Debian Codegraph @

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

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 -odac
4 </CsOptions>
5 <CsInstruments>
6
7 sr = 44100
8 ksmps = 32
9 nchnls = 2
10 0dbfs = 1
11
12 seed 0
13 giTone ftgen 0, 0, 2^10, 10, 1, .5, .3, .1
14
15 instr 1
16 kGate randomi 0, 1, 3; moves between 0 and 1 (3 new values per second)
17 kFreq randomi 300, 800, 1; moves between 300 and 800 hz
18 ;(1 new value per sec)
19 kdB randomi -12, 0, 5; moves between -12 and 0 dB
20 ;(5 new values per sec)
21 aSig oscil3 1, kFreq, giTone
22 kVol init 0
23 kVol = (kGate > 0.5 ? ampdb(kdB) : 0); short form of condition
24 kVol port kVol, .02; smooth volume curve to avoid clicks
25 aOut = aSig * kVol
26 outs aOut, aOut
27 endin
28
29 </CsInstruments>
30 <CsScore>
31 i 1 0 20
32 </CsScore>
33 </CsoundSynthesizer>
34 ;example by joachim heintz