rnd31Signal Generators:Random (Noise) Generatorsrnd31rnd31
31-bit bipolar random opcodes with controllable distribution.
Description
31-bit bipolar random opcodes with controllable distribution. These units are portable, i.e. using the same seed value will generate the same random sequence on all systems. The distribution of generated random numbers can be varied at k-rate.
Syntaxax rnd31 kscl, krpow [, iseed]ix rnd31 iscl, irpow [, iseed]kx rnd31 kscl, krpow [, iseed]Initializationix -- i-rate output value.
iscl -- output scale. The generated random numbers are in the range -iscl to iscl.
irpow -- controls the distribution of random numbers. If irpow is positive, the random distribution (x is in the range -1 to 1) is abs(x) ˆ ((1 / irpow) - 1); for negative irpow values, it is (1 - abs(x)) ˆ ((-1 / irpow) - 1). Setting irpow to -1, 0, or 1 will result in uniform distribution (this is also faster to calculate).
[A graph of distributions for different values of irpow.]
A graph of distributions for different values of irpow.
iseed (optional, default=0) -- seed value for random number generator (positive integer in the range 1 to 2147483646 (2 ˆ 31 - 2)). Zero or negative value seeds from current time (this is also the default). Seeding from current time is guaranteed to generate different random sequences, even if multiple random opcodes are called in a very short time.
In the a- and k-rate version the seed is set at opcode initialization. With i-rate output, if iseed is zero or negative, it will seed from current time in the first call, and return the next value from the random sequence in successive calls; positive seed values are set at all i-rate calls. The seed is local for a- and k-rate, and global for i-rate units.
Notesalthough seed values up to 2147483646 are allowed, it is recommended to use smaller numbers (< 1000000) for portability, as large integers may be rounded to a different value if 32-bit floats are used.i-rate rnd31 with a positive seed will always produce the same output value (this is not a bug). To get different values, set seed to 0 in successive calls, which will return the next value from the random sequence.Performanceax -- a-rate output value.
kx -- k-rate output value.
kscl -- output scale. The generated random numbers are in the range -kscl to kscl. It is the same as iscl, but can be varied at k-rate.
krpow -- controls the distribution of random numbers. It is the same as irpow, but can be varied at k-rate.
Examples
Here is an example of the rnd31 opcode at a-rate. It uses the file rnd31.csd.
An example of the rnd31 opcode at a-rate.See the sections Real-time Audio and Command Line Flags for more information on using command line flags.
Here is an example of the rnd31 opcode at k-rate. It uses the file rnd31_krate.csd.
An example of the rnd31 opcode at k-rate.
Its output should include lines like this:
k1=0.112106
k1=-0.274665
k1=0.403933
Here is an example of the rnd31 opcode that uses the number 7 as a seed value. It uses the file rnd31_seed7.csd.
An example of the rnd31 opcode that uses the number 7 as a seed value.
Its output should include lines like this:
instr 1: i1 = -0.649
instr 1: i2 = -0.761
instr 1: i3 = 0.677
Here is an example of the rnd31 opcode that uses the current time as a seed value. It uses the file rnd31_time.csd.
An example of the rnd31 opcode that uses the current time as a seed value.See the sections Real-time Audio and Command Line Flags for more information on using command line flags.
Its output should include lines like this:
instr 1: i1 = -0.691
instr 1: i2 = -0.686
instr 1: i3 = -0.358
See alsoRandom (Noise) GeneratorsCreditsAuthor: &nameistvan;New in version 4.16