Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-release > by-pkgid > b707d9a4ee443103660a75ccb6e51334 > files > 2190

csound-doc-5.19.01-10.mga5.noarch.rpm

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>midichn</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.76.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="midichannelaftertouch.html" title="midichannelaftertouch" />
    <link rel="next" href="midicontrolchange.html" title="midicontrolchange" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">midichn</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="midichannelaftertouch.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="midicontrolchange.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="midichn">
      <a id="midichn"></a>
      <div class="titlepage"></div>
      <a id="IndexMidichn" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">midichn</span>
        </h2>
        <p>midichn — 
      Returns the MIDI channel number from which the note was activated.
          </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="idp30873512"></a>
        <h2>Description</h2>
        <p>
      <span class="emphasis"><em>midichn</em></span> returns the MIDI channel number (1 - 16) from which the note was activated. In the case of score notes, it returns 0.
    </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="idp30927624"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ichn <span class="command"><strong>midichn</strong></span></pre>
      </div>
      <div class="refsect1" title="Initialization">
        <a id="idp30928568"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>ichn</em></span> -- channel number. If the current note was activated from score, it is set to zero.
    </p>
      </div>
      <div class="refsect1" title="Examples">
        <a id="idp30929576"></a>
        <h2>Examples</h2>
        <p>
      Here is a simple example of the midichn opcode. It uses the file <a class="ulink" href="examples/midichn.csd" target="_top"><em class="citetitle">midichn.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp30930568"></a>
          <p class="title">
            <strong>Example 455. Example of the midichn opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac -M0 -+rtmidi=virtual <span class="comment">;;; midi file input</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1

<span class="oblock">instr</span> 1	 
<span class="comment">;change channel on virtual midi keyboard</span>
i1 <span class="opc">midichn</span>
   <span class="opc">print</span> i1

<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">f</span> 0 20	<span class="comment">;runs for 20 seconds</span>

<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
        <p>
      Here is an advanced example of the midichn opcode. It uses the file <a class="ulink" href="examples/midichn_advanced.csd" target="_top"><em class="citetitle">midichn_advanced.csd</em></a>. 
    </p>
        <p>
      Don't forget that you must include the <a class="link" href="CommandFlags.html#FlagsMinusUpperF"><em class="citetitle">-F flag</em></a> when using an external MIDI file like <span class="quote">“<span class="quote">midichn_advanced.mid</span>”</span>.
    </p>
        <p>
      </p>
        <div class="example">
          <a id="idp30934808"></a>
          <p class="title">
            <strong>Example 456. An advanced example of the midichn opcode.</strong>
          </p>
          <div class="example-contents">
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac -F midichn_advanced.mid <span class="comment">;;;realtime audio out with MIDI file input</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o midichn_advanced.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1

	<span class="ohdr">massign</span>  1, 1		<span class="comment">; all channels use instr 1</span>
	<span class="ohdr">massign</span>  2, 1
	<span class="ohdr">massign</span>  3, 1
	<span class="ohdr">massign</span>  4, 1
	<span class="ohdr">massign</span>  5, 1
	<span class="ohdr">massign</span>  6, 1
	<span class="ohdr">massign</span>  7, 1
	<span class="ohdr">massign</span>  8, 1
	<span class="ohdr">massign</span>  9, 1
	<span class="ohdr">massign</span> 10, 1
	<span class="ohdr">massign</span> 11, 1
	<span class="ohdr">massign</span> 12, 1
	<span class="ohdr">massign</span> 13, 1
	<span class="ohdr">massign</span> 14, 1
	<span class="ohdr">massign</span> 15, 1
	<span class="ohdr">massign</span> 16, 1

gicnt	<span class="op">=</span>  0		<span class="comment">; note counter</span>

	<span class="oblock">instr</span> 1

gicnt	<span class="op">=</span>  gicnt <span class="op">+</span> 1	<span class="comment">; update note counter</span>
kcnt	<span class="opc">init</span> gicnt	<span class="comment">; copy to local variable</span>
ichn	<span class="opc">midichn</span>		<span class="comment">; get channel number</span>
istime	<span class="opc">times</span>		<span class="comment">; note-on time</span>

	<span class="octrl">if</span> (ichn <span class="op">&gt;</span> 0.5) <span class="octrl">goto</span> <span class="olabel">l2</span>		<span class="comment">; MIDI note</span>
	<span class="opc">printks</span> "note <span class="op">%</span>.0f (time <span class="op">=</span> <span class="op">%</span>.2f) was activated from the score\\n", \
		3600, kcnt, istime
	<span class="octrl">goto</span> <span class="olabel">l1</span>
<span class="olabel">l2</span><span class="op">:</span>
	<span class="opc">printks</span> "note <span class="op">%</span>.0f (time <span class="op">=</span> <span class="op">%</span>.2f) was activated from channel <span class="op">%</span>.0f\\n", \
		3600, kcnt, istime, ichn
<span class="olabel">l1</span><span class="op">:</span>

icps	<span class="opc">cpsmidi</span>		<span class="comment">; convert midi note to pitch</span>
kenv	<span class="opc">madsr</span>	0.1, 0, 0.8, 0.9
asig	<span class="opc">pluck</span>	kenv, icps, icps, 1, 1	 
	<span class="opc">outs</span>	asig, asig
	 
<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">t</span> 0 60		<span class="comment">;beats per minute</span>

<span class="stamnt">f</span> 0 8		<span class="comment">;stay active for 8 seconds</span>
<span class="stamnt">f</span> 1 0 4096 10 1	<span class="comment">;sine</span>

<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />

      Its output should include lines like:
      </p>
        <pre class="screen">
note 1 (time = 0.00) was activated from channel 1
note 2 (time = 2.00) was activated from channel 4
note 3 (time = 3.00) was activated from channel 2
note 4 (time = 5.00) was activated from channel 3
      </pre>
        <p>
    </p>
      </div>
      <div class="refsect1" title="See Also">
        <a id="idp30936592"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="pgmassign.html" title="pgmassign"><em class="citetitle">pgmassign</em></a>
    </p>
      </div>
      <div class="refsect1" title="Credits">
        <a id="idp30937664"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Istvan Varga</td>
          </tr>
          <tr>
            <td>May 2002</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in version 4.20</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="midichannelaftertouch.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="midicontrolchange.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">midichannelaftertouch </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> midicontrolchange</td>
        </tr>
      </table>
    </div>
  </body>
</html>