| 1 | |
| 2 | <refentry id="randh"> |
| 3 | <indexterm id="IndexRandh"><primary>randh</primary></indexterm> |
| 4 | <refentryinfo><title>Signal Generators:Random (Noise) Generators</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>randh</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | |
| 10 | |
| 11 | <refnamediv> |
| 12 | <refname>randh</refname> |
| 13 | <refpurpose> |
| 14 | Generates random numbers and holds them for a period of time. |
| 15 | </refpurpose> |
| 16 | </refnamediv> |
| 17 | |
| 18 | <refsect1> |
| 19 | <title>Description</title> |
| 20 | <para> |
| 21 | Generates random numbers and holds them for a period of time. |
| 22 | </para> |
| 23 | </refsect1> |
| 24 | |
| 25 | <refsect1> |
| 26 | <title>Syntax</title> |
| 27 | <synopsis>ares <command>randh</command> xamp, xcps [, iseed] [, isize] [, ioffset]</synopsis> |
| 28 | |
| 29 | <synopsis>kres <command>randh</command> kamp, kcps [, iseed] [, isize] [, ioffset]</synopsis> |
| 30 | </refsect1> |
| 31 | |
| 32 | <refsect1> |
| 33 | <title>Initialization</title> |
| 34 | <para> |
| 35 | <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. |
| 36 | </para> |
| 37 | |
| 38 | <para> |
| 39 | <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. |
| 40 | </para> |
| 41 | |
| 42 | <para> |
| 43 | <emphasis>ioffset</emphasis> (optional, default=0) -- a base value added to the random result. New in Csound version 4.03. |
| 44 | </para> |
| 45 | </refsect1> |
| 46 | |
| 47 | <refsect1> |
| 48 | <title>Performance</title> |
| 49 | <para> |
| 50 | <emphasis>kamp, xamp</emphasis> -- range over which random numbers are distributed. |
| 51 | </para> |
| 52 | |
| 53 | <para> |
| 54 | <emphasis>kcps, xcps</emphasis> -- the frequency which new random numbers are generated. |
| 55 | </para> |
| 56 | |
| 57 | <para> |
| 58 | 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>. |
| 59 | </para> |
| 60 | |
| 61 | <para> |
| 62 | 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>randh</emphasis> will hold each new number for the period of the specified cycle. |
| 63 | </para> |
| 64 | </refsect1> |
| 65 | |
| 66 | <refsect1> |
| 67 | <title>Examples</title> |
| 68 | <para> |
| 69 | Here is an example of the randh opcode. It uses the file <ulink url="examples/randh.csd"><citetitle>randh.csd</citetitle></ulink>. |
| 70 | <example> |
| 71 | <title>Example of the randh opcode.</title> |
| 72 | <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> |
| 73 | <xi:include href="examples-xml/randh.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 74 | </example> |
| 75 | </para> |
| 76 | <para> |
| 77 | The example will produce the following output: |
| 78 | <screen> |
| 79 | i1 50.00000 |
| 80 | i1 50.00305 |
| 81 | i1 97.68677 |
| 82 | i1 -44.25354 |
| 83 | i1 -61.56006 |
| 84 | i1 -75.91248 |
| 85 | i1 67.57202 |
| 86 | i1 12.83875 |
| 87 | i1 5.39551 |
| 88 | i1 -95.18738 |
| 89 | |
| 90 | WARNING: Seeding from current time 684387922 |
| 91 | |
| 92 | i2 -13.81226 |
| 93 | i2 -16.49475 |
| 94 | i2 69.51904 |
| 95 | i2 35.04944 |
| 96 | i2 47.47925 |
| 97 | i2 63.25378 |
| 98 | i2 -59.61914 |
| 99 | i2 50.93079 |
| 100 | i2 -6.46362 |
| 101 | i2 5.89294 |
| 102 | </screen> |
| 103 | </para> |
| 104 | </refsect1> |
| 105 | |
| 106 | <refsect1> |
| 107 | <title>See also</title> |
| 108 | <para><link linkend="SiggenNoise"><citetitle>Random (Noise) Generators</citetitle></link> |
| 109 | <link linkend="rand"><citetitle>rand</citetitle></link>, |
| 110 | <link linkend="randi"><citetitle>randi</citetitle></link> |
| 111 | </para> |
| 112 | </refsect1> |
| 113 | |
| 114 | </refentry> |