| User-Defined Opcode Database |
|---|
Generate random walk at a-rate
Download UDO FileGenerate random walk at a-rate. rnd31 outputs in range kstep and output is bound within imin and imax.
aout RandomWalkA kstep, imin, imax, iseed
imin - minimum of range of values
imax - maximum of range of values
iseed - seed for rnd31
kstep - kscl for rnd31. The generated random numbers are in the range -kstep to kstep. kstep must be less than (max-min)/2.
opcode RandomWalkA, a, kiii
setksmps 1
kstep, imin, imax, iseed xin
k1 init (imin + imax) * 0.5
k2 rnd31 kstep, 0, iseed
k3 = k1 + k2
k1 = ((k3 < imin) || (k3 > imax) ? k1 - k2 : k3)
aout upsamp k1
xout aout
endop
<CsoundSynthesizer>
<CsOptions>
-d -m231 -H0
</CsOptions>
<CsInstruments>
sr = 48000
ksmps = 32
nchnls = 1
opcode RandomWalkA, a, kiii
setksmps 1
kstep, imin, imax, iseed xin
k1 init (imin + imax) * 0.5
k2 rnd31 kstep, 0, iseed
k3 = k1 + k2
k1 = ((k3 < imin) || (k3 > imax) ? k1 - k2 : k3)
aout upsamp k1
xout aout
endop
opcode RandomWalkK, k, kiii
kstep, imin, imax, iseed xin
k1 init (imin + imax) * 0.5
k2 rnd31 kstep, 0, iseed
k3 = k1 + k2
k1 = ((k3 < imin) || (k3 > imax) ? k1 - k2 : k3)
xout k1
endop
instr 1
kstep linseg 0, p3/2, 2000, p3/2, 0
afoo RandomWalkA kstep, -10000, 10000, 0
out afoo
endin
</CsInstruments>
<CsScore>
t 0 60
i 1 0 5
e
</CsScore>
</CsoundSynthesizer>
Istvan Varga
| Previous | Home | Next |
| quadBformat | RandomWalkK |