birnd

birnd — Returns a random number in a bi-polar range.

Description

Returns a random number in a bi-polar range.

Syntax

birnd(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 bipolar range -x to x. rnd and birnd obtain values from a global pseudo-random number generator, then scale them into the requested range. The single global generator will thus distribute its sequence to these units throughout the performance, in whatever order the requests arrive.

Examples

Here is an example of the birnd opcode. Play birnd.csd

Example 105. Example of the birnd opcode.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac    ;;;realtime audio out
;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
; For Non-realtime ouput leave only the line below:
;-o birnd.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs  = 1

instr 1		; Generate a random number from -1 to 1.
  
kbin =	birnd(1)
	printk .2, kbin
endin

</CsInstruments>
<CsScore>

i 1 0 1
i 1 + .
i 1 + .
i 1 + .
i 1 + .
i 1 + .
i 1 + .
e
</CsScore>
</CsoundSynthesizer>


Its output should include lines like:

instr 1:  i1 = 0.94700
instr 1:  i1 = -0.72119
instr 1:  i1 = 0.53898
instr 1:  i1 = 0.05001
instr 1:  i1 = 0.24533
instr 1:  i1 = 0.93902
instr 1:  i1 = 0.43364

See Also

rnd

Credits

Author: Barry L. Vercoe
MIT
Cambridge, Massachussetts
1997

Extended in 3.47 to x-rate by John ffitch.