<?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>midion</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="midion2.html" title="midion2" /> <link rel="next" href="midiout.html" title="midiout" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">midion</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="midion2.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="midiout.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry" title="midion"> <a id="midion"></a> <div class="titlepage"></div> <a id="IndexMidion" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">midion</span> </h2> <p>midion — Generates MIDI note messages at k-rate. </p> </div> <div class="refsect1" title="Description"> <a id="idp31306168"></a> <h2>Description</h2> <p> Generates MIDI note messages at k-rate. </p> </div> <div class="refsect1" title="Syntax"> <a id="idp31306816"></a> <h2>Syntax</h2> <pre class="synopsis"><span class="command"><strong>midion</strong></span> kchn, knum, kvel</pre> </div> <div class="refsect1" title="Performance"> <a id="idp31317160"></a> <h2>Performance</h2> <p> <span class="emphasis"><em>kchn</em></span> -- MIDI channel number (1-16) </p> <p> <span class="emphasis"><em>knum</em></span> -- note number (0-127) </p> <p> <span class="emphasis"><em>kvel</em></span> -- velocity (0-127) </p> <p> <span class="emphasis"><em>midion</em></span> (k-rate note on) plays MIDI notes with current <span class="emphasis"><em>kchn</em></span>, <span class="emphasis"><em>knum</em></span> and <span class="emphasis"><em>kvel</em></span>. These arguments can be varied at k-rate. Each time the MIDI converted value of any of these arguments changes, last MIDI note played by current instance of <span class="emphasis"><em>midion</em></span> is immediately turned off and a new note with the new argument values is activated. This opcode, as well as <span class="emphasis"><em>moscil</em></span>, can generate very complex melodic textures if controlled by complex k-rate signals. </p> <p> Any number of <span class="emphasis"><em>midion</em></span> opcodes can appear in the same Csound instrument, allowing a counterpoint-style polyphony within a single instrument. </p> </div> <div class="refsect1" title="Examples"> <a id="idp31358408"></a> <h2>Examples</h2> <p> Here is a simple example of the midion opcode. It uses the file <a class="ulink" href="examples/midion_simple.csd" target="_top"><em class="citetitle">midion_simple.csd</em></a>. </p> <div class="example"> <a id="idp31359336"></a> <p class="title"> <strong>Example 467. Simple Example of the midion 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> <p>This example generates a minor chord over every note received on the MIDI input. It generates MIDI notes on csound's MIDI output, so be sure to connect something.</p> <pre class="programlisting"> <span class="csdtag"><CsoundSynthesizer></span> <span class="csdtag"><CsOptions></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 -Q1 <span class="comment">;;;RT audio I/O with MIDI in</span> <span class="csdtag"></CsOptions></span> <span class="csdtag"><CsInstruments></span> <span class="ohdr">sr</span> <span class="op">=</span> 44100 <span class="ohdr">kr</span> <span class="op">=</span> 4410 <span class="ohdr">ksmps</span> <span class="op">=</span> 10 <span class="ohdr">nchnls</span> <span class="op">=</span> 2 <span class="comment">; Example by Giorgio Zucco 2007</span> <span class="oblock">instr</span> 1 <span class="comment">;Triggered by MIDI notes on channel 1</span> ifund <span class="opc">notnum</span> ivel <span class="opc">veloc</span> knote1 <span class="opc">init</span> ifund knote2 <span class="opc">init</span> ifund <span class="op">+</span> 3 knote3 <span class="opc">init</span> ifund <span class="op">+</span> 5 <span class="comment">;minor chord on MIDI out channel 1</span> <span class="comment">;Needs something plugged to csound's MIDI output</span> <span class="opc">midion</span> 1, knote1,ivel <span class="opc">midion</span> 1, knote2,ivel <span class="opc">midion</span> 1, knote3,ivel <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="comment">; Dummy ftable</span> <span class="stamnt">f</span>0 60 <span class="csdtag"></CsScore></span> <span class="csdtag"></CsoundSynthesizer></span> </pre> </div> </div> <p><br class="example-break" /> Here is another example of the midion opcode. It uses the file <a class="ulink" href="examples/midion_scale.csd" target="_top"><em class="citetitle">midion_scale.csd</em></a>. </p> <div class="example"> <a id="idp31362328"></a> <p class="title"> <strong>Example 468. Example of the midion opcode to generate random notes from a scale.</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> <p>This example generates random notes from a given scale for every note received on the MIDI input. It generates MIDI notes on csound's MIDI output, so be sure to connect something.</p> <pre class="programlisting"> <span class="csdtag"><CsoundSynthesizer></span> <span class="csdtag"><CsOptions></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 -Q1 <span class="comment">;;;RT audio I/O with MIDI in</span> <span class="csdtag"></CsOptions></span> <span class="csdtag"><CsInstruments></span> <span class="ohdr">sr</span> <span class="op">=</span> 44100 <span class="ohdr">kr</span> <span class="op">=</span> 4410 <span class="ohdr">ksmps</span> <span class="op">=</span> 10 <span class="ohdr">nchnls</span> <span class="op">=</span> 2 <span class="comment">; Example by Giorgio Zucco 2007</span> <span class="oblock">instr</span> 1 <span class="comment">; Triggered by MIDI notes on channel 1</span> ivel <span class="opc">veloc</span> krate <span class="op">=</span> 8 iscale <span class="op">=</span> 100 <span class="comment">;f</span> <span class="comment">; Random sequence from table f100</span> krnd <span class="opc">randh</span> <span class="opc">int</span>(14),krate,<span class="op">-</span>1 knote <span class="opc">table</span> <span class="opc">abs</span>(krnd),iscale <span class="comment">; Generates random notes from the scale on ftable 100</span> <span class="comment">; on channel 1 of csound's MIDI output</span> <span class="opc">midion</span> 1,knote,ivel <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="stamnt">f</span>100 0 32 -2 40 50 60 70 80 44 54 65 74 84 39 49 69 69 <span class="comment">; Dummy ftable</span> <span class="stamnt">f</span>0 60 <span class="csdtag"></CsScore></span> <span class="csdtag"></CsoundSynthesizer></span> </pre> </div> </div> <p><br class="example-break" /> </p> </div> <div class="refsect1" title="See Also"> <a id="idp31365016"></a> <h2>See Also</h2> <p> <a class="link" href="moscil.html" title="moscil"><em class="citetitle">moscil</em></a>, <a class="link" href="midion2.html" title="midion2"><em class="citetitle">midion2</em></a>, <a class="link" href="noteon.html" title="noteon"><em class="citetitle">noteon</em></a>, <a class="link" href="noteoff.html" title="noteoff"><em class="citetitle">noteoff</em></a>, <a class="link" href="noteondur.html" title="noteondur"><em class="citetitle">noteondur</em></a>, <a class="link" href="noteondur2.html" title="noteondur2"><em class="citetitle">noteondur2</em></a> </p> </div> <div class="refsect1" title="Credits"> <a id="idp31368432"></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>May 1997</td> </tr> </table> <p> </p> <p>Thanks goes to Rasmus Ekman for pointing out the correct MIDI channel and controller number ranges.</p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="midion2.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="midiout.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">midion2 </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> midiout</td> </tr> </table> </div> </body> </html>