betarand — Beta distribution random number generator (positive values only).
Beta distribution random number generator (positive values only). This is an x-class noise generator.
ares betarand krange, kalpha, kbeta
ires betarand krange, kalpha, kbeta
kres betarand krange, kalpha, kbeta
krange -- range of the random numbers (0 - krange).
kalpha -- alpha value. If kalpha is smaller than one, smaller values favor values near 0.
kbeta -- beta value. If kbeta is smaller than one, smaller values favor values near krange.
If both kalpha and kbeta equal one we have uniform distribution. If both kalpha and kbeta are greater than one we have a sort of Gaussian distribution. Outputs only positive numbers.
For more detailed explanation of these distributions, see:
C. Dodge - T.A. Jerse 1985. Computer music. Schirmer books. pp.265 - 286
D. Lorrain. A panoply of stochastic cannons. In C. Roads, ed. 1989. Music machine . Cambridge, Massachusetts: MIT press, pp. 351 - 379.
Here is an example of the betarand opcode. It uses the file betarand.csd.
Example 85. Example of the betarand 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 ;;;RT audio out ;-iadc ;;;uncomment -iadc if RT audio input is needed too ; For Non-realtime ouput leave only the line below: ; -o betarand.wav -W ;;; for file output any platform </CsOptions> <CsInstruments> sr = 44100 ksmps = 32 nchnls = 2 0dbfs = 1 instr 1 ; every run time same values kbeta betarand 100, 1, 1 printk .2, kbeta ; look aout oscili 0.8, 440+kbeta, 1 ; & listen outs aout, aout endin instr 2 ; every run time different values seed 0 kbeta betarand 100, 1, 1 printk .2, kbeta ; look aout oscili 0.8, 440+kbeta, 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: 85.74227 i 1 time 0.20267: 12.07606 i 1 time 0.40267: 25.03239 i 1 time 0.60267: 0.42037 i 1 time 0.80267: 76.69589 i 1 time 1.00000: 29.73339 i 1 time 1.20267: 48.29811 i 1 time 1.40267: 75.46507 i 1 time 1.60267: 74.80686 i 1 time 1.80000: 81.37473 i 1 time 2.00000: 55.48827 Seeding from current time 3472120656 i 2 time 3.00267: 57.21408 i 2 time 3.20267: 30.95705 i 2 time 3.40267: 19.71687 i 2 time 3.60000: 64.48965 i 2 time 3.80267: 72.35818 i 2 time 4.00000: 49.65395 i 2 time 4.20000: 55.25888 i 2 time 4.40267: 3.98308 i 2 time 4.60267: 52.98075 i 2 time 4.80267: 58.07925 i 2 time 5.00000: 56.38914