Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-release > by-pkgid > 5fcfcb7517038d1f44ab4e478e6e61fa > files > 493

csound-doc-6.10.0-1.mga7.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>cpstun</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="cpstmid.html" title="cpstmid" />
    <link rel="next" href="cpstuni.html" title="cpstuni" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">cpstun</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="cpstmid.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="cpstuni.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="cpstun"></a>
      <div class="titlepage"></div>
      <a id="IndexCpstun" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">cpstun</span>
        </h2>
        <p>cpstun — 
      Returns micro-tuning values at k-rate.
    </p>
      </div>
      <div class="refsect1">
        <a id="idm281472944280712"></a>
        <h2>Description</h2>
        <p>
      Returns micro-tuning values at k-rate.
    </p>
      </div>
      <div class="refsect1">
        <a id="idm281472944279384"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">kcps <span class="command"><strong>cpstun</strong></span> ktrig, kindex, kfn</pre>
      </div>
      <div class="refsect1">
        <a id="idm281472944277144"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>kcps</em></span> -- Return value in cycles per second.
    </p>
        <p>
      <span class="emphasis"><em>ktrig</em></span> -- A trigger signal used to trigger the evaluation.
    </p>
        <p>
      <span class="emphasis"><em>kindex</em></span> -- An integer number denoting an index of scale.
    </p>
        <p>
      <span class="emphasis"><em>kfn</em></span> --  Function table containing the parameters (numgrades, interval, basefreq, basekeymidi) and the tuning ratios.
    </p>
        <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>cpstun</em></span> works at k-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>
      <span class="emphasis"><em>kindex</em></span> arguments should be filled with integer numbers expressing the grade of given scale to be converted in cps. In <span class="emphasis"><em>cpstun</em></span>, a new value is evaluated only when <span class="emphasis"><em>ktrig</em></span> contains a non-zero value.  The function table <span class="emphasis"><em>kfn</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="idm281472944255288"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the cpstun opcode. It uses the file <a class="ulink" href="examples/cpstun.csd" target="_top"><em class="citetitle">cpstun.csd</em></a>.

      </p>
        <div class="example">
          <a id="idm281472944253432"></a>
          <p class="title">
            <strong>Example 165. Example of the cpstun 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="idm281472777356376"></a>
              <pre class="programlisting">
<span class="nt">&lt;CsoundSynthesizer&gt;</span>
<span class="nt">&lt;CsOptions&gt;</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 cpstun.wav -W ;;; for file output any platform</span>
<span class="nt">&lt;/CsOptions&gt;</span>
<span class="nt">&lt;CsInstruments&gt;</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">; Set the trigger.</span>
  k<span class="n">trig</span> <span class="nb">init</span> <span class="mi">1</span>

  <span class="c1">; Use Table #1.</span>
  k<span class="n">fn</span> <span class="nb">init</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>
  k<span class="n">index</span> <span class="nb">init</span> <span class="mi">69</span>

  k<span class="n">1</span> <span class="nb">cpstun</span> k<span class="n">trig</span><span class="p">,</span> k<span class="n">index</span><span class="p">,</span> k<span class="n">fn</span>

  <span class="nb">printk2</span> k<span class="n">1</span>
<span class="kd">endin</span>


<span class="nt">&lt;/CsInstruments&gt;</span>
<span class="nt">&lt;CsScore&gt;</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">&lt;/CsScore&gt;</span>
<span class="nt">&lt;/CsoundSynthesizer&gt;</span>
</pre>
            </div>
          </div>
        </div>
        <p><br class="example-break" />

      Its output should include lines like this:
      </p>
        <pre class="screen">i1   440.11044</pre>
        <p>
    </p>
      </div>
      <div class="refsect1">
        <a id="idm281472944248376"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="cpstmid.html" title="cpstmid"><em class="citetitle">cpstmid</em></a>,
      <a class="link" href="cpstuni.html" title="cpstuni"><em class="citetitle">cpstuni</em></a>,
      <a class="link" href="GEN02.html" title="GEN02"><em class="citetitle">GEN02</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idm281472944244312"></a>
        <h2>Credits</h2>
        <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="cpstmid.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="cpstuni.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">cpstmid </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> cpstuni</td>
        </tr>
      </table>
    </div>
  </body>
</html>