summaryrefslogtreecommitdiff
path: root/opcodes/cuserrnd.xml
blob: 847e0290fb902a21159f208cef85dda80156bb33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<refentry id="cuserrnd">
<indexterm id="IndexCuserrnd"><primary>cuserrnd</primary></indexterm>
  <refentryinfo><title>Signal Generators:Random (Noise) Generators</title></refentryinfo>
  <refmeta>
    <refentrytitle>cuserrnd</refentrytitle>
  </refmeta>



  <refnamediv>
    <refname>cuserrnd</refname>
    <refpurpose>
      Continuous USER-defined-distribution RaNDom generator.
          </refpurpose>
  </refnamediv>
  
  <refsect1>
    <title>Description</title>
    <para>
      Continuous USER-defined-distribution RaNDom generator.
    </para>
  </refsect1>

  <refsect1>
    <title>Syntax</title>
    <synopsis>aout <command>cuserrnd</command> kmin, kmax, ktableNum</synopsis>

    <synopsis>iout <command>cuserrnd</command> imin, imax, itableNum</synopsis>

    <synopsis>kout <command>cuserrnd</command> kmin, kmax, ktableNum</synopsis>
  </refsect1>

  <refsect1>
    <title>Initialization</title>
    <para>
      <emphasis>imin</emphasis> -- minimum range limit
    </para>

    <para>
      <emphasis>imax</emphasis> -- maximum range limit
    </para>

    <para>
      <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
    </para>
  </refsect1>

  <refsect1>
    <title>Performance</title>
    <para>
      <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
    </para>
    <para>
      <emphasis>kmin</emphasis> -- minimum range limit
    </para>

    <para>
      <emphasis>kmax</emphasis> -- maximum range limit
    </para>

    <para>
      <emphasis>cuserrnd</emphasis> (continuous user-defined-distribution random generator) generates random values according to a continuous random distribution created by the user. In this case the shape of the distribution histogram can be drawn or generated by any GEN routine. The table containing the shape of such histogram must then be translated to a distribution function by means of GEN40 (see <link linkend="GEN40">GEN40</link> for more details). Then such function must be assigned to the XtableNum argument of cuserrnd.  The output range can then be rescaled according to the Xmin and Xmax arguments. cuserrnd linearly interpolates between table elements, so it is not recommended for discrete distributions (<link linkend="GEN41">GEN41</link> and <link linkend="GEN42">GEN42</link>).
    </para>

    <para>
      For a tutorial about random distribution histograms and functions see:

      <itemizedlist>
        <listitem>
          <para>
            D. Lorrain. "A panoply of stochastic cannons". In C. Roads, ed. 1989. Music machine. Cambridge, Massachusetts: MIT press, pp. 351 - 379.
          </para>
        </listitem>
      </itemizedlist>
    </para>
  </refsect1>

    <refsect1>
    <title>Examples</title>
    <para>
      Here is an example of the cuserrnd opcode. It uses the file <ulink url="examples/cuserrnd.csd"><citetitle>cuserrnd.csd</citetitle></ulink>.
            <example>
        <title>Example of the cuserrnd opcode.</title>
        <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>
          <xi:include href="examples-xml/cuserrnd.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
      </example>     
      Its output should include lines like these:
      <screen>
 i   1 time     0.00067:    53.14918
 i   1 time     0.20067:     0.00000
 i   1 time     0.40067:     0.00000
 i   1 time     0.60067:    96.80406
 i   1 time     0.80067:    94.20729
 i   1 time     1.00000:     0.00000
 i   1 time     1.20067:    86.13032
 i   1 time     1.40067:    31.37096
 i   1 time     1.60067:    70.35889
 i   1 time     1.80000:     0.00000
 i   1 time     2.00000:    49.18914

WARNING: Seeding from current time 2006647442

 i   2 time     3.00067:    21.45002
 i   2 time     3.20067:    44.32333
 i   2 time     3.40067:    46.05420
 i   2 time     3.60000:     0.00000
 i   2 time     3.80067:    41.32175
 i   2 time     4.00000:     0.00000
 i   2 time     4.20000:    63.72019
 i   2 time     4.40067:     0.00000
 i   2 time     4.60067:     0.00000
 i   2 time     4.80067:     0.00000
 i   2 time     5.00000:    74.49330
      </screen>
    </para>
  </refsect1>

  <refsect1>
    <title>See Also</title>
    <para>
      <link linkend="duserrnd"><citetitle>duserrnd</citetitle></link>,
      <link linkend="urd"><citetitle>urd</citetitle></link>
    </para>
  </refsect1>

  <refsect1>
    <title>Credits</title>
    <para>Author: &namegabriel;</para>
    <para>New in Version 4.16</para>
  </refsect1>
</refentry>