linrand

linrand — Linear distribution random number generator (positive values only).

Description

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

Syntax

ares linrand krange
ires linrand krange
kres linrand krange

Performance

krange -- the range of the random numbers (0 - krange). Outputs only positive numbers.

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 linrand opcode. It uses the file linrand.csd.

Example 424. Example of the linrand 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 linrand.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

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

instr 1  	; every run time same values

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

instr 2		; every run time different values

	seed 0
klin	linrand 100
	printk .2, klin			; look 
aout	oscili 0.8, 440+klin, 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 this:

 i   1 time     0.00033:    13.54770
 i   1 time     0.20033:    32.38746
 i   1 time     0.40033:    47.69304
 i   1 time     0.60033:    19.82218
 i   1 time     0.80033:    42.98293
 i   1 time     1.00000:    81.13174
 i   1 time     1.20033:    47.39585
 i   1 time     1.40033:    12.53248
 i   1 time     1.60033:    35.70722
 i   1 time     1.80000:    65.25774
 i   1 time     2.00000:    23.24811
Seeding from current time 392575384
 i   2 time     3.00033:    23.05609
 i   2 time     3.20033:    76.15114
 i   2 time     3.40033:    22.78861
 i   2 time     3.60000:     0.79064
 i   2 time     3.80033:    43.49438
 i   2 time     4.00000:    34.10963
 i   2 time     4.20000:    31.88702
 i   2 time     4.40033:    59.78054
 i   2 time     4.60033:     4.96821
 i   2 time     4.80033:    24.69674
 i   2 time     5.00000:    21.88815
      

See Also

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

Credits

Author: Paris Smaragdis
MIT, Cambridge
1995