Debian Codegraph @

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