Debian Codegraph @

opcodes/rnd31.xml

raw symbols SCIP
1
2 <refentry id="rnd31">
3 <indexterm id="IndexRnd31"><primary>rnd31</primary></indexterm>
4 <refentryinfo><title>Signal Generators:Random (Noise) Generators</title></refentryinfo>
5 <refmeta>
6 <refentrytitle>rnd31</refentrytitle>
7 </refmeta>
8
9
10
11 <refnamediv>
12 <refname>rnd31</refname>
13 <refpurpose>
14 31-bit bipolar random opcodes with controllable distribution.
15 </refpurpose>
16 </refnamediv>
17
18 <refsect1>
19 <title>Description</title>
20 <para>
21 31-bit bipolar random opcodes with controllable distribution. These units are portable, i.e. using the same seed value will generate the same random sequence on all systems. The distribution of generated random numbers can be varied at k-rate.
22 </para>
23 </refsect1>
24
25 <refsect1>
26 <title>Syntax</title>
27 <synopsis>ax <command>rnd31</command> kscl, krpow [, iseed]</synopsis>
28
29 <synopsis>ix <command>rnd31</command> iscl, irpow [, iseed]</synopsis>
30
31 <synopsis>kx <command>rnd31</command> kscl, krpow [, iseed]</synopsis>
32 </refsect1>
33
34 <refsect1>
35 <title>Initialization</title>
36 <para>
37 <emphasis>ix</emphasis> -- i-rate output value.
38 </para>
39
40 <para>
41 <emphasis>iscl</emphasis> -- output scale. The generated random numbers are in the range -iscl to iscl.
42 </para>
43
44 <para>
45 <emphasis>irpow</emphasis> -- controls the distribution of random numbers. If irpow is positive, the random distribution (x is in the range -1 to 1) is <emphasis>abs(x) &circ; ((1 / irpow) - 1)</emphasis>; for negative irpow values, it is <emphasis>(1 - abs(x)) &circ; ((-1 / irpow) - 1)</emphasis>. Setting <emphasis>irpow</emphasis> to -1, 0, or 1 will result in uniform distribution (this is also faster to calculate).
46 </para>
47
48 <para>
49 <mediaobject>
50 <imageobject>
51 <imagedata fileref="images/rnd31_rand.png" format="PNG"/>
52 </imageobject>
53
54 <textobject>
55 <phrase>[A graph of distributions for different values of irpow.]</phrase>
56 </textobject>
57
58 <caption>
59 <para>A graph of distributions for different values of irpow.</para>
60 </caption>
61 </mediaobject>
62 </para>
63
64 <para>
65 <emphasis>iseed</emphasis> (optional, default=0) -- seed value for random number generator (positive integer in the range 1 to 2147483646 (2 &circ; 31 - 2)). Zero or negative value seeds from current time (this is also the default). Seeding from current time is guaranteed to generate different random sequences, even if multiple random opcodes are called in a very short time.
66 </para>
67 <para> In the a- and k-rate version the seed is set at opcode initialization. With i-rate output, if iseed is zero or negative, it will seed from current time in the first call, and return the next value from the random sequence in successive calls; positive seed values are set at all i-rate calls. The seed is local for a- and k-rate, and global for i-rate units.
68 </para>
69
70 <note>
71 <title>Notes</title>
72 <para>
73 <itemizedlist>
74 <listitem><para>although seed values up to 2147483646 are allowed, it is recommended to use smaller numbers (&lt; 1000000) for portability, as large integers may be rounded to a different value if 32-bit floats are used.</para></listitem>
75 <listitem><para>i-rate <emphasis>rnd31</emphasis> with a positive seed will always produce the same output value (this is not a bug). To get different values, set seed to 0 in successive calls, which will return the next value from the random sequence.</para></listitem>
76 </itemizedlist>
77 </para>
78 </note>
79 </refsect1>
80
81 <refsect1>
82 <title>Performance</title>
83 <para>
84 <emphasis>ax</emphasis> -- a-rate output value.
85 </para>
86
87 <para>
88 <emphasis>kx</emphasis> -- k-rate output value.
89 </para>
90
91 <para>
92 <emphasis>kscl</emphasis> -- output scale. The generated random numbers are in the range -kscl to kscl. It is the same as <emphasis>iscl</emphasis>, but can be varied at k-rate.
93 </para>
94
95 <para>
96 <emphasis>krpow</emphasis> -- controls the distribution of random numbers. It is the same as <emphasis>irpow</emphasis>, but can be varied at k-rate.
97 </para>
98 </refsect1>
99
100 <refsect1>
101 <title>Examples</title>
102 <para>
103 Here is an example of the rnd31 opcode at a-rate. It uses the file <ulink url="examples/rnd31.csd"><citetitle>rnd31.csd</citetitle></ulink>.
104
105 <example>
106 <title>An example of the rnd31 opcode at a-rate.</title>
107
108
109
110 <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>
111 <xi:include href="examples-xml/rnd31.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
112 </example>
113 </para>
114 <para>
115 Here is an example of the rnd31 opcode at k-rate. It uses the file <ulink url="examples/rnd31_krate.csd"><citetitle>rnd31_krate.csd</citetitle></ulink>.
116
117 <example>
118 <title>An example of the rnd31 opcode at k-rate.</title>
119
120 <xi:include href="examples-xml/rnd31_krate.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
121 </example>
122
123 Its output should include lines like this:
124 <screen>
125 k1=0.112106
126 k1=-0.274665
127 k1=0.403933
128 </screen>
129 </para>
130
131 <para>
132 Here is an example of the rnd31 opcode that uses the number 7 as a seed value. It uses the file <ulink url="examples/rnd31_seed7.csd"><citetitle>rnd31_seed7.csd</citetitle></ulink>.
133
134 <example>
135 <title>An example of the rnd31 opcode that uses the number 7 as a seed value.</title>
136
137 <xi:include href="examples-xml/rnd31_seed7.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
138 </example>
139
140 Its output should include lines like this:
141 <screen>
142 instr 1: i1 = -0.649
143 instr 1: i2 = -0.761
144 instr 1: i3 = 0.677
145 </screen>
146 </para>
147
148 <para>
149 Here is an example of the rnd31 opcode that uses the current time as a seed value. It uses the file <ulink url="examples/rnd31_time.csd"><citetitle>rnd31_time.csd</citetitle></ulink>.
150
151 <example>
152 <title>An example of the rnd31 opcode that uses the current time as a seed value.</title>
153
154 <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>
155 <xi:include href="examples-xml/rnd31_time.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
156 </example>
157
158 Its output should include lines like this:
159 <screen>
160 instr 1: i1 = -0.691
161 instr 1: i2 = -0.686
162 instr 1: i3 = -0.358
163 </screen>
164 </para>
165 </refsect1>
166
167 <refsect1>
168 <title>See also</title>
169 <para><link linkend="SiggenNoise"><citetitle>Random (Noise) Generators</citetitle></link>
170 </para>
171 </refsect1>
172
173 <refsect1>
174 <title>Credits</title>
175 <para>Author: &nameistvan;</para>
176 <para>New in version 4.16</para>
177 </refsect1>
178 </refentry>