Sophie

Sophie

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

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>midiin</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="mididefault.html" title="mididefault" />
    <link rel="next" href="midinoteoff.html" title="midinoteoff" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">midiin</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="mididefault.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="midinoteoff.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="midiin">
      <a id="midiin"></a>
      <div class="titlepage"></div>
      <a id="IndexMidiin" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">midiin</span>
        </h2>
        <p>midiin — 
      Returns a generic MIDI message received by the MIDI IN port.
          </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="idp31025600"></a>
        <h2>Description</h2>
        <p>
      Returns a generic MIDI message received by the MIDI IN port
    </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="idp31026360"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">kstatus, kchan, kdata1, kdata2 <span class="command"><strong>midiin</strong></span></pre>
      </div>
      <div class="refsect1" title="Performance">
        <a id="idp31027408"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>kstatus</em></span> -- the type of MIDI message. Can be:
      </p>
        <div class="itemizedlist">
          <ul class="itemizedlist" type="disc">
            <li class="listitem">
              <p>128 (note off)</p>
            </li>
            <li class="listitem">
              <p>144 (note on)</p>
            </li>
            <li class="listitem">
              <p>160 (polyphonic aftertouch)</p>
            </li>
            <li class="listitem">
              <p>176 (control change)</p>
            </li>
            <li class="listitem">
              <p>192 (program change)</p>
            </li>
            <li class="listitem">
              <p>208 (channel aftertouch)</p>
            </li>
            <li class="listitem">
              <p>224 (pitch bend</p>
            </li>
            <li class="listitem">
              <p>0 if no MIDI message are pending in the MIDI IN buffer</p>
            </li>
          </ul>
        </div>
        <p>
    </p>
        <p>
      <span class="emphasis"><em>kchan</em></span> -- MIDI channel (1-16)
    </p>
        <p>
      <span class="emphasis"><em>kdata1, kdata2</em></span> -- message-dependent data values
    </p>
        <p>
      <span class="emphasis"><em>midiin</em></span> has no input arguments, because it reads at the MIDI in port implicitly. It works at k-rate. Normally (i.e., when no messages are pending) <span class="emphasis"><em>kstatus</em></span> is zero, only when MIDI data are present in the MIDI IN buffer, is <span class="emphasis"><em>kstatus</em></span> set to the type of the relevant messages.
    </p>
        <div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;">
          <table border="0" summary="Note">
            <tr>
              <td rowspan="2" align="center" valign="top" width="25">
                <img alt="[Note]" src="images/note.png" />
              </td>
              <th align="left">Note</th>
            </tr>
            <tr>
              <td align="left" valign="top">
                <p>
	Be careful when using <span class="emphasis"><em>midiin</em></span> in low numbered instruments, since a MIDI note will launch additional instances of the instrument, resulting in duplicate events and weird behaviour. Use <a class="link" href="massign.html" title="massign"><em class="citetitle">massign</em></a> to direct MIDI note on messages to a different instrument or to disable triggering of instruments from MIDI.
      </p>
              </td>
            </tr>
          </table>
        </div>
      </div>
      <div class="refsect1" title="Examples">
        <a id="idp31083232"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the midiin opcode. It uses the file <a class="ulink" href="examples/midiin.csd" target="_top"><em class="citetitle">midiin.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp31084208"></a>
          <p class="title">
            <strong>Example 460. Example of the midiin 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>
<span class="comment">; Audio out   Audio in    No messages</span>
-odac           -iadc     -d         -M0  -+rtmidi=virtual <span class="comment">;;;RT audio I/O with MIDI in</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o midiin.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>  10
<span class="ohdr">nchnls</span>    <span class="op">=</span>  1

<span class="comment">; Example by schwaahed 2006</span>

      <span class="ohdr">massign</span>         0, 130  <span class="comment">; make sure that all channels</span>
      <span class="ohdr">pgmassign</span>       0, 130  <span class="comment">; and programs are assigned to test instr</span>


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

knotelength    <span class="opc">init</span>    0
knoteontime    <span class="opc">init</span>    0

kstatus, kchan, kdata1, kdata2                  <span class="opc">midiin</span>

<span class="octrl">if</span> (kstatus <span class="op">==</span> 128) then
knoteofftime    <span class="opc">times</span>
knotelength    <span class="op">=</span>    knoteofftime <span class="op">-</span> knoteontime
<span class="opc">printks</span> "kstatus<span class="op">=</span> <span class="op">%</span>d, kchan <span class="op">=</span> <span class="op">%</span>d, \\tnote#  <span class="op">=</span> <span class="op">%</span>d, velocity <span class="op">=</span> <span class="op">%</span>d \\tNote OFF\\t<span class="op">%</span>f <span class="op">%</span>f\\n", 0, kstatus, kchan, kdata1,kdata2, knoteofftime, knotelength

<span class="octrl">elseif</span> (kstatus <span class="op">==</span> 144) then
knoteontime    <span class="opc">times</span>
<span class="opc">printks</span> "kstatus<span class="op">=</span> <span class="op">%</span>d, kchan <span class="op">=</span> <span class="op">%</span>d, \\tnote#  <span class="op">=</span> <span class="op">%</span>d, velocity <span class="op">=</span> <span class="op">%</span>d \\tNote ON\\t<span class="op">%</span>f\\n", 0, kstatus, kchan, kdata1, kdata2, knoteontime


<span class="octrl">elseif</span> (kstatus <span class="op">==</span> 160) then
<span class="opc">printks</span> "kstatus<span class="op">=</span> <span class="op">%</span>d, kchan <span class="op">=</span> <span class="op">%</span>d, \\tkdata1 <span class="op">=</span> <span class="op">%</span>d, kdata2 <span class="op">=</span> <span class="op">%</span>d \\tPolyphonic Aftertouch\\n", 0, kstatus, kchan, kdata1, kdata2

<span class="octrl">elseif</span> (kstatus <span class="op">==</span> 176) then
<span class="opc">printks</span> "kstatus<span class="op">=</span> <span class="op">%</span>d, kchan <span class="op">=</span> <span class="op">%</span>d, \\t CC <span class="op">=</span> <span class="op">%</span>d, value <span class="op">=</span> <span class="op">%</span>d \\tControl Change\\n", 0, kstatus, kchan, kdata1, kdata2

<span class="octrl">elseif</span> (kstatus <span class="op">==</span> 192) then
<span class="opc">printks</span> "kstatus<span class="op">=</span> <span class="op">%</span>d, kchan <span class="op">=</span> <span class="op">%</span>d, \\tkdata1 <span class="op">=</span> <span class="op">%</span>d, kdata2 <span class="op">=</span> <span class="op">%</span>d \\tProgram Change\\n", 0, kstatus, kchan, kdata1, kdata2

<span class="octrl">elseif</span> (kstatus <span class="op">==</span> 208) then
<span class="opc">printks</span>  "kstatus<span class="op">=</span> <span class="op">%</span>d, kchan <span class="op">=</span> <span class="op">%</span>d, \\tkdata1 <span class="op">=</span> <span class="op">%</span>d, kdata2 <span class="op">=</span> <span class="op">%</span>d \\tChannel Aftertouch\\n", 0, kstatus, kchan, kdata1, kdata2

<span class="octrl">elseif</span> (kstatus <span class="op">==</span> 224) then
<span class="opc">printks</span> "kstatus<span class="op">=</span> <span class="op">%</span>d, kchan <span class="op">=</span> <span class="op">%</span>d, \\t ( data1 , kdata2 ) <span class="op">=</span> ( <span class="op">%</span>d, <span class="op">%</span>d )\\tPitch Bend\\n", 0, kstatus, kchan, kdata1, kdata2

<span class="octrl">endif</span>

  <span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">i</span>130 0 3600
<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>
      </div>
      <div class="refsect1" title="Credits">
        <a id="idp31086448"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Gabriel Maldonado</td>
          </tr>
          <tr>
            <td>Italy</td>
          </tr>
          <tr>
            <td>1998</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in Csound version 3.492</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="mididefault.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="midinoteoff.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">mididefault </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> midinoteoff</td>
        </tr>
      </table>
    </div>
  </body>
</html>