Debian Codegraph @

src/Examples/FLOSS Manual Examples/03 Csound Language/03G11_UDO_rand_dev.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 -odac
4 </CsOptions>
5 <CsInstruments>
6 sr = 44100
7 ksmps = 32
8 nchnls = 2
9 0dbfs = 1
10
11 giSine ftgen 0, 0, 256, 10, 1; sine wave
12
13 opcode TabDirtk, 0, ikk
14 ;"dirties" a function table by applying random deviations at a k-rate trigger
15 ;input: function table, trigger (1 = perform manipulation),
16 ;deviation as percentage
17 ift, ktrig, kperc xin
18 if ktrig == 1 then ;just work if you get a trigger signal
19 kndx = 0
20 while kndx < ftlen(ift) do
21 kval table kndx, ift; read old value
22 knewval = kval + rnd31:k(kperc/100,0); calculate new value
23 tablew knewval, kndx, giSine; write new value
24 kndx += 1
25 od
26 endif
27 endop
28
29 instr 1
30 kTrig metro 1 ;trigger signal once per second
31 kPerc linseg 0, p3, 100
32 TabDirtk giSine, kTrig, kPerc
33 aSig poscil .2, 400, giSine
34 out aSig, aSig
35 endin
36
37 </CsInstruments>
38 <CsScore>
39 i 1 0 10
40 </CsScore>
41 </CsoundSynthesizer>
42 ;example by joachim heintz