| 1 | |
| 2 | <refentry id="rnd"> |
| 3 | <indexterm id="IndexRnd"><primary>rnd</primary></indexterm> |
| 4 | <refentryinfo><title>Mathematical Operations:Random Functions</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>rnd</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>rnd</refname> |
| 11 | <refpurpose> |
| 12 | Returns a random number in a unipolar range at the rate given by the input argument. |
| 13 | </refpurpose> |
| 14 | </refnamediv> |
| 15 | |
| 16 | <refsect1> |
| 17 | <title>Description</title> |
| 18 | <para> |
| 19 | Returns a random number in a unipolar range at the rate given by the input argument. |
| 20 | </para> |
| 21 | </refsect1> |
| 22 | |
| 23 | <refsect1> |
| 24 | <title>Syntax</title> |
| 25 | <synopsis><command>rnd</command>(x) (init- or control-rate only)</synopsis> |
| 26 | |
| 27 | <para> |
| 28 | Where the argument within the parentheses may be an expression. These value converters sample a global random sequence, but do not reference <emphasis>seed</emphasis>. The result can be a term in a further expression. |
| 29 | </para> |
| 30 | </refsect1> |
| 31 | |
| 32 | <refsect1> |
| 33 | <title>Performance</title> |
| 34 | <para> |
| 35 | Returns a random number in the unipolar range 0 to <emphasis>x</emphasis>. |
| 36 | </para> |
| 37 | </refsect1> |
| 38 | |
| 39 | <refsect1> |
| 40 | <title>Examples</title> |
| 41 | <para> |
| 42 | Here is an example of the rnd opcode. It uses the file <ulink url="examples/rnd.csd"><citetitle>rnd.csd</citetitle></ulink>. |
| 43 | |
| 44 | <example> |
| 45 | <title>Example of the rnd opcode.</title> |
| 46 | <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> |
| 47 | <xi:include href="examples-xml/rnd.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 48 | </example> |
| 49 | |
| 50 | Its output should be: |
| 51 | <screen>SECTION 1: |
| 52 | new alloc for instr 1: |
| 53 | instr 1: irand = 9.735 |
| 54 | new alloc for instr 1: |
| 55 | instr 1: irand = 1.394 |
| 56 | new alloc for instr 1: |
| 57 | instr 1: irand = 7.695 |
| 58 | midi channel 1 now using instr 1 |
| 59 | B 0.000 .. 2.000 T 2.000 TT 2.000 M: 0.00000 |
| 60 | new alloc for instr 2: |
| 61 | i 2 time 2.10000: 5.25005 |
| 62 | i 2 time 2.20000: 6.22665 |
| 63 | i 2 time 2.30000: 9.69511 |
| 64 | i 2 time 2.40000: 7.16822 |
| 65 | i 2 time 2.50000: 9.45134 |
| 66 | i 2 time 2.60000: 1.34123 |
| 67 | i 2 time 2.70000: 2.09879 |
| 68 | i 2 time 2.80000: 2.36001 |
| 69 | i 2 time 2.90000: 0.03553</screen> |
| 70 | </para> |
| 71 | </refsect1> |
| 72 | |
| 73 | <refsect1> |
| 74 | <para> |
| 75 | Here is another example of the rnd opcode. It uses the file <ulink url="examples/rnd-advanced.csd"><citetitle>rnd-advanced.csd</citetitle></ulink>. |
| 76 | |
| 77 | <example> |
| 78 | <title>Advanced example of the rnd opcode.</title> |
| 79 | |
| 80 | |
| 81 | |
| 82 | <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> |
| 83 | <xi:include href="examples-xml/rnd-advanced.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 84 | </example> |
| 85 | </para> |
| 86 | </refsect1> |
| 87 | |
| 88 | <refsect1> |
| 89 | <title>See also</title> |
| 90 | <para><link linkend="MathRndfunc"><citetitle>Random Functions</citetitle></link></para> |
| 91 | </refsect1> |
| 92 | |
| 93 | <refsect1> |
| 94 | <title>Credits</title> |
| 95 | <para> |
| 96 | <simplelist> |
| 97 | <member>Author: &namebarry;</member> |
| 98 | <member>MIT</member> |
| 99 | <member>Cambridge, Massachussetts</member> |
| 100 | <member>1997</member> |
| 101 | </simplelist> |
| 102 | </para> |
| 103 | </refsect1> |
| 104 | </refentry> |