| 1 | <refentry id="randc"> |
| 2 | <indexterm id="IndexRandc"><primary>randc</primary></indexterm> |
| 3 | <refentryinfo><title>Signal Generators:Random (Noise) Generators</title></refentryinfo> |
| 4 | <refmeta> |
| 5 | <refentrytitle>randc</refentrytitle> |
| 6 | </refmeta> |
| 7 | |
| 8 | |
| 9 | |
| 10 | <refnamediv> |
| 11 | <refname>randc</refname> |
| 12 | <refpurpose> |
| 13 | Generates a controlled random number series with cubic interpolation between each new number. |
| 14 | </refpurpose> |
| 15 | </refnamediv> |
| 16 | |
| 17 | <refsect1> |
| 18 | <title>Description</title> |
| 19 | <para> |
| 20 | Generates a controlled random number series with cubic interpolation between each new number. |
| 21 | </para> |
| 22 | </refsect1> |
| 23 | |
| 24 | <refsect1> |
| 25 | <title>Syntax</title> |
| 26 | <synopsis>ares <command>randc</command> xamp, xcps [, iseed] [, isize] [, ioffset]</synopsis> |
| 27 | |
| 28 | <synopsis>kres <command>randc</command> kamp, kcps [, iseed] [, isize] [, ioffset]</synopsis> |
| 29 | </refsect1> |
| 30 | |
| 31 | <refsect1> |
| 32 | <title>Initialization</title> |
| 33 | <para> |
| 34 | <emphasis>iseed</emphasis> (optional, default=0.5) -- 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 negative value will cause seed re-initialization to be skipped. A value greater than 1 will seed from system time, this is the best option to generate a different random sequence for each run. |
| 35 | </para> |
| 36 | |
| 37 | <para> |
| 38 | <emphasis>isize</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. |
| 39 | </para> |
| 40 | |
| 41 | <para> |
| 42 | <emphasis>ioffset</emphasis> (optional, default=0) -- a base value added to the random result. |
| 43 | </para> |
| 44 | </refsect1> |
| 45 | |
| 46 | <refsect1> |
| 47 | <title>Performance</title> |
| 48 | <para> |
| 49 | <emphasis>kamp, xamp</emphasis> -- range over which random numbers are distributed. |
| 50 | </para> |
| 51 | |
| 52 | <para> |
| 53 | <emphasis>kcps, xcps</emphasis> -- the frequency which new random numbers are generated. |
| 54 | </para> |
| 55 | |
| 56 | <para> |
| 57 | 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>. |
| 58 | </para> |
| 59 | |
| 60 | <para> |
| 61 | The remaining units produce band-limited noise: the <emphasis>kcps</emphasis> and <emphasis>xcps</emphasis> parameters permit the user to specify that new random numbers are to be generated at a rate less than the sampling or control frequencies. <emphasis>randi</emphasis> will produce straight-line interpolation between each new number and the next. |
| 62 | </para> |
| 63 | </refsect1> |
| 64 | |
| 65 | <refsect1> |
| 66 | <title>Examples</title> |
| 67 | <para> |
| 68 | Here is an example of the randc opcode. It uses the file <ulink url="examples/randc.csd"><citetitle>randc.csd</citetitle></ulink>. |
| 69 | <example> |
| 70 | <title>Example of the randc opcode.</title> |
| 71 | <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> |
| 72 | <xi:include href="examples-xml/randc.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 73 | </example> |
| 74 | </para> |
| 75 | <para> |
| 76 | The example will produce the following output: |
| 77 | <screen> |
| 78 | i 1 time 0.00000: 50.00305 |
| 79 | i 1 time 0.50068: 68.16267 |
| 80 | i 1 time 1.00136: -94.61682 |
| 81 | i 1 time 1.50204: -74.38840 |
| 82 | .... |
| 83 | |
| 84 | WARNING: Seeding from current time 67726716 |
| 85 | |
| 86 | i 2 time 4.00036: 79.19006 |
| 87 | i 2 time 4.50104: -47.46559 |
| 88 | i 2 time 5.00172: 74.73582 |
| 89 | i 2 time 5.50240: 65.35726 |
| 90 | .... |
| 91 | </screen> |
| 92 | </para> |
| 93 | </refsect1> |
| 94 | |
| 95 | <refsect1> |
| 96 | <title>See also</title> |
| 97 | <para><link linkend="SiggenNoise"><citetitle>Random (Noise) Generators</citetitle></link> |
| 98 | <link linkend="randh"><citetitle>randh</citetitle></link>, |
| 99 | <link linkend="rand"><citetitle>rand</citetitle></link> |
| 100 | </para> |
| 101 | </refsect1> |
| 102 | |
| 103 | </refentry> |