Sophie

Sophie

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

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>GEN42</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="ScoregensTop.html" title="Score Statements and GEN Routines" />
    <link rel="prev" href="GEN41.html" title="GEN41" />
    <link rel="next" href="GEN43.html" title="GEN43" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">GEN42</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="GEN41.html">Prev</a> </td>
          <th width="60%" align="center">Score Statements and GEN Routines</th>
          <td width="20%" align="right"> <a accesskey="n" href="GEN43.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="GEN42">
      <a id="GEN42"></a>
      <div class="titlepage"></div>
      <a id="IndexGEN42" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">GEN42</span>
        </h2>
        <p>GEN42 — 
      Generates a random distribution of discrete ranges of values.
    </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="idp78356488"></a>
        <h2>Description</h2>
        <p>
      Generates a random distribution function of discrete ranges of values by giving a list of groups of three numbers.
    </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="idp78357216"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>f</strong></span> # time size -42  min1 max1 prob1 min2 max2 prob2 min3 max3 prob3 ...  minN maxN probN</pre>
      </div>
      <div class="refsect1" title="Performance">
        <a id="idp78413952"></a>
        <h2>Performance</h2>
        <p>
      The first number of each group is a the minimum value of the range, the second is the maximum value and the third is the probability of that an element belonging to that range of values can be chosen by a random algorithm. Probabilities for a range should be a fraction of 1, and the sum of the probabilities for all the ranges should total 1.0.
    </p>
        <p>
      This subroutine is designed to be used together with duserrnd and <a class="link" href="urd.html" title="urd"><em class="citetitle">urd</em></a> opcodes (see <a class="link" href="duserrnd.html" title="duserrnd">duserrnd</a> for more information). Since both duserrnd and urd do not use any interpolation, it is suggested to give a size reasonably big.
    </p>
      </div>
      <div class="refsect1" title="Examples">
        <a id="idp78416128"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the GEN42 opcode. It uses the file <a class="ulink" href="examples/gen42.csd" target="_top"><em class="citetitle">gen42.csd</em></a>.
            </p>
        <div class="example">
          <a id="idp78417104"></a>
          <p class="title">
            <strong>Example 1069. Example of the GEN42 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 GEN42.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 

ktab  <span class="op">=</span> 1			<span class="comment">;ftable 1</span>
kurd  <span class="op">=</span> <span class="opc">urd</span>(ktab) 
ktrig <span class="opc">metro</span> 5			<span class="comment">;triggers 5 times per second</span>
kres  <span class="opc">samphold</span> kurd, ktrig	<span class="comment">;sample and hold value of kurd</span>
      <span class="opc">printk2</span> kres		<span class="comment">;print it</span>
asig  <span class="opc">poscil</span> .5, 220<span class="op">+</span>kres, 2
      <span class="opc">outs</span> asig, asig
<span class="oblock">endin</span>

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

<span class="ohdr">seed</span> 0	<span class="comment">;every run new values</span>

ktab  <span class="op">=</span> 1 			<span class="comment">;ftable 1</span>
kurd  <span class="op">=</span> <span class="opc">urd</span>(ktab) 
ktrig <span class="opc">metro</span> 5			<span class="comment">;triggers 5 times per second</span>
kres  <span class="opc">samphold</span> kurd, ktrig	<span class="comment">;sample and hold value of kurd</span>
      <span class="opc">printk2</span> kres		<span class="comment">;print it</span>
asig  <span class="opc">poscil</span> .5, 220<span class="op">+</span>kres, 2
      <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 -42  10 20 .3 100 200 .7 <span class="comment">;30% choose between 10 and 20 and 70% between 100 and 200</span>
<span class="stamnt">f</span>2 0 8192 10 1			  <span class="comment">;sine wave</span>

<span class="stamnt">i</span> 1 0 5
<span class="stamnt">i</span> 2 6 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" />     
      Its output should include lines like these:
      </p>
        <pre class="screen">
 i1   184.61538
 i1   130.76923
 i1   169.23077
 i1    12.00000
.......

WARNING: Seeding from current time 3751086165

 i2   138.46154
 i2    12.00000
 i2   123.07692
 i2   161.53846
 i2   123.07692
 i2   153.84615
......
      </pre>
        <p>

        <span>This is the diagram of the waveform of the GEN42 routine, as used in the example:</span>
    </p>
        <p>
    </p>
        <p>
      </p>
        <div class="mediaobject">
          <img src="images/gen42.png" alt="f 1 0 -20 -42 10 20 .3 100 200 .7" />
          <div class="caption">
            <p>  f 1 0 -20 -42  10 20 .3 100 200 .7</p>
          </div>
        </div>
        <p>
    </p>
      </div>
      <div class="refsect1" title="Credits">
        <a id="idp78422304"></a>
        <h2>Credits</h2>
        <p>Author: Gabriel Maldonado</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="GEN41.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="ScoregensTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="GEN43.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">GEN41 </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> GEN43</td>
        </tr>
      </table>
    </div>
  </body>
</html>