Sophie

Sophie

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

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>readk4</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="readk3.html" title="readk3" />
    <link rel="next" href="reinit.html" title="reinit" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">readk4</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="readk3.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="reinit.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="readk4">
      <a id="readk4"></a>
      <div class="titlepage"></div>
      <a id="IndexReadk4" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">readk4</span>
        </h2>
        <p>readk4 — 
      Periodically reads four orchestra control-signal values from an external file.
    </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="idp40277568"></a>
        <h2>Description</h2>
        <p>
      Periodically reads four orchestra control-signal values from an external file.
    </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="idp40278256"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">kr1, kr2, kr3, kr4 <span class="command"><strong>readk4</strong></span> ifilname, iformat, iprd</pre>
      </div>
      <div class="refsect1" title="Initialization">
        <a id="idp40281696"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>ifilname</em></span> -- an integer N denoting a file named "readk.N" or a character string (in double quotes, spaces permitted) denoting the external file name. For a string, it may either be a full path name with directory specified or a simple filename.  In the later case, the file is sought first in the current directory, then in <a class="link" href="CommandEnvironment.html" title="Csound Environment Variables"><em class="citetitle">SSDIR</em></a>, and finally in <a class="link" href="CommandEnvironment.html" title="Csound Environment Variables"><em class="citetitle">SFDIR</em></a>.
    </p>
        <p>
      <span class="emphasis"><em>iformat</em></span> -- specifies the input data format:
      </p>
        <div class="itemizedlist">
          <ul class="itemizedlist" type="disc">
            <li class="listitem">
              <p>1 = 8-bit signed integers (char)</p>
            </li>
            <li class="listitem">
              <p>4 = 16-bit short integers</p>
            </li>
            <li class="listitem">
              <p>5 = 32-bit long integers</p>
            </li>
            <li class="listitem">
              <p>6 = 32-bit floats</p>
            </li>
            <li class="listitem">
              <p>7 = ASCII long integers (plain text)</p>
            </li>
            <li class="listitem">
              <p>8 = ASCII floats (plain text)</p>
            </li>
          </ul>
        </div>
        <p>
    </p>
        <p>
      Note that A-law and U-law formats are not available, and that all formats except the last two are binary. The input file should be a "raw", headerless data file.
    </p>
        <p>
      <span class="emphasis"><em>iprd</em></span> -- the rate (period) in seconds, rounded to the nearest orchestra control period, at which the signals are read from the input file.  A value of 0 implies one control period (the enforced minimum), which will read new values at the orchestra control rate.  Longer periods will cause the same values to repeat for more than one control period.
      
    </p>
      </div>
      <div class="refsect1" title="Performance">
        <a id="idp40341176"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>kr1, kr2, kr3, kr4</em></span> -- output of the signals read from <span class="emphasis"><em>ifilname</em></span>.
    </p>
        <p>
      This opcode allows four generated control signal values to be read from a named external file. The file should contain no header information but it should contain a regularly sampled time series of control values. For binary formats, the individual samples of each signal are interleaved. For ASCII text formats, the values are assumed to be separated by at least one whitespace character.  The four "channels" in a sample frame may be on the same line or separated by newline characters, it does not matter. There may be any number of <span class="emphasis"><em>readk4</em></span> opcodes in an instrument or orchestra and they may read from the same or different files.
    </p>
      </div>
      <div class="refsect1" title="Examples">
        <a id="idp40343608"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the readk4 opcode. It uses the file <a class="ulink" href="examples/readk4.csd" target="_top"><em class="citetitle">readk4.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp40344560"></a>
          <p class="title">
            <strong>Example 710. Example of the readk4 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>
-odac      <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o readk4.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</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

giSine <span class="ohdr">ftgen</span> 0, 0, 2^10, 10, 1

<span class="oblock">instr</span> 1 <span class="comment">;writes four control signals to a file</span>
kcf       <span class="opc">randh</span>     950, 1, 2, 1, 1050 <span class="comment">;generates one random number between 100 and 2000 per second</span>
kq        <span class="opc">randh</span>     10, 1, 2, 1, 11 <span class="comment">;generates another random number between 1 and 21 per second</span>
kdb       <span class="opc">randh</span>     9, 1, 2, 1, <span class="op">-</span>15 <span class="comment">;amplitudes in dB between -24 and -6</span>
kpan      <span class="opc">randh</span>     .5, 1, 2, 1, .5 <span class="comment">;panning between 0 and 1</span>
          <span class="opc">dumpk4</span>    kcf, kq, kdb, kpan, "dumpk4.txt", 8, 1 <span class="comment">;writes the control signals</span>
          <span class="opc">prints</span>    "WRITING<span class="op">:</span>\n"
          <span class="opc">printks</span>   "kcf <span class="op">=</span> <span class="op">%</span>f, kq <span class="op">=</span> <span class="op">%</span>f, kdb <span class="op">=</span> <span class="op">%</span>f, kpan <span class="op">=</span> <span class="op">%</span>f\n", 1, kcf, kq, kdb, kpan  <span class="comment">;prints them</span>
<span class="oblock">endin</span>

<span class="oblock">instr</span> 2 <span class="comment">;reads the file written by instr 1</span>
kcf,kq,kdb,kp <span class="opc">readk4</span> "dumpk4.txt", 8, 1
          <span class="opc">prints</span>    "READING<span class="op">:</span>\n"
          <span class="opc">printks</span>   "kcf <span class="op">=</span> <span class="op">%</span>f, kq <span class="op">=</span> <span class="op">%</span>f, kdb <span class="op">=</span> <span class="op">%</span>f, kpan <span class="op">=</span> <span class="op">%</span>f\n", 1, kcf, kq, kdb, kp  <span class="comment">;prints values</span>
kdb       <span class="opc">lineto</span>    kdb, .1 <span class="comment">;smoothing amp transition</span>
kp        <span class="opc">lineto</span>    kp, .1 <span class="comment">;smoothing pan transition</span>
anoise    <span class="opc">rand</span>      <span class="opc">ampdb</span>(kdb), 2, 1
kbw       <span class="op">=</span>         kcf<span class="op">/</span>kq <span class="comment">;bandwidth of resonant filter</span>
abp       <span class="opc">reson</span>     anoise, kcf, kbw
aout      <span class="opc">balance</span>   abp, anoise
aL, aR    <span class="opc">pan2</span>      aout, kp
          <span class="opc">outs</span>      aL, aR
<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 5
<span class="stamnt">i</span> 2 5 5
<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" />

      The output should include lines like these:
      </p>
        <pre class="screen">
WRITING:
kcf = 1122.469723, kq = 11.762839, kdb = -14.313445, kpan = 0.538142
kcf = 1122.469723, kq = 11.762839, kdb = -14.313445, kpan = 0.538142
kcf = 1148.638412, kq = 12.040490, kdb = -14.061868, kpan = 0.552205
kcf = 165.796855, kq = 18.523179, kdb = -15.816977, kpan = 0.901528
kcf = 147.729960, kq = 13.071911, kdb = -11.924531, kpan = 0.982518
kcf = 497.430113, kq = 13.605512, kdb = -21.586611, kpan = 0.179229

READING:
WARNING: Seeding from current time 3308160476

kcf = 1122.469700, kq = 11.762800, kdb = -14.313400, kpan = 0.538100
kcf = 1122.469700, kq = 11.762800, kdb = -14.313400, kpan = 0.538100
kcf = 1148.638400, kq = 12.040500, kdb = -14.061900, kpan = 0.552200
kcf = 165.796900, kq = 18.523200, kdb = -15.817000, kpan = 0.901500
kcf = 147.730000, kq = 13.071900, kdb = -11.924500, kpan = 0.982500
kcf = 497.430100, kq = 13.605500, kdb = -21.586600, kpan = 0.179200
      </pre>
        <p>
    </p>
      </div>
      <div class="refsect1" title="See Also">
        <a id="idp40348112"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="dumpk.html" title="dumpk"><em class="citetitle">dumpk</em></a>,
      <a class="link" href="dumpk2.html" title="dumpk2"><em class="citetitle">dumpk2</em></a>,
      <a class="link" href="dumpk3.html" title="dumpk3"><em class="citetitle">dumpk3</em></a>,
      <a class="link" href="dumpk4.html" title="dumpk4"><em class="citetitle">dumpk4</em></a>,
      <a class="link" href="readk.html" title="readk"><em class="citetitle">readk</em></a>,
      <a class="link" href="readk2.html" title="readk2"><em class="citetitle">readk2</em></a>,
      <a class="link" href="readk3.html" title="readk3"><em class="citetitle">readk3</em></a>
    </p>
      </div>
      <div class="refsect1" title="Credits">
        <a id="idp40352032"></a>
        <h2>Credits</h2>
        <p>By: John ffitch and Barry Vercoe</p>
        <p>1999 or earlier</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="readk3.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="reinit.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">readk3 </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> reinit</td>
        </tr>
      </table>
    </div>
  </body>
</html>