rnd

rnd --  Returns a random number in a unipolar range.

Description

Returns a random number in a unipolar range.

Syntax

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.

Performance

Returns a random number in the unipolar range 0 to x.

Examples

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 */
/* Written by Kevin Conder */
; 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 */
/* Written by Kevin Conder */
; Play Instrument #1 for one second.
i 1 0 1
; Play Instrument #1 for one second.
i 1 1 1
e
/* rnd.sco */
        
Its output should include lines like this:
instr 1:  i1 = 0.974
instr 1:  i1 = 0.139
      

See Also

birnd

Credits

Author: Barry L. Vercoe
MIT
Cambridge, Massachussetts
1997