Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-release > by-pkgid > b707d9a4ee443103660a75ccb6e51334 > files > 2254

csound-doc-5.19.01-10.mga5.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>octcps</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="octave.html" title="octave" />
    <link rel="next" href="octmidi.html" title="octmidi" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">octcps</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="octave.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="octmidi.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="octcps">
      <a id="octcps"></a>
      <div class="titlepage"></div>
      <a id="IndexOctcps" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">octcps</span>
        </h2>
        <p>octcps — 
      Converts a cycles-per-second value to octave-point-decimal.
    </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="idp33223448"></a>
        <h2>Description</h2>
        <p>
      Converts a cycles-per-second value to octave-point-decimal.
    </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="idp33262968"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>octcps</strong></span> (cps)  (init- or control-rate args only)</pre>
        <p>
      where the argument within the parentheses may be a further expression.
    </p>
      </div>
      <div class="refsect1" title="Performance">
        <a id="idp33264296"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>octcps</em></span> and its related opcodes are really <span class="emphasis"><em>value converters</em></span> with a special function of manipulating pitch data.
    </p>
        <p>
      Data concerning pitch and frequency can exist in any of the following forms:
    </p>
        <div class="table">
          <a id="idp33265648"></a>
          <p class="title">
            <strong>Table 17. Pitch and Frequency Values</strong>
          </p>
          <div class="table-contents">
            <table summary="Pitch and Frequency Values" border="0">
              <colgroup>
                <col />
                <col />
              </colgroup>
              <thead>
                <tr>
                  <th>Name</th>
                  <th>Abbreviation</th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td>octave point pitch-class (8ve.pc)</td>
                  <td>pch</td>
                </tr>
                <tr>
                  <td>octave point decimal</td>
                  <td>oct</td>
                </tr>
                <tr>
                  <td>cycles per second</td>
                  <td>cps</td>
                </tr>
                <tr>
                  <td>Midi note number (0-127)</td>
                  <td>midinn</td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>
        <br class="table-break" />
        <p>
      The first two forms consist of a whole number, representing octave registration, followed by a specially interpreted fractional part. For <span class="emphasis"><em>pch</em></span>, the fraction is read as two decimal digits representing the 12 equal-tempered pitch classes from .00 for C to .11 for B. For <span class="emphasis"><em>oct</em></span>, the fraction is interpreted as a true decimal fractional part of an octave. The two fractional forms are thus related by the factor 100/12. In both forms, the fraction is preceded by a whole number octave index such that 8.00 represents Middle C, 9.00 the C above, etc. Midi note number values range between 0 and 127 (inclusively) with 60 representing Middle C, and are usually whole numbers. Thus A440 can be represented alternatively by 440 (<span class="emphasis"><em>cps</em></span>), 69 (<span class="emphasis"><em>midinn</em></span>), 8.09 (<span class="emphasis"><em>pch</em></span>), or 8.75 (<span class="emphasis"><em>oct</em></span>). Microtonal divisions of the <span class="emphasis"><em>pch</em></span> semitone can be encoded by using more than two decimal places.
    </p>
        <p>
      The mnemonics of the pitch conversion units are derived from morphemes of the forms involved, the second morpheme describing the source and the first morpheme the object (result). Thus <span class="emphasis"><em>cpspch</em></span>(8.09) will convert the pitch argument 8.09 to its <span class="emphasis"><em>cps</em></span> (or Hertz) equivalent, giving the value of 440. Since the argument is constant over the duration of the note, this conversion will take place at i-time, before any samples for the current note are produced. 
    </p>
        <p>
      By contrast, the conversion <span class="emphasis"><em>cpsoct</em></span>(8.75 + k1) which gives the value of A440 transposed by the octave interval <span class="emphasis"><em>k1</em></span>. The calculation will be repeated every k-period since that is the rate at which <span class="emphasis"><em>k1</em></span> varies.
    </p>
        <div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;">
          <table border="0" summary="Note: Note">
            <tr>
              <td rowspan="2" align="center" valign="top" width="25">
                <img alt="[Note]" src="images/note.png" />
              </td>
              <th align="left">Note</th>
            </tr>
            <tr>
              <td align="left" valign="top">
                <p>
        The conversion from <span class="emphasis"><em>pch</em></span>, <span class="emphasis"><em>oct</em></span>, or <span class="emphasis"><em>midinn</em></span> into <span class="emphasis"><em>cps</em></span> is not a linear operation but involves an exponential process that could be time-consuming when executed repeatedly. Csound now uses a built-in table lookup to do this efficiently, even at audio rates. Because the table index is truncated without interpolation, pitch resolution when using one of these opcodes is limited to 8192 discrete and equal divisions of the octave, and some pitches of the standard 12-tone equally-tempered scale are very slightly mistuned (by at most 0.15 cents).
      </p>
              </td>
            </tr>
          </table>
        </div>
      </div>
      <div class="refsect1" title="Examples">
        <a id="idp33276664"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the octcps opcode. It uses the file <a class="ulink" href="examples/octcps.csd" target="_top"><em class="citetitle">octcps.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp33277632"></a>
          <p class="title">
            <strong>Example 519. Example of the octcps 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">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
<span class="comment">; Audio out   Audio in</span>
-odac           -iadc    <span class="comment">;;;RT audio I/O</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o octcps.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="comment">; Initialize the global variables.</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> 1

<span class="comment">; Instrument #1.</span>
<span class="oblock">instr</span> 1
  <span class="comment">; Convert a cycles-per-second value into an </span>
  <span class="comment">; octave value.</span>
  icps <span class="op">=</span> 440
  ioct <span class="op">=</span> <span class="opc">octcps</span>(icps)

  <span class="opc">print</span> ioct
<span class="oblock">endin</span>


<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="comment">; Play Instrument #1 for one second.</span>
<span class="stamnt">i</span> 1 0 1
<span class="stamnt">e</span>


<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />

      Its output should include a line like this:
      </p>
        <pre class="screen">instr 1:  ioct = 8.750</pre>
        <p>
    </p>
      </div>
      <div class="refsect1" title="See Also">
        <a id="idp33280312"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="cpsoct.html" title="cpsoct"><em class="citetitle">cpsoct</em></a>,
      <a class="link" href="cpspch.html" title="cpspch"><em class="citetitle">cpspch</em></a>,
      <a class="link" href="octpch.html" title="octpch"><em class="citetitle">octpch</em></a>,
      <a class="link" href="pchoct.html" title="pchoct"><em class="citetitle">pchoct</em></a>,
      <a class="link" href="cpsmidinn.html" title="cpsmidinn"><em class="citetitle">cpsmidinn</em></a>,
      <a class="link" href="octmidinn.html" title="octmidinn"><em class="citetitle">octmidinn</em></a>,
      <a class="link" href="pchmidinn.html" title="pchmidinn"><em class="citetitle">pchmidinn</em></a>
    </p>
      </div>
      <div class="refsect1" title="Credits">
        <a id="idp33284232"></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="octave.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="octmidi.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">octave </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> octmidi</td>
        </tr>
      </table>
    </div>
  </body>
</html>