| 1 | |
| 2 | <refentry id="active"> |
| 3 | <indexterm id="IndexActive"><primary>active</primary></indexterm> |
| 4 | <refentryinfo><title>Instrument Control:Realtime Performance Control</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>active</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>active</refname> |
| 11 | <refpurpose> |
| 12 | Returns the number of active instances of an instrument. |
| 13 | </refpurpose> |
| 14 | </refnamediv> |
| 15 | |
| 16 | <refsect1> |
| 17 | <title>Description</title> |
| 18 | <para> |
| 19 | Returns the number of active instances of an instrument with |
| 20 | options to ignore releasing instances. |
| 21 | </para> |
| 22 | </refsect1> |
| 23 | |
| 24 | <refsect1> |
| 25 | <title>Syntax</title> |
| 26 | <synopsis>ir <command>active</command> insnum [,iopt [,inorel]]</synopsis> |
| 27 | <synopsis>ir <command>active</command> Sinsname [,iopt [,inorel]]</synopsis> |
| 28 | <synopsis>kres <command>active</command> kinsnum [,iopt [,inorel]]</synopsis> |
| 29 | </refsect1> |
| 30 | |
| 31 | <refsect1> |
| 32 | <title>Initialization</title> |
| 33 | <para> |
| 34 | <emphasis>insnum</emphasis> -- number or string name of the instrument to be reported |
| 35 | </para> |
| 36 | <para> |
| 37 | <emphasis>Sinsname</emphasis> -- instrument name |
| 38 | </para> |
| 39 | <para> |
| 40 | <emphasis>iopt</emphasis> -- select currently active (zero, default), |
| 41 | or all every active (non zero) |
| 42 | </para> |
| 43 | <para> |
| 44 | <emphasis>inorel</emphasis> -- if non-zero ignore instruments in |
| 45 | release phase (zero, default), only valid if iopts is zero. |
| 46 | </para> |
| 47 | </refsect1> |
| 48 | |
| 49 | <refsect1> |
| 50 | <title>Performance</title> |
| 51 | <para> |
| 52 | <emphasis>kinsnum</emphasis> -- number or string name of the instrument to be reported |
| 53 | </para> |
| 54 | |
| 55 | <para> |
| 56 | <emphasis>active</emphasis> returns the number of active |
| 57 | instances of instrument number |
| 58 | <emphasis>insnum/kinsnum</emphasis> (or named instrument |
| 59 | <emphasis>Sinsname</emphasis>). As of Csound 4.17 the output is |
| 60 | updated at k-rate (if input arg is k-rate), to allow running |
| 61 | count of instr instances. |
| 62 | </para> |
| 63 | <para> |
| 64 | As of Csound 5.17 if the instrument number is given as zero then |
| 65 | all instruments are counted. |
| 66 | </para> |
| 67 | </refsect1> |
| 68 | |
| 69 | <refsect1> |
| 70 | <title>Examples</title> |
| 71 | |
| 72 | <para> |
| 73 | Here is a simple example of the active opcode. It uses the file |
| 74 | <ulink |
| 75 | url="examples/active.csd"><citetitle>active.csd</citetitle></ulink>. |
| 76 | |
| 77 | <example> |
| 78 | <title>Simple example of the active opcode.</title> |
| 79 | <para> |
| 80 | See the sections <link linkend="UsingRealTime"><citetitle>Real-time |
| 81 | Audio</citetitle></link> and <link |
| 82 | linkend="CommandFlags"><citetitle>Command Line |
| 83 | Flags</citetitle></link> for more information on using command |
| 84 | line flags. |
| 85 | </para> |
| 86 | <xi:include href="examples-xml/active.csd.xml" |
| 87 | xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 88 | </example> |
| 89 | |
| 90 | Its output should include lines like this: |
| 91 | <screen> |
| 92 | instr 2: icount = 1.000 |
| 93 | instr 2: icount = 2.000 |
| 94 | </screen> |
| 95 | </para> |
| 96 | |
| 97 | <para> |
| 98 | Here is a more advanced example of the active opcode. It displays the results of the active opcode at k-rate instead of i-rate. It uses the file <ulink url="examples/active_k.csd"><citetitle>active_k.csd</citetitle></ulink>. |
| 99 | |
| 100 | <example> |
| 101 | <title>Example of the active opcode at k-rate.</title> |
| 102 | |
| 103 | <xi:include href="examples-xml/active_k.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 104 | </example> |
| 105 | |
| 106 | Its output should include lines like: |
| 107 | <screen> |
| 108 | i2 1.00000 |
| 109 | i2 2.00000 |
| 110 | </screen> |
| 111 | </para> |
| 112 | <para> |
| 113 | Here is another example of the active opcode, using the number of instances to calculate gain. It uses the file <ulink url="examples/active_scale.csd"><citetitle>active_scale.csd</citetitle></ulink>. |
| 114 | <example> |
| 115 | <title>Example of the active opcode at k-rate.</title> |
| 116 | <xi:include href="examples-xml/active_scale.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 117 | </example> |
| 118 | </para> |
| 119 | </refsect1> |
| 120 | |
| 121 | <refsect1> |
| 122 | <title>See also</title> |
| 123 | <para><link linkend="ControlRealtime"><citetitle>Real-time Performance Control</citetitle></link></para> |
| 124 | </refsect1> |
| 125 | |
| 126 | <refsect1> |
| 127 | <title>Credits</title> |
| 128 | <para> |
| 129 | <simplelist> |
| 130 | <member>Author: &namejohn;</member> |
| 131 | <member>University of Bath/Codemist Ltd.</member> |
| 132 | <member>Bath, UK</member> |
| 133 | <member>July, 1999</member> |
| 134 | </simplelist> |
| 135 | </para> |
| 136 | <para>Examples written by &namekevin;.</para> |
| 137 | <para>New in Csound version 3.57; named instruments added version 5.13</para> |
| 138 | <para>Option for all ever active new in 5.13</para> |
| 139 | <para>Count of all instruments new in 5.17</para> |
| 140 | <para>No release option new in 5.19</para> |
| 141 | </refsect1> |
| 142 | </refentry> |