Sophie

Sophie

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

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>octmidinn</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="octmidib.html" title="octmidib" />
    <link rel="next" href="octpch.html" title="octpch" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">octmidinn</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="octmidib.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="octpch.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="octmidinn">
      <a id="octmidinn"></a>
      <div class="titlepage"></div>
      <a id="IndexOctmidinn" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">octmidinn</span>
        </h2>
        <p>octmidinn — 
      Converts a Midi note number value to octave-point-decimal.
    </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="idp33341208"></a>
        <h2>Description</h2>
        <p>
      Converts a Midi note number value to octave-point-decimal.
    </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="idp33341880"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>octmidinn</strong></span> (MidiNoteNumber)  (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="idp33352568"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>octmidinn</em></span> is a function that takes an i-rate or k-rate value representing a Midi note number and returns the equivalent pitch value in Csound's octave-point-decimal format. This conversion assumes that Middle C (8.000 in <span class="emphasis"><em>oct</em></span>) is Midi note number 60. Midi note number values are typically integers in the range from 0 to 127 but fractional values or values outside of this range will be interpreted consistently.
    </p>
        <div class="note" title="octmidinn vs. octmidi" style="margin-left: 0.5in; margin-right: 0.5in;">
          <table border="0" summary="Note: octmidinn vs. octmidi">
            <tr>
              <td rowspan="2" align="center" valign="top" width="25">
                <img alt="[Note]" src="images/note.png" />
              </td>
              <th align="left">octmidinn vs. octmidi</th>
            </tr>
            <tr>
              <td align="left" valign="top">
                <p>
        The <span class="emphasis"><em>octmidinn</em></span> opcode may be used in any Csound instrument instance whether it is activated from a Midi event, score event, line event, or from another instrument.  The input value for <span class="emphasis"><em>octmidinn</em></span> might for example come from a p-field in a textual score or it may have been retrieved from the real-time Midi event that activated the current note using the <a class="link" href="notnum.html" title="notnum"><em class="citetitle">notnum</em></a> opcode.  You must specify an i-rate or k-rate expression for the Midi note number that is to be converted.  On the other hand, the <a class="link" href="octmidi.html" title="octmidi"><em class="citetitle">octmidi</em></a> opcode only produces meaningful results in a Midi-activated note (either real-time or from a Midi score with the -F flag).  With <a class="link" href="octmidi.html" title="octmidi"><em class="citetitle">octmidi</em></a>, the Midi note number value is taken from the Midi event associated with the instrument instance, and no location or expression for this value may be specified.
      </p>
              </td>
            </tr>
          </table>
        </div>
        <p>
      <span class="emphasis"><em>octmidinn</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="idp33395808"></a>
          <p class="title">
            <strong>Table 18. 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="idp33406824"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the octmidinn opcode. It uses the file <a class="ulink" href="examples/cpsmidinn.csd" target="_top"><em class="citetitle">cpsmidinn.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp33407816"></a>
          <p class="title">
            <strong>Example 522. Example of the octmidinn 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">; This example produces no audio, so we render in</span>
<span class="comment">; non-realtime and turn off sound to disk:</span>
-n
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="oblock">instr</span> 1
  <span class="comment">; i-time loop to print conversion table</span>
  imidiNN <span class="op">=</span>   0
  loop1<span class="op">:</span>
    icps  <span class="op">=</span> <span class="opc">cpsmidinn</span>(imidiNN)
    ioct  <span class="op">=</span> <span class="opc">octmidinn</span>(imidiNN)
    ipch  <span class="op">=</span> <span class="opc">pchmidinn</span>(imidiNN)
            
    <span class="opc">print</span>   imidiNN, icps, ioct, ipch
      
    imidiNN <span class="op">=</span> imidiNN <span class="op">+</span> 1
  <span class="octrl">if</span> (imidiNN <span class="op">&lt;</span> 128) <span class="octrl">igoto</span> loop1
<span class="oblock">endin</span>

<span class="oblock">instr</span> 2
  <span class="comment">; test k-rate converters</span>
  kMiddleC  <span class="op">=</span>   60
  kcps  <span class="op">=</span> <span class="opc">cpsmidinn</span>(kMiddleC)
  koct  <span class="op">=</span> <span class="opc">octmidinn</span>(kMiddleC)
  kpch  <span class="op">=</span> <span class="opc">pchmidinn</span>(kMiddleC)
            
  <span class="opc">printks</span> "<span class="op">%</span>d <span class="op">%</span>f <span class="op">%</span>f <span class="op">%</span>f\n", 1.0, kMiddleC, kcps, koct, kpch
<span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">i</span>1 0 0
<span class="stamnt">i</span>2 0 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" />
    </p>
      </div>
      <div class="refsect1" title="See Also">
        <a id="idp33410096"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="cpsmidinn.html" title="cpsmidinn"><em class="citetitle">cpsmidinn</em></a>,
      <a class="link" href="pchmidinn.html" title="pchmidinn"><em class="citetitle">pchmidinn</em></a>,
      <a class="link" href="octmidi.html" title="octmidi"><em class="citetitle">octmidi</em></a>,
      <a class="link" href="notnum.html" title="notnum"><em class="citetitle">notnum</em></a>,
      <a class="link" href="cpspch.html" title="cpspch"><em class="citetitle">cpspch</em></a>,
      <a class="link" href="cpsoct.html" title="cpsoct"><em class="citetitle">cpsoct</em></a>,
      <a class="link" href="octcps.html" title="octcps"><em class="citetitle">octcps</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>
    </p>
      </div>
      <div class="refsect1" title="Credits">
        <a id="idp33414952"></a>
        <h2>Credits</h2>
        <p>Derived from original value converters by Barry Vercoe.</p>
        <p>New in version 5.07</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="octmidib.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="octpch.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">octmidib </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> octpch</td>
        </tr>
      </table>
    </div>
  </body>
</html>