<?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>cpstuni</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="cpstun.html" title="cpstun" /> <link rel="next" href="cpsxpch.html" title="cpsxpch" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">cpstuni</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="cpstun.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="cpsxpch.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry"> <a id="cpstuni"></a> <div class="titlepage"></div> <a id="IndexCpstuni" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">cpstuni</span> </h2> <p>cpstuni — Returns micro-tuning values at init-rate. </p> </div> <div class="refsect1"> <a id="idm281472944238216"></a> <h2>Description</h2> <p> Returns micro-tuning values at init-rate. </p> </div> <div class="refsect1"> <a id="idm281472944194456"></a> <h2>Syntax</h2> <pre class="synopsis">icps <span class="command"><strong>cpstuni</strong></span> index, ifn</pre> </div> <div class="refsect1"> <a id="idm281472944192216"></a> <h2>Initialization</h2> <p> <span class="emphasis"><em>icps</em></span> -- Return value in cycles per second. </p> <p> <span class="emphasis"><em>index</em></span> -- An integer number denoting an index of scale. </p> <p> <span class="emphasis"><em>ifn</em></span> -- Function table containing the parameters (numgrades, interval, basefreq, basekeymidi) and the tuning ratios. </p> </div> <div class="refsect1"> <a id="idm281472944188472"></a> <h2>Performance</h2> <p> These opcodes are similar to <a class="link" href="cpstmid.html" title="cpstmid"><em class="citetitle">cpstmid</em></a>, but work without necessity of MIDI. </p> <p> <span class="emphasis"><em>cpstuni</em></span> works at init-rate. It allows fully customized micro-tuning scales. It requires a function table number containing the tuning ratios, and some other parameters stored in the function table itself. </p> <p> The <span class="emphasis"><em>index</em></span> argument should be filled with integer numbers expressing the grade of given scale to be converted in cps. 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> and the first four values stored in this function are parameters that express: </p> <div class="itemizedlist"> <ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> <p>numgrades -- The number of grades of the micro-tuning scale.</p> </li> <li class="listitem"> <p>interval -- The frequency range covered before repeating the grade ratios, for example 2 for one octave, 1.5 for a fifth etcetera.</p> </li> <li class="listitem"> <p>basefreq -- The base frequency of the scale in cycles per second.</p> </li> <li class="listitem"> <p>basekey -- The integer index of the scale to which to assign basefreq unmodified.</p> </li> </ul> </div> <p> </p> <p> After these four values, the user can begin to insert the tuning ratios. For example, for a standard 12-grade scale with the base-frequency of 261 cps assigned to the key-number 60, the corresponding f-statement in the score to generate the table should be: </p> <div class="informalexample"> <pre class="programlisting"> <span class="comment">; numgrades basefreq tuning-ratios (eq.temp) .......</span> <span class="comment">; interval basekey</span> <span class="stamnt">f</span>1 0 64 -2 12 2 261 60 1 1.059463 1.12246 1.18920 ..etc...</pre> </div> <p> </p> <p> Another example with a 24-grade scale with a base frequency of 440 assigned to the key-number 48, and a repetition interval of 1.5: </p> <div class="informalexample"> <pre class="programlisting"> <span class="comment">; numgrades basefreq tuning-ratios .......</span> <span class="comment">; interval basekey</span> <span class="stamnt">f</span>1 0 64 -2 24 1.5 440 48 1 1.01 1.02 1.03 ..etc...</pre> </div> <p> </p> </div> <div class="refsect1"> <a id="idm281472944171464"></a> <h2>Examples</h2> <p> Here is an example of the cpstuni opcode. It uses the file <a class="ulink" href="examples/cpstuni.csd" target="_top"><em class="citetitle">cpstuni.csd</em></a>. </p> <div class="example"> <a id="idm281472944169608"></a> <p class="title"> <strong>Example 166. Example of the cpstuni 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="idm281472777282200"></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> <span class="c1">; Audio out Audio in</span> -odac -iadc <span class="c1">;;;RT audio I/O</span> <span class="c1">; For Non-realtime ouput leave only the line below:</span> <span class="c1">; -o cpstuni.wav -W ;;; for file output any platform</span> <span class="nt"></CsOptions></span> <span class="nt"><CsInstruments></span> <span class="c1">; Initialize the global variables.</span> <span class="vg">sr</span> <span class="o">=</span> <span class="mi">44100</span> <span class="vg">kr</span> <span class="o">=</span> <span class="mi">4410</span> <span class="vg">ksmps</span> <span class="o">=</span> <span class="mi">10</span> <span class="vg">nchnls</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="c1">; Instrument #1.</span> <span class="kd">instr</span> <span class="nf">1</span> <span class="c1">; Use Table #1.</span> i<span class="n">fn</span> <span class="o">=</span> <span class="mi">1</span> <span class="c1">; If the base key (note #60) is C, then 9 notes </span> <span class="c1">; above it (note #60 + 9 = note #69) should be A.</span> i<span class="n">ndex</span> <span class="o">=</span> <span class="mi">69</span> i<span class="n">1</span> <span class="nb">cpstuni</span> i<span class="n">ndex</span><span class="p">,</span> i<span class="n">fn</span> <span class="nb">print</span> i<span class="n">1</span> <span class="kd">endin</span> <span class="nt"></CsInstruments></span> <span class="nt"><CsScore></span> <span class="c1">; Play Instrument #1 for one second.</span> <span class="nb">i</span> <span class="mi">1</span> <span class="mi">0</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" /> Its output should include lines like this: </p> <pre class="screen">instr 1: i1 = 440.110</pre> <p> </p> </div> <div class="refsect1"> <a id="idm281472944164552"></a> <h2>See Also</h2> <p> <a class="link" href="cpstmid.html" title="cpstmid"><em class="citetitle">cpstmid</em></a>, <a class="link" href="cpstun.html" title="cpstun"><em class="citetitle">cpstun</em></a>, <a class="link" href="GEN02.html" title="GEN02"><em class="citetitle">GEN02</em></a> </p> </div> <div class="refsect1"> <a id="idm281472944160488"></a> <h2>Credits</h2> <p>Written by Gabriel Maldonado.</p> <p>Example written by Kevin Conder.</p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="cpstun.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="cpsxpch.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">cpstun </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> cpsxpch</td> </tr> </table> </div> </body> </html>