<?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>cpstmid</title> <link rel="stylesheet" type="text/css" href="csound.css" /> <link rel="stylesheet" type="text/css" href="syntax-highlighting.css" /> <meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /> <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="cpspch.html" title="cpspch" /> <link rel="next" href="cpstun.html" title="cpstun" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">cpstmid</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="cpspch.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="cpstun.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry"> <a id="cpstmid"></a> <div class="titlepage"></div> <a id="IndexCpstmid" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">cpstmid</span> </h2> <p>cpstmid — Get a MIDI note number (allows customized micro-tuning scales). </p> </div> <div class="refsect1"> <a id="idm281472944401832"></a> <h2>Description</h2> <p> This unit is similar to <a class="link" href="cpsmidi.html" title="cpsmidi"><em class="citetitle">cpsmidi</em></a>, but allows fully customized micro-tuning scales. </p> </div> <div class="refsect1"> <a id="idm281472944357192"></a> <h2>Syntax</h2> <pre class="synopsis">icps <span class="command"><strong>cpstmid</strong></span> ifn</pre> </div> <div class="refsect1"> <a id="idm281472944354952"></a> <h2>Initialization</h2> <p> <span class="emphasis"><em>ifn</em></span> -- function table containing the parameters (<span class="emphasis"><em>numgrades</em></span>, <span class="emphasis"><em>interval</em></span>, <span class="emphasis"><em>basefreq</em></span>, <span class="emphasis"><em>basekeymidi</em></span>) and the tuning ratios. </p> </div> <div class="refsect1"> <a id="idm281472944351544"></a> <h2>Performance</h2> <p> Init-rate only </p> <p> <span class="emphasis"><em>cpsmid</em></span> requires five parameters, the first, <span class="emphasis"><em>ifn</em></span>, is the function table number of the tuning ratios, and the other parameters must be stored in the function table itself. The function table <span class="emphasis"><em>ifn</em></span> should be generated by <a class="link" href="GEN02.html" title="GEN02"><em class="citetitle">GEN02</em></a>, with normalization inhibited. The first four values stored in this function are: </p> <div class="orderedlist"> <ol class="orderedlist" type="1"> <li class="listitem"> <p><span class="emphasis"><em>numgrades</em></span> -- the number of grades of the micro-tuning scale</p> </li> <li class="listitem"> <p><span class="emphasis"><em>interval</em></span> -- the frequency range covered before repeating the grade ratios, for example 2 for one octave, 1.5 for a fifth etc.</p> </li> <li class="listitem"> <p><span class="emphasis"><em>basefreq</em></span> -- the base frequency of the scale in Hz</p> </li> <li class="listitem"> <p><span class="emphasis"><em>basekeymidi</em></span> -- the MIDI note number to which <span class="emphasis"><em>basefreq</em></span> is assigned unmodified</p> </li> </ol> </div> <p> </p> <p> After these four values, the user can begin to insert the tuning ratios. For example, for a standard 12 note scale with the base frequency of 261 Hz assigned to the key number 60, the corresponding f-statement in the score to generate the table should be: </p> <div class="literallayout"> <p><br /> ; numgrades interval basefreq basekeymidi tuning ratios (equal temp) <br /> f1 0 64 -2 12 2 261 60 1 1.059463094359 1.122462048309 1.189207115003 ..etc... <br /> </p> </div> <p> </p> <p> Another example with a 24 note scale with a base frequency of 440 assigned to the key number 48, and a repetition interval of 1.5: </p> <div class="literallayout"> <p><br /> ; numgrades interval basefreq basekeymidi tuning-ratios (equal temp) <br /> f1 0 64 -2 24 1.5 440 48 1 1.01 1.02 1.03 ..etc... <br /> </p> </div> <p> </p> </div> <div class="refsect1"> <a id="idm281472944337896"></a> <h2>Examples</h2> <p> Here is an example of the cpstmid opcode. It uses the file <a class="ulink" href="examples/cpstmid.csd" target="_top"><em class="citetitle">cpstmid.csd</em></a>. </p> <div class="example"> <a id="idm281472944336120"></a> <p class="title"> <strong>Example 164. Example of the cpstmid 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> <div class="refsect1"> <a id="idm281472777416968"></a> <pre class="programlisting"> <span class="nt"><CsoundSynthesizer></span> <span class="nt"><CsOptions></span> <span class="c1">; Select audio/midi flags here according to platform</span> -odac -M0 <span class="c1">;;;RT audio I/O with MIDI in</span> <span class="c1">;-iadc ;;;uncomment -iadc if RT audio input is needed too</span> <span class="c1">; For Non-realtime ouput leave only the line below:</span> <span class="c1">; -o cpstmid.wav -W ;;; for file output any platform</span> <span class="nt"></CsOptions></span> <span class="nt"><CsInstruments></span> <span class="c1">; after an example from Kevin Conder</span> <span class="vg">sr</span> <span class="o">=</span> <span class="mi">44100</span> <span class="vg">ksmps</span> <span class="o">=</span> <span class="mi">32</span> <span class="vg">nchnls</span> <span class="o">=</span> <span class="mi">2</span> <span class="vg">0dbfs</span> <span class="o">=</span> <span class="mi">1</span> <span class="c1">; Table #1, a normal 12-tone equal temperament scale.</span> <span class="c1">; numgrades = 12 (twelve tones)</span> <span class="c1">; interval = 2 (one octave)</span> <span class="c1">; basefreq = 261.659 (Middle C)</span> <span class="c1">; basekeymidi = 60 (Middle C)</span> gi<span class="n">temp</span> <span class="nb">ftgen</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">64</span><span class="p">,</span> <span class="o">-</span><span class="mi">2</span><span class="p">,</span> <span class="mi">12</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mf">261.659</span><span class="p">,</span> <span class="mi">60</span><span class="p">,</span> <span class="mf">1.00</span><span class="p">,</span> \ <span class="mf">1.059</span><span class="p">,</span> <span class="mf">1.122</span><span class="p">,</span> <span class="mf">1.189</span><span class="p">,</span> <span class="mf">1.260</span><span class="p">,</span> <span class="mf">1.335</span><span class="p">,</span> <span class="mf">1.414</span><span class="p">,</span> \ <span class="mf">1.498</span><span class="p">,</span> <span class="mf">1.588</span><span class="p">,</span> <span class="mf">1.682</span><span class="p">,</span> <span class="mf">1.782</span><span class="p">,</span> <span class="mf">1.888</span><span class="p">,</span> <span class="mf">2.000</span> <span class="kd">instr</span> <span class="nf">1</span> i<span class="n">fn</span> <span class="o">=</span> <span class="mi">1</span> i<span class="n">cps</span> <span class="nb">cpstmid</span> i<span class="n">fn</span> <span class="nb">print</span> i<span class="n">cps</span> a<span class="n">sig</span> <span class="nb">oscil</span> <span class="mf">0.6</span><span class="p">,</span> i<span class="n">cps</span><span class="p">,</span> <span class="mi">2</span> <span class="nb">outs</span> a<span class="n">sig</span><span class="p">,</span> a<span class="n">sig</span> <span class="kd">endin</span> <span class="nt"></CsInstruments></span> <span class="nt"><CsScore></span> <span class="nb">f</span> <span class="mi">0</span> <span class="mi">20</span> <span class="c1">;sine wave.</span> <span class="nb">f</span> <span class="mi">2</span> <span class="mi">0</span> <span class="mi">16384</span> <span class="mi">10</span> <span class="mi">1</span> <span class="nb">e</span> <span class="nt"></CsScore></span> <span class="nt"></CsoundSynthesizer></span> </pre> </div> </div> </div> <p><br class="example-break" /> </p> </div> <div class="refsect1"> <a id="idm281472944331896"></a> <h2>See Also</h2> <p> <a class="link" href="cpsmidi.html" title="cpsmidi"><em class="citetitle">cpsmidi</em></a>, <a class="link" href="GEN02.html" title="GEN02"><em class="citetitle">GEN02</em></a> </p> </div> <div class="refsect1"> <a id="idm281472944328824"></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="cpspch.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="cpstun.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">cpspch </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> cpstun</td> </tr> </table> </div> </body> </html>