Skip to content

bexprnd

Exponential distribution random number generator.

This is an x-class noise generator.

Syntax

ares = bexprnd(krange)
ires = bexprnd(krange)
kres = bexprnd(krange)
ares bexprnd krange
ires bexprnd krange
kres bexprnd krange

Performance

krange -- the range of the random numbers (-krange to +krange)

For more detailed explanation of these distributions, see:

  1. C. Dodge - T.A. Jerse 1985. Computer music. Schirmer books. pp.265 - 286
  2. D. Lorrain. A panoply of stochastic cannons. In C. Roads, ed. 1989. Music machine. Cambridge, Massachusetts: MIT press, pp. 351 - 379.

Examples

Here is an example of the bexprnd opcode. It uses the file bexprnd-modern.csd.

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

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

instr 1         ; every run time same values
  kexp = bexprnd(100)
  printk(0.2, kexp)                 ; look 
  aout = oscili(0.8, 440+kexp, 1)   ; & listen
  outs(aout, aout)
endin

instr 2         ; every run time different values
  seed(0)
  kexp = bexprnd(100)
  printk(0.2, kexp)                 ; look 
  aout = oscili(0.8, 440+kexp, 1)   ; & listen
  outs(aout, aout)
endin

</CsInstruments>
<CsScore>
; sine wave
f 1 0 16384 10 1

i 1 0 2
i 2 3 2
e

</CsScore>
</CsoundSynthesizer>

Here is an example of the bexprnd opcode. It uses the file bexprnd.csd.

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

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

instr 1         ; every run time same values

kexp    bexprnd 100
        printk .2, kexp                 ; look 
aout    oscili 0.8, 440+kexp, 1         ; & listen
        outs    aout, aout

endin

instr 2         ; every run time different values

        seed 0
kexp    bexprnd 100
        printk .2, kexp                 ; look 
aout    oscili 0.8, 440+kexp, 1         ; & listen
        outs    aout, aout
endin

</CsInstruments>
<CsScore>
; sine wave
f 1 0 16384 10 1

i 1 0 2
i 2 3 2
e

</CsScore>
</CsoundSynthesizer>

Its output should include a line like:

i 1 time 0.00267: 99.27598 i 1 time 0.20267: 74.97176 i 1 time 0.40267: -35.67213 i 1 time 0.60267: 1.10579 i 1 time 0.80267: -18.08816 i 1 time 1.00000: 28.93329 i 1 time 1.20267: 320.63733 i 1 time 1.40267: -332.05614 i 1 time 1.60267: -212.66361 i 1 time 1.80000: -92.57433 i 1 time 2.00000: 140.70939 Seeding from current time 4055201702 i 2 time 3.00267: 190.30495 i 2 time 3.20267: -58.30677 i 2 time 3.40267: 192.39784 i 2 time 3.60000: 12.72448 i 2 time 3.80267: 79.91503 i 2 time 4.00000: 34.44258 i 2 time 4.20000: 167.92680 i 2 time 4.40267: -117.10278 i 2 time 4.60267: -70.99155 i 2 time 4.80267: -23.24037 i 2 time 5.00000: -226.35500-modern

See also

Random (Noise) Generators

Credits

Author: Paris Smaragdis
MIT, Cambridge
1995