Debian Codegraph @

src/Examples/FLOSS Manual Examples/03 Csound Language/03C02_IfThen_k.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 seed 0; random values each time different
12 giTone ftgen 0, 0, 2^10, 10, 1, .5, .3, .1
13
14 instr 1
15
16 ; move between 0 and 1 (3 new values per second)
17 kGate randomi 0, 1, 3, 3
18 ; move between 300 and 800 hz (1 new value per sec)
19 kFreq randomi 300, 800, 1, 3
20 ; move between -12 and 0 dB (5 new values per sec)
21 kdB randomi -12, 0, 5, 3
22 aSig oscil3 1, kFreq, giTone
23 kVol init 0
24 if kGate > 0.5 then; if kGate is larger than 0.5
25 kVol = ampdb(kdB); open gate
26 else
27 kVol = 0; otherwise close gate
28 endif
29 kVol port kVol, .02; smooth volume curve to avoid clicks
30 aOut = aSig * kVol
31 outs aOut, aOut
32 endin
33
34 </CsInstruments>
35 <CsScore>
36 i 1 0 30
37 </CsScore>
38 </CsoundSynthesizer>
39 ;example by joachim heintz