<!-- Converted to DocBook/SGML by Kevin Conder -->
<refentry id="active">
  <refmeta>
    <refentrytitle>active</refentrytitle>
  </refmeta>
 
  <refnamediv>
    <refname>active</refname>

    <refpurpose>
      Returns the number of active instances of an instrument.
      <indexterm id="IndexActive"><primary>active</primary></indexterm>
    </refpurpose>
  </refnamediv>
 
  <refsect1>
    <title>Description</title>
    <para>
      Returns the number of active instances of an instrument.
    </para>
  </refsect1>

  <refsect1>
    <title>Syntax</title>
    <synopsis>ir <command>active</command> insnum</synopsis>

    <synopsis>kr <command>active</command> kinsnum</synopsis>
  </refsect1>

  <refsect1>
    <title>Initialization</title>
    <para>
      <emphasis>insnum</emphasis> -- number of the instrument to be reported
    </para>
  </refsect1>
 
  <refsect1>
    <title>Performance</title>
    <para>
      <emphasis>kinsnum</emphasis> -- number of the instrument to be reported
    </para>

    <para>
      <emphasis>active</emphasis> returns the number of active instances of instrument number insnum/kinsnum.  As of Csound4.17 the output is updated at k-rate (if input arg is k-rate), to allow running count of instr instances.
    </para>
  </refsect1>
 
  <refsect1>
    <title>Examples</title>

    <para>
      Here is a simple example of the active opcode. It uses the files <ulink url="examples/active.orc"><citetitle>active.orc</citetitle></ulink> and <ulink url="examples/active.sco"><citetitle>active.sco</citetitle></ulink>.

      <example>
        <title>Simple example of the active opcode.</title>

        <programlisting>
<inlinemediaobject>
            <imageobject>
              <imagedata fileref="examples/active.orc" format="linespecific">
            </imageobject>
          </inlinemediaobject>
        </programlisting>
    
        <programlisting>
<inlinemediaobject>
            <imageobject>
              <imagedata fileref="examples/active.sco" format="linespecific">
            </imageobject>
          </inlinemediaobject>
        </programlisting>
      </example>

      Its output should include lines like this:
      <screen>
instr 2:  icount = 1.000
instr 2:  icount = 2.000
      </screen>
    </para>

    <para>
      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 files <ulink url="examples/active_k.orc"><citetitle>active_k.orc</citetitle></ulink> and <ulink url="examples/active_k.sco"><citetitle>active_k.sco</citetitle></ulink>.

      <example>
        <title>Example of the active opcode at k-rate.</title>

        <programlisting>
<inlinemediaobject>
            <imageobject>
              <imagedata fileref="examples/active_k.orc" format="linespecific">
            </imageobject>
          </inlinemediaobject>
        </programlisting>
    
        <programlisting>
<inlinemediaobject>
            <imageobject>
              <imagedata fileref="examples/active_k.sco" format="linespecific">
            </imageobject>
          </inlinemediaobject>
        </programlisting>
      </example>

      Its output should include lines like:
      <screen>
 i2     1.00000
 i2     2.00000
      </screen>
    </para>
  </refsect1>
 
  <refsect1>
    <title>Credits</title>
    <para>
      <simplelist>
        <member>Author: &namejohn;</member>
        <member>University of Bath/Codemist Ltd.</member>
        <member>Bath, UK</member>
        <member>July, 1999</member>
      </simplelist>
    </para>
    <para>Examples written by &namekevin;.</para>
    <para>New in Csound version 3.57</para>
  </refsect1>
</refentry>
