Debian Codegraph @

opcodes/rand.xml

raw symbols SCIP
1
2 <refentry id="rand">
3 <indexterm id="IndexRand"><primary>rand</primary></indexterm>
4 <refentryinfo><title>Signal Generators:Random (Noise) Generators</title></refentryinfo>
5 <refmeta>
6 <refentrytitle>rand</refentrytitle>
7 </refmeta>
8
9 <refnamediv>
10 <refname>rand</refname>
11 <refpurpose>
12 Generates a controlled random number series.
13 </refpurpose>
14 </refnamediv>
15
16 <refsect1>
17 <title>Description</title>
18 <para>
19 Output is a controlled random number series between -<emphasis>amp</emphasis> and +<emphasis>amp</emphasis>
20 </para>
21 </refsect1>
22
23 <refsect1>
24 <title>Syntax</title>
25 <synopsis>ares <command>rand</command> xamp [, iseed] [, isel] [, ioffset]</synopsis>
26
27 <synopsis>kres <command>rand</command> xamp [, iseed] [, isel] [, ioffset]</synopsis>
28 </refsect1>
29
30 <refsect1>
31 <title>Initialization</title>
32 <para>
33 <emphasis>iseed</emphasis> (optional, default=0.5) -- a seed value for the recursive pseudo-random formula. A value between 0 and 1 will produce an initial output of <emphasis>kamp * iseed</emphasis>. A value greater than 1 will be seeded from the system clock. A negative value will cause seed re-initialization to be skipped. The default seed value is .5.
34 </para>
35
36 <para>
37 <emphasis>isel</emphasis> (optional, default=0) -- if zero, a 16-bit number is generated. If non-zero, a 31-bit random number is generated. Default is 0.
38 </para>
39
40 <para>
41 <emphasis>ioffset</emphasis> (optional, default=0) -- a base value added to the random result. New in Csound version 4.03.
42 </para>
43 </refsect1>
44
45 <refsect1>
46 <title>Performance</title>
47 <para>
48 <emphasis>kamp, xamp</emphasis> -- range over which random numbers are distributed.
49 </para>
50 <para>
51 <emphasis>ares, kres</emphasis> -- Random number produced.
52 </para>
53
54 <para>
55 The internal pseudo-random formula produces values which are uniformly distributed over the range <emphasis>kamp</emphasis> to <emphasis>-kamp</emphasis>. <emphasis>rand</emphasis> will thus generate uniform white noise with an R.M.S value of <emphasis>kamp / root 2</emphasis>.
56 </para>
57 <para>
58 The value <emphasis>ares</emphasis> or <emphasis>kres</emphasis> is within is a half-closed interval which contains <emphasis>-xamp</emphasis>, but never contains <emphasis>+xamp</emphasis>.
59 </para>
60 </refsect1>
61
62 <refsect1>
63 <title>Examples</title>
64 <para>
65 Here is an example of the rand opcode. It uses the file <ulink url="examples/rand.csd"><citetitle>rand.csd</citetitle></ulink>.
66 <example>
67 <title>Example of the rand opcode.</title>
68 <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>
69 <xi:include href="examples-xml/rand.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
70 </example>
71 </para>
72 <para>
73 The example will produce the following output:
74 <screen>
75 i 1 time 0.00067: 50.00305
76 i 1 time 0.50000: 62.71362
77 i 1 time 1.00000: -89.31885
78
79 WARNING: Seeding from current time 472230558
80
81 i 2 time 2.00067: -70.65735
82 i 2 time 2.50000: 69.15283
83 i 2 time 3.00000: -48.79761
84 </screen>
85 </para>
86 </refsect1>
87
88 <refsect1>
89 <title>See also</title>
90 <para><link linkend="SiggenNoise"><citetitle>Random (Noise) Generators</citetitle></link>
91 <link linkend="randh"><citetitle>randh</citetitle></link>,
92 <link linkend="randi"><citetitle>randi</citetitle></link>
93 </para>
94 </refsect1>
95
96 <refsect1>
97 <title>Credits</title>
98 <para>Thanks to a note from &namejohn;, I changed the names of the parameters.</para>
99 </refsect1>
100 </refentry>