unirand

unirand — Uniform distribution random number generator (positive values only).

Description

Uniform distribution random number generator (positive values only). This is an x-class noise generator.

Syntax

ares unirand krange
ires unirand krange
kres unirand krange

Performance

krange -- the range of the random numbers (0 - 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 unirand opcode. Play unirand.csd

Example 1136. Example of the unirand 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 RT audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o unirand.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

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

instr 1  	; every run time same values

ktri	unirand 100
	printk .2, ktri			; look 
aout	oscili 0.8, 440+ktri, 1		; & listen
	outs	aout, aout
endin

instr 2		; every run time different values

	seed 0
ktri	unirand 100
	printk .2, ktri			; look 
aout	oscili 0.8, 440+ktri, 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 lines like these:

 i   1 time     0.00067:    81.47237
 i   1 time     0.20067:    41.72671
 i   1 time     0.40067:     5.96189
 i   1 time     0.60067:    91.59912
 i   1 time     0.80067:    85.07127
 i   1 time     1.00000:    92.50948
 i   1 time     1.20067:    98.79347
 i   1 time     1.40067:    98.91449
 i   1 time     1.60067:    50.37808
 i   1 time     1.80000:    72.02497
 i   1 time     2.00000:    52.94362

WARNING: Seeding from current time 4007444022

 i   2 time     3.00067:    91.86294
 i   2 time     3.20067:    94.68759
 i   2 time     3.40067:     1.05825
 i   2 time     3.60000:    78.57628
 i   2 time     3.80067:    27.67408
 i   2 time     4.00000:    76.46347
 i   2 time     4.20000:    77.10071
 i   2 time     4.40067:    34.28921
 i   2 time     4.60067:    37.72286
 i   2 time     4.80067:    54.96646
 i   2 time     5.00000:    11.67566
B  3.000 ..  5.000 T  5.000 TT  5.000 M:  0.80000  0.80000
Score finished in csoundPerform().
      

See Also

seed, betarand, bexprnd, cauchy, exprand, gauss, linrand, pcauchy, poisson, trirand, weibull

Credits

Author: Paris Smaragdis
MIT, Cambridge
1995