Sophie

Sophie

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

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>duserrnd</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="dumpk4.html" title="dumpk4" />
    <link rel="next" href="dust.html" title="dust" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">duserrnd</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="dumpk4.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="dust.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="duserrnd">
      <a id="duserrnd"></a>
      <div class="titlepage"></div>
      <a id="IndexDuserrnd" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">duserrnd</span>
        </h2>
        <p>duserrnd — 
      Discrete USER-defined-distribution RaNDom generator.
          </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="idp18942808"></a>
        <h2>Description</h2>
        <p>
      Discrete USER-defined-distribution RaNDom generator.
    </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="idp18943472"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">aout <span class="command"><strong>duserrnd</strong></span> ktableNum</pre>
        <pre class="synopsis">iout <span class="command"><strong>duserrnd</strong></span> itableNum</pre>
        <pre class="synopsis">kout <span class="command"><strong>duserrnd</strong></span> ktableNum</pre>
      </div>
      <div class="refsect1" title="Initialization">
        <a id="idp18997608"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>itableNum</em></span> -- number of table containing the random-distribution function.  Such table is generated by the user. See <a class="link" href="GEN40.html" title="GEN40">GEN40</a>, <a class="link" href="GEN41.html" title="GEN41">GEN41</a>, and <a class="link" href="GEN42.html" title="GEN42">GEN42</a>. The table length does not need to be a power of 2
    </p>
      </div>
      <div class="refsect1" title="Performance">
        <a id="idp18999808"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>ktableNum</em></span> -- number of table containing the random-distribution function.  Such table is generated by the user. See <a class="link" href="GEN40.html" title="GEN40">GEN40</a>, <a class="link" href="GEN41.html" title="GEN41">GEN41</a>, and <a class="link" href="GEN42.html" title="GEN42">GEN42</a>. The table length does not need to be a power of 2
    </p>
        <p>
      <span class="emphasis"><em>duserrnd</em></span> (discrete user-defined-distribution random generator) generates random values according to a discrete random distribution created by the user. The user can create the discrete distribution histogram by using <a class="link" href="GEN41.html" title="GEN41">GEN41</a>. In order to create that table, the user has to define an arbitrary amount of number pairs, the first number of each pair representing a value and the second representing its probability (see <a class="link" href="GEN41.html" title="GEN41">GEN41</a> for more details).  
    </p>
        <p>
      When used  as a function, the rate of generation depends by the rate type of input variable XtableNum. In this case it can be embedded into any formula. Table number can be varied at k-rate, allowing to change the distribution histogram during the performance of a single note. <span class="emphasis"><em>duserrnd</em></span> is designed be used in algorithmic music generation.
    </p>
        <p>
      <span class="emphasis"><em>duserrnd</em></span> can also be used to generate values following a set of ranges of probabilities by using distribution functions generated by GEN42 (See <a class="link" href="GEN42.html" title="GEN42">GEN42</a> for more details). In this case, in order to simulate continuous ranges, the length of table XtableNum should be reasonably big, as <span class="emphasis"><em>duserrnd</em></span> does not interpolate between table elements.
    </p>
        <p>
      For a tutorial about random distribution histograms and functions see:

      </p>
        <div class="itemizedlist">
          <ul class="itemizedlist" type="disc">
            <li class="listitem">
              <p>
            D. Lorrain. "A panoply of stochastic cannons". In C. Roads, ed. 1989. Music machine. Cambridge, Massachusetts: MIT press, pp. 351 - 379.
          </p>
            </li>
          </ul>
        </div>
        <p>
    </p>
      </div>
      <div class="refsect1" title="Examples">
        <a id="idp19006792"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the duserrnd opcode. It uses the file <a class="ulink" href="examples/duserrnd.csd" target="_top"><em class="citetitle">duserrnd.csd</em></a>.
            </p>
        <div class="example">
          <a id="idp19007784"></a>
          <p class="title">
            <strong>Example 198. Example of the duserrnd 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 RT audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o duserrnd.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

<span class="oblock">instr</span> 1

k1   <span class="opc">duserrnd</span> 1
     <span class="opc">printk</span> 0, k1
asig <span class="opc">poscil</span> .5, 220<span class="op">*</span>k1, 2	<span class="comment">;multiply frequency with random value</span>
     <span class="opc">outs</span> asig, asig

<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">f</span>1 0 -20 -41  2 .1 8 .9	<span class="comment">;choose 2 at 10% probability, and 8 at 90%</span>

<span class="stamnt">f</span>2 0 8192 10 1

<span class="stamnt">i</span>1 0 2
<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 lines like these:
      </p>
        <pre class="screen">
i   1 time     0.00067:     8.00000
i   1 time     0.00133:     8.00000
i   1 time     0.00200:     8.00000
i   1 time     0.00267:     8.00000
i   1 time     0.00333:     2.00000
i   1 time     0.00400:     8.00000
i   1 time     0.00533:     8.00000
i   1 time     0.00600:     8.00000
..........
      </pre>
        <p>
    </p>
      </div>
      <div class="refsect1" title="See Also">
        <a id="idp19010760"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="cuserrnd.html" title="cuserrnd"><em class="citetitle">cuserrnd</em></a>,
      <a class="link" href="urd.html" title="urd"><em class="citetitle">urd</em></a>
    </p>
      </div>
      <div class="refsect1" title="Credits">
        <a id="idp19012264"></a>
        <h2>Credits</h2>
        <p>Author: Gabriel Maldonado</p>
        <p>New in Version 4.16</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="dumpk4.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="dust.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">dumpk4 </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> dust</td>
        </tr>
      </table>
    </div>
  </body>
</html>