Debian Codegraph @

src/Examples/FLOSS Manual Examples/04 Sound Synthesis/04F02_GranSynth_basic.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 -odac -m0
4 </CsOptions>
5 <CsInstruments>
6
7 sr = 44100
8 ksmps = 1
9 nchnls = 1
10 0dbfs = 1
11
12 giSine ftgen 0,0,4096,10,1
13
14 instr 1
15 kRate expon p4,p3,p5 ; rate of grain generation
16 kTrig metro kRate ; a trigger to generate grains
17 kDur expon p6,p3,p7 ; grain duration
18 kForm expon p8,p3,p9 ; formant (spectral centroid)
19 ; p1 p2 p3 p4
20 schedkwhen kTrig,0,0,2, 0, kDur,kForm ;trigger a note(grain) in instr 2
21 ;print data to terminal every 1/2 second
22 printks "Rate:%5.2F Dur:%5.2F Formant:%5.2F%n", 0.5, kRate , kDur, kForm
23 endin
24
25 instr 2
26 iForm = p4
27 aEnv linseg 0,0.005,0.2,p3-0.01,0.2,0.005,0
28 aSig poscil aEnv, iForm, giSine
29 out aSig
30 endin
31
32 </CsInstruments>
33 <CsScore>
34 ;p4 = rate begin
35 ;p5 = rate end
36 ;p6 = duration begin
37 ;p7 = duration end
38 ;p8 = formant begin
39 ;p9 = formant end
40 ; p1 p2 p3 p4 p5 p6 p7 p8 p9
41 i 1 0 30 1 100 0.02 0.02 400 400 ;demo of grain generation rate
42 i 1 31 10 10 10 0.4 0.01 400 400 ;demo of grain size
43 i 1 42 20 50 50 0.02 0.02 100 5000 ;demo of changing formant
44 e
45 </CsScore>
46 </CsoundSynthesizer>
47 ;example by Iain McCurdy