Debian Codegraph @

examples/splitrig.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 -odac -d -m0
4 </CsOptions>
5 <CsInstruments>
6
7 ; By Stefano Cucchi & Menno Knevel - 2020
8
9 sr = 44100
10 ksmps = 32
11 nchnls = 2
12 0dbfs = 1
13
14 ; table with values
15 ; 4 lines = 4 kout triggers
16 ; 4 rows = number of tics for every pattern (imaxtics)
17 gi1 ftgen 1, 0, 1024, -2, ; Table is generated with GEN02
18 \ ; Every column represent a kout trigger
19 4, \ ; define # of rows of numtics of pattern 0 == index 0
20 \; k1, k2, k3, k4
21 2, 3, 4, 5,\
22 3, 4, 5, 5,\
23 4, 10, 10, 3,\
24 5, 2, 10, 4,\
25 \
26 4, \ ; define # of rows of numtics of pattern 1 == index 1
27 \; k1, k2, k3, k4
28 6, 10, 7, 8,\
29 8, 6, 7, 8,\
30 8, 6, 10, 8,\
31 9, 6, 10, 8
32
33 instr 1
34
35 ktrig metro 4 ; general trigger
36 ; initialize out triggers
37 k1 init 0
38 k2 init 0
39 k3 init 0
40 k4 init 0
41 kndx = p4 ;choose pattern 0 or 1
42 imaxtics = 4 ; number of tics
43 ifn = 1
44 splitrig ktrig, kndx, imaxtics, ifn, k1, k2, k3, k4
45 if (p5 == 1) then
46 schedkwhen ktrig, 0, 1, k1, 0, .1 ; 1st column
47 elseif (p5 == 2) then
48 schedkwhen ktrig, 0, 1, k2, 0, .1 ; 2nd column
49 elseif (p5 == 3) then
50 schedkwhen ktrig, 0, 1, k3, 0, .1 ; 3rd column
51 elseif (p5 == 4) then
52 schedkwhen ktrig, 0, 1, k4, 0, .1 ; 4th column
53 endif
54 print p5
55 endin
56
57 instr 2
58
59 prints "instr 2\n"
60 ares linen .3, 0.02, p3, .05 ;envelope
61 aout poscil ares, 200
62 outs aout, aout
63 endin
64
65 instr 3
66
67 prints "instr 3\n"
68 ares linen .3, 0.02, p3, .05
69 aout poscil ares, 300
70 outs aout, aout
71 endin
72
73 instr 4
74
75 prints "instr 4\n"
76 ares linen .3, 0.02, p3, .05
77 aout poscil ares, 400
78 outs aout, aout
79 endin
80
81 instr 5
82
83 prints "instr 5\n"
84 ares linen .3, 0.02, p3, .05
85 aout poscil ares, 500
86 outs aout, aout
87 endin
88
89 instr 6
90
91 prints "instr 6\n"
92 ares linen .3, 0.02, p3, .05
93 aout poscil ares, 1500
94 outs aout, aout
95 endin
96
97 instr 7
98
99 prints "instr 7\n"
100 ares linen .3, 0.02, p3, .05
101 aout poscil ares, 2000
102 outs aout, aout
103 endin
104
105 instr 8
106
107 prints "instr 8\n"
108 ares linen .3, 0.02, p3, .05
109 aout poscil ares, 2500
110 outs aout, aout
111 endin
112
113 instr 9
114
115 prints "instr 9\n"
116 ares linen .3, 0.02, p3, .05
117 aout poscil ares, 3000
118 outs aout, aout
119 endin
120
121 instr 10 ; dummy instrument
122
123 prints "instr 10\n"
124 ; silence
125 endin
126
127 </CsInstruments>
128 <CsScore>
129 s
130 i 1 0 4 0 1 ; play the 4 columns of pattern 0
131 i 1 + 4 0 2
132 i 1 + 4 0 3
133 i 1 + 4 0 4
134 s
135 i 1 0 4 1 1 ; play the 4 colums of pattern 1
136 i 1 + 4 1 2
137 i 1 + 4 1 3
138 i 1 + 4 1 4
139 e
140 </CsScore>
141 </CsoundSynthesizer>