<?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" /> <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="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" title="cpstmid"> <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" title="Description"> <a id="idp16938712"></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" title="Syntax"> <a id="idp16939920"></a> <h2>Syntax</h2> <pre class="synopsis">icps <span class="command"><strong>cpstmid</strong></span> ifn</pre> </div> <div class="refsect1" title="Initialization"> <a id="idp16996104"></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" title="Performance"> <a id="idp16997864"></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" title="Examples"> <a id="idp17005848"></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="idp17006832"></a> <p class="title"> <strong>Example 136. 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> <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> -odac -M0 <span class="comment">;;;RT audio I/O with MIDI in</span> <span class="comment">;-iadc ;;;uncomment -iadc if RT audio input is needed too</span> <span class="comment">; For Non-realtime ouput leave only the line below:</span> <span class="comment">; -o cpstmid.wav -W ;;; for file output any platform</span> <span class="csdtag"></CsOptions></span> <span class="csdtag"><CsInstruments></span> <span class="comment">; after an example from Kevin Conder</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="comment">; Table #1, a normal 12-tone equal temperament scale.</span> <span class="comment">; numgrades = 12 (twelve tones)</span> <span class="comment">; interval = 2 (one octave)</span> <span class="comment">; basefreq = 261.659 (Middle C)</span> <span class="comment">; basekeymidi = 60 (Middle C)</span> gitemp <span class="ohdr">ftgen</span> 1, 0, 64, <span class="op">-</span>2, 12, 2, 261.659, 60, 1.00, \ 1.059, 1.122, 1.189, 1.260, 1.335, 1.414, \ 1.498, 1.588, 1.682, 1.782, 1.888, 2.000 <span class="oblock">instr</span> 1 ifn <span class="op">=</span> 1 icps <span class="opc">cpstmid</span> ifn <span class="opc">print</span> icps asig <span class="opc">oscil</span> 0.6, icps, 2 <span class="opc">outs</span> asig, asig <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="stamnt">f</span> 0 20 <span class="comment">;sine wave.</span> <span class="stamnt">f</span> 2 0 16384 10 1 <span class="stamnt">e</span> <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="idp17009144"></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" title="Credits"> <a id="idp17010680"></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>