Debian Codegraph @

examples/tablecopy.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 ; Select audio/midi flags here according to platform
4 -odac ;;;realtime audio out
5 ;-iadc ;;;uncomment -iadc if realtime audio input is needed too
6 ; For Non-realtime ouput leave only the line below:
7 ; -o tablecopy.wav -W ;;; for file output any platform
8 </CsOptions>
9 <CsInstruments>
10
11 sr = 44100
12 ksmps = 32
13 nchnls = 2
14 0dbfs = 1
15 ;after an example from Jonathan Murphy
16
17 gilen = 7
18 gilist ftgen 1, 0, gilen + 1, -2, 2, 3, 4, 5, 6, 7 ;only 6 elements, so 1 is doubled
19 gitmp ftgen 2, 0, gilen + 1, -2, 0 ;empty table
20 gkmax init gilen
21
22 seed 0 ;each time different
23
24 instr 1
25
26 ktrig metro 3 ;trigger values
27 krnd random 0, gkmax
28
29 if (ktrig == 1) then
30 kval table krnd, gilist
31 tablew 0, krnd, gilist
32 kread = 0
33 kwrite = 0
34 start:
35 knew table kread, gilist
36 if (knew != 0) then
37 tablew knew, kwrite, gitmp
38 kwrite = kwrite + 1
39 endif
40 kread = kread + 1
41 if (kread <= gilen) kgoto start
42 tablecopy gilist, gitmp ;fill with zeroes
43 gkmax = gkmax - 1
44 endif
45
46 printk2 kval
47
48 if (gkmax < 0) then
49 event "i", 2, 0, 1/kr ;when ready, then stop
50 endif
51
52 asig vco2 .5, 40*kval ;sound generation
53 outs asig, asig
54
55 endin
56
57 instr 2
58
59 exitnow
60
61 endin
62 </CsInstruments>
63 <CsScore>
64 i1 0 5
65 e
66 </CsScore>
67 </CsoundSynthesizer>
68