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

  <refnamediv>
    <refname>midichn</refname>
    <refpurpose>
      Returns the MIDI channel number from which the note was activated.
      <indexterm id="IndexMidichn"><primary>midichn</primary></indexterm>
    </refpurpose>
  </refnamediv>
  
  <refsect1>
    <title>Description</title>
    <para>
      <emphasis>midichn</emphasis> returns the MIDI channel number (1 - 16) from which the note was activated. In the case of score notes, it returns 0.
    </para>
  </refsect1>

  <refsect1>
    <title>Syntax</title>
    <synopsis>ichn <command>midichn</command></synopsis>
  </refsect1>

  <refsect1>
    <title>Initialization</title>
    <para>
      <emphasis>ichn</emphasis> -- channel number. If the current note was activated from score, it is set to zero.
    </para>
  </refsect1>

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

      <example>
        <title>Example of the midichn opcode.</title>

        <programlisting>
<inlinemediaobject>
            <imageobject>
              <imagedata fileref="examples/midichn.orc" format="linespecific">
            </imageobject>
          </inlinemediaobject>
        </programlisting>

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

    <para>
      Here is an advanced example of the midichn opcode. It uses the files <ulink url="examples/midichn_advanced.mid"><citetitle>midichn_advanced.mid</citetitle></ulink>, <ulink url="examples/midichn_advanced.orc"><citetitle>midichn_advanced.orc</citetitle></ulink>, and <ulink url="examples/midichn_advanced.sco"><citetitle>midichn_advanced.sco</citetitle></ulink>. 
    </para>

    <para>
      Don't forget that you must include the <link linkend="FlagsMinusUpperF"><citetitle>-F flag</citetitle></link> when using an external MIDI file like <quote>midichn_advanced.mid</quote>.
    </para>

    <para>
      <example>
        <title>An advanced example of the midichn opcode.</title>

        <programlisting>
<inlinemediaobject>
            <imageobject>
              <imagedata fileref="examples/midichn_advanced.orc" format="linespecific">
            </imageobject>
          </inlinemediaobject>
        </programlisting>

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

      Its output should include lines like:
      <screen>
note 7 (time = 0.00) was activated from channel 4
note 8 (time = 0.00) was activated from channel 2
      </screen>
    </para>
  </refsect1>

  <refsect1>
    <title>See Also</title>
    <para>
      <link linkend="pgmassign"><citetitle>pgmassign</citetitle></link>
    </para>
  </refsect1>

  <refsect1>
    <title>Credits</title>
    <para>
      <simplelist>
        <member>Author: &nameistvan;</member>
        <member>May 2002</member>
      </simplelist>
    </para>
    <para>The simple example was written by &namekevin;.</para>

    <para>New in version 4.20</para>
  </refsect1>
</refentry>
