| 1 | |
| 2 | <refentry id="duserrnd"> |
| 3 | <indexterm id="IndexDuserrnd"><primary>duserrnd</primary></indexterm> |
| 4 | <refentryinfo><title>Signal Generators:Random (Noise) Generators</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>duserrnd</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | |
| 10 | |
| 11 | <refnamediv> |
| 12 | <refname>duserrnd</refname> |
| 13 | <refpurpose> |
| 14 | Discrete USER-defined-distribution RaNDom generator. |
| 15 | </refpurpose> |
| 16 | </refnamediv> |
| 17 | |
| 18 | <refsect1> |
| 19 | <title>Description</title> |
| 20 | <para> |
| 21 | Discrete USER-defined-distribution RaNDom generator. |
| 22 | </para> |
| 23 | </refsect1> |
| 24 | |
| 25 | <refsect1> |
| 26 | <title>Syntax</title> |
| 27 | <synopsis>aout <command>duserrnd</command> ktableNum</synopsis> |
| 28 | |
| 29 | <synopsis>iout <command>duserrnd</command> itableNum</synopsis> |
| 30 | |
| 31 | <synopsis>kout <command>duserrnd</command> ktableNum</synopsis> |
| 32 | </refsect1> |
| 33 | |
| 34 | <refsect1> |
| 35 | <title>Initialization</title> |
| 36 | <para> |
| 37 | <emphasis>itableNum</emphasis> -- number of table containing the random-distribution function. Such table is generated by the user. See <link linkend="GEN40">GEN40</link>, <link linkend="GEN41">GEN41</link>, and <link linkend="GEN42">GEN42</link>. The table length does not need to be a power of 2 |
| 38 | </para> |
| 39 | </refsect1> |
| 40 | |
| 41 | <refsect1> |
| 42 | <title>Performance</title> |
| 43 | <para> |
| 44 | <emphasis>ktableNum</emphasis> -- number of table containing the random-distribution function. Such table is generated by the user. See <link linkend="GEN40">GEN40</link>, <link linkend="GEN41">GEN41</link>, and <link linkend="GEN42">GEN42</link>. The table length does not need to be a power of 2 |
| 45 | </para> |
| 46 | |
| 47 | <para> |
| 48 | <emphasis>duserrnd</emphasis> (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 <link linkend="GEN41">GEN41</link>. 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 <link linkend="GEN41">GEN41</link> for more details). |
| 49 | </para> |
| 50 | |
| 51 | <para> |
| 52 | 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. <emphasis>duserrnd</emphasis> is designed be used in algorithmic music generation. |
| 53 | </para> |
| 54 | |
| 55 | <para> |
| 56 | <emphasis>duserrnd</emphasis> can also be used to generate values following a set of ranges of probabilities by using distribution functions generated by GEN42 (See <link linkend="GEN42">GEN42</link> for more details). In this case, in order to simulate continuous ranges, the length of table XtableNum should be reasonably big, as <emphasis>duserrnd</emphasis> does not interpolate between table elements. |
| 57 | </para> |
| 58 | |
| 59 | <para> |
| 60 | For a tutorial about random distribution histograms and functions see: |
| 61 | |
| 62 | <itemizedlist> |
| 63 | <listitem> |
| 64 | <para> |
| 65 | D. Lorrain. "A panoply of stochastic cannons". In C. Roads, ed. 1989. Music machine. Cambridge, Massachusetts: MIT press, pp. 351 - 379. |
| 66 | </para> |
| 67 | </listitem> |
| 68 | </itemizedlist> |
| 69 | </para> |
| 70 | </refsect1> |
| 71 | |
| 72 | <refsect1> |
| 73 | <title>Examples</title> |
| 74 | <para> |
| 75 | Here is an example of the duserrnd opcode. It uses the file <ulink url="examples/duserrnd.csd"><citetitle>duserrnd.csd</citetitle></ulink>. |
| 76 | <example> |
| 77 | <title>Example of the duserrnd opcode.</title> |
| 78 | <para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para> |
| 79 | <xi:include href="examples-xml/duserrnd.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 80 | </example> |
| 81 | Its output should include lines like these: |
| 82 | <screen> |
| 83 | i 1 time 0.00067: 8.00000 |
| 84 | i 1 time 0.00133: 8.00000 |
| 85 | i 1 time 0.00200: 8.00000 |
| 86 | i 1 time 0.00267: 8.00000 |
| 87 | i 1 time 0.00333: 2.00000 |
| 88 | i 1 time 0.00400: 8.00000 |
| 89 | i 1 time 0.00533: 8.00000 |
| 90 | i 1 time 0.00600: 8.00000 |
| 91 | .......... |
| 92 | </screen> |
| 93 | </para> |
| 94 | </refsect1> |
| 95 | |
| 96 | <refsect1> |
| 97 | <title>See also</title> |
| 98 | <para><link linkend="SiggenNoise"><citetitle>Random (Noise) Generators</citetitle></link></para> |
| 99 | </refsect1> |
| 100 | |
| 101 | <refsect1> |
| 102 | <title>Credits</title> |
| 103 | <para>Author: &namegabriel;</para> |
| 104 | <para>New in Version 4.16</para> |
| 105 | </refsect1> |
| 106 | </refentry> |