| 1 | |
| 2 | <refentry id="randomi"> |
| 3 | <indexterm id="IndexRandomi"><primary>randomi</primary></indexterm> |
| 4 | <refentryinfo><title>Signal Generators:Random (Noise) Generators</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>randomi</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>randomi</refname> |
| 11 | <refpurpose> |
| 12 | Generates a user-controlled random number series with interpolation between each new number. |
| 13 | </refpurpose> |
| 14 | </refnamediv> |
| 15 | |
| 16 | <refsect1> |
| 17 | <title>Description</title> |
| 18 | <para> |
| 19 | Generates a user-controlled random number series with interpolation between each new number. |
| 20 | </para> |
| 21 | </refsect1> |
| 22 | |
| 23 | <refsect1> |
| 24 | <title>Syntax</title> |
| 25 | <synopsis>ares <command>randomi</command> kmin, kmax, xcps [,imode] [,ifirstval]</synopsis> |
| 26 | |
| 27 | <synopsis>kres <command>randomi</command> kmin, kmax, kcps [,imode] [,ifirstval]</synopsis> |
| 28 | </refsect1> |
| 29 | |
| 30 | <refsect1> |
| 31 | <title>Initialization</title> |
| 32 | <para> |
| 33 | <emphasis>imode</emphasis> (optional, default=0) -- first interpolation cycle mode (see below) |
| 34 | </para> |
| 35 | |
| 36 | <para> |
| 37 | <emphasis>ifirstval</emphasis> (optional, default=0) -- first output value |
| 38 | </para> |
| 39 | </refsect1> |
| 40 | |
| 41 | <refsect1> |
| 42 | <title>Performance</title> |
| 43 | <para> |
| 44 | <emphasis>kmin</emphasis> -- minimum range limit |
| 45 | </para> |
| 46 | |
| 47 | <para> |
| 48 | <emphasis>kmax</emphasis> -- maximum range limit |
| 49 | </para> |
| 50 | |
| 51 | <para> |
| 52 | <emphasis>kcps, xcps</emphasis> -- rate of random break-point generation |
| 53 | </para> |
| 54 | |
| 55 | <para> |
| 56 | The <emphasis>randomi</emphasis> opcode is similar to <link linkend="randi"><citetitle>randi</citetitle></link> but allows the user to set arbitrary minimum and maximum values. |
| 57 | </para> |
| 58 | |
| 59 | <para> |
| 60 | When <emphasis>imode</emphasis> = 0 (the default), the <emphasis>kmin</emphasis> |
| 61 | argument value is outputted during <emphasis>1/kcps</emphasis> (resp. |
| 62 | <emphasis>1/xcps</emphasis>) seconds at the beginning of the note, before |
| 63 | the first random number is generated. Then the normal interpolation process |
| 64 | takes place, first between <emphasis>kmin</emphasis> and the first random |
| 65 | number generated, and then between successive generated random numbers, |
| 66 | each interpolation cycle having a duration of <emphasis>1/kcps</emphasis> |
| 67 | (resp. <emphasis>1/xcps</emphasis>) seconds. |
| 68 | </para> |
| 69 | |
| 70 | <para> |
| 71 | When <emphasis>imode</emphasis> = 1, a random number is generated at |
| 72 | initialization and interpolation begins immediately between the |
| 73 | <emphasis>kmin</emphasis> argument value and that random number. |
| 74 | </para> |
| 75 | |
| 76 | <para> |
| 77 | When <emphasis>imode</emphasis> = 2, a random number is generated at |
| 78 | initialization and interpolation begins immediately between the |
| 79 | <emphasis>ifirstval</emphasis> argument value and that random number. |
| 80 | </para> |
| 81 | |
| 82 | <para> |
| 83 | When <emphasis>imode</emphasis> = 3, two random numbers are generated |
| 84 | at initialization as breakpoints for the first interpolation cycle. |
| 85 | </para> |
| 86 | </refsect1> |
| 87 | |
| 88 | <refsect1> |
| 89 | <title>Examples</title> |
| 90 | <para> |
| 91 | Here is an example of the randomi opcode. It uses the file <ulink url="examples/randomi.csd"><citetitle>randomi.csd</citetitle></ulink>. |
| 92 | |
| 93 | <example> |
| 94 | <title>Example of the randomi opcode.</title> |
| 95 | |
| 96 | <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> |
| 97 | <xi:include href="examples-xml/randomi.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 98 | </example> |
| 99 | |
| 100 | Its output should include lines like this: |
| 101 | <screen> |
| 102 | Mode: 0 |
| 103 | k1 = 220.000000 |
| 104 | k1 = 220.000000 |
| 105 | k1 = 220.146093 |
| 106 | k1 = 246.827703 |
| 107 | k1 = 395.595775 |
| 108 | ... |
| 109 | |
| 110 | Mode: 1 |
| 111 | k1 = 220.000000 |
| 112 | k1 = 224.325329 |
| 113 | k1 = 274.370074 |
| 114 | k1 = 343.216049 |
| 115 | k1 = 414.324347 |
| 116 | ... |
| 117 | |
| 118 | Mode: 2 |
| 119 | k1 = 330.000000 |
| 120 | k1 = 292.628171 |
| 121 | k1 = 334.519777 |
| 122 | k1 = 290.610602 |
| 123 | k1 = 394.905366 |
| 124 | ... |
| 125 | |
| 126 | Mode: 3 |
| 127 | k1 = 360.727674 |
| 128 | k1 = 431.680412 |
| 129 | k1 = 380.625254 |
| 130 | k1 = 289.267139 |
| 131 | k1 = 303.038109 |
| 132 | ...</screen> |
| 133 | </para> |
| 134 | </refsect1> |
| 135 | |
| 136 | <refsect1> |
| 137 | <title>See also</title> |
| 138 | <para><link linkend="SiggenNoise"><citetitle>Random (Noise) Generators</citetitle></link> |
| 139 | </para> |
| 140 | </refsect1> |
| 141 | |
| 142 | <refsect1> |
| 143 | <title>Credits</title> |
| 144 | <para>Author: &namegabriel;</para> |
| 145 | <para>Arguments <emphasis>imode</emphasis> and <emphasis>ifirstval</emphasis> |
| 146 | added by &namepinot;, Jan. 2011, after a discussion with Peiman Khosravi on |
| 147 | the csnd list.</para> |
| 148 | <para>Example written by &namekevin;, adapted for new args by &namepinot;.</para> |
| 149 | </refsect1> |
| 150 | </refentry> |