rnd(x) (init- or control-rate only)
Where the argument within the parentheses may be an expression. These value converters sample a global random sequence, but do not reference seed. The result can be a term in a further expression.
Here is an example of the rnd opcode. It uses the files rnd.orc and rnd.sco.
Example 1. Example of the rnd opcode.
/* rnd.orc */
; Initialize the global variables.
sr = 44100
kr = 4410
ksmps = 10
nchnls = 1
; Instrument #1.
instr 1
; Generate a random number from 0 to 1.
i1 = rnd(1)
print i1
endin
/* rnd.orc */
/* rnd.sco */
; Play Instrument #1 for one second.
i 1 0 1
; Play Instrument #1 for one second.
i 1 1 1
e
/* rnd.sco */
instr 1: i1 = 0.974 instr 1: i1 = 0.139