Debian Codegraph @

src/Examples/CsoundQt/Synths/Mono_Synth.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 </CsOptions>
4 <CsInstruments>
5
6 ; A monophonic legato instrument, playable from a MIDI keyboard.
7 ; By Jim Aikin, based on a method suggested by Victor Lazzarini.
8
9 sr = 44100
10 ksmps = 4
11 nchnls = 2
12 0dbfs = 1
13
14 alwayson "ToneGenerator"
15 giSaw ftgen 0, 0, 8192, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
16
17 gkCheck init 0
18 gkPitch init 260
19
20 instr 1 ; activated from MIDI channel 1, tracks the pitch
21 gkPitch cpsmidib 2
22 gkCheck = 1
23 endin
24
25 instr ToneGenerator
26
27 kon active 1 ; check whether any instances of instr 1 are active
28
29 ; velocity sensing -- only accept a new velocity input if
30 ; there's no note overlap (if kon == 1) -- scale the velocity
31 ; to a range of 0.2 - 1.0
32 kvel init 0
33 kstatus, kchan, kdata1, kdata2 midiin
34 if kstatus == 144 && kdata2 != 0 && kon == 1 then
35 kvel = kdata2 * 0.006 + 0.2
36 endif
37
38 katt invalue "att"
39 krel invalue "rel"
40 ; amplitude control
41 kampraw init 0
42 if kon != 0 then
43 kampraw = 0.5 * kvel
44 kenvramp = katt ; 50 = fast attack
45 else
46 kampraw = 0
47 kenvramp = krel ; 1 = slow release
48 endif
49 kamp tonek kampraw, kenvramp
50
51 kpitchglide invalue "pitchglide"
52 ipitchglide = 4 ; higher numbers cause faster glide
53 kpitch tonek gkPitch, kpitchglide
54
55 ; oscillators
56 idetune = 0.3
57 asig1 oscil kamp, kpitch + idetune, giSaw
58 asig2 oscil kamp, kpitch, giSaw
59 asig3 oscil kamp, kpitch - idetune, giSaw
60 asig = asig1 + asig2 + asig3
61
62 ; if no MIDI keys are pressed, reinit the filter envelope
63 if gkCheck == 1 && kon == 0 then
64 reinit filtenv
65 endif
66
67 ifiltdec1 = 1.5
68 ifiltdec2 = 3
69 filtenv:
70 kfilt expseg 500, 0.01, 8000, ifiltdec1, 2000, ifiltdec2, 500, 1, 500
71 rireturn
72
73 ; smooth the filter envelope so a reinit won't cause it to jump --
74 ; also have the cutoff track the keyboard and velocity
75 kfilt tonek (kfilt * (0.6 + kvel * 0.5)) + kpitch, kenvramp
76
77 afilt lpf18 asig, kfilt, 0.3, 0.1
78
79 outs afilt, afilt
80 endin
81
82 </CsInstruments>
83 <CsScore>
84
85 e 3600
86
87 </CsScore>
88 </CsoundSynthesizer><bsbPanel>
89 <label>Widgets</label>
90 <objectName/>
91 <x>198</x>
92 <y>290</y>
93 <width>352</width>
94 <height>212</height>
95 <visible>true</visible>
96 <uuid/>
97 <bgcolor mode="background">
98 <r>85</r>
99 <g>170</g>
100 <b>127</b>
101 </bgcolor>
102 <bsbObject version="2" type="BSBVSlider">
103 <objectName>att</objectName>
104 <x>60</x>
105 <y>49</y>
106 <width>20</width>
107 <height>100</height>
108 <uuid>{d9bc8180-98f8-400a-978c-9bedbbee8c34}</uuid>
109 <visible>true</visible>
110 <midichan>0</midichan>
111 <midicc>0</midicc>
112 <minimum>1.00000000</minimum>
113 <maximum>80.00000000</maximum>
114 <value>1.00000000</value>
115 <mode>lin</mode>
116 <mouseControl act="jump">continuous</mouseControl>
117 <resolution>-1.00000000</resolution>
118 <randomizable group="0">false</randomizable>
119 </bsbObject>
120 <bsbObject version="2" type="BSBLabel">
121 <objectName/>
122 <x>29</x>
123 <y>147</y>
124 <width>80</width>
125 <height>25</height>
126 <uuid>{e887fef3-be7e-47c6-b2d5-ef5761197823}</uuid>
127 <visible>true</visible>
128 <midichan>0</midichan>
129 <midicc>0</midicc>
130 <label>Attack</label>
131 <alignment>center</alignment>
132 <font>Arial</font>
133 <fontsize>10</fontsize>
134 <precision>3</precision>
135 <color>
136 <r>0</r>
137 <g>0</g>
138 <b>0</b>
139 </color>
140 <bgcolor mode="nobackground">
141 <r>255</r>
142 <g>255</g>
143 <b>255</b>
144 </bgcolor>
145 <bordermode>noborder</bordermode>
146 <borderradius>1</borderradius>
147 <borderwidth>1</borderwidth>
148 </bsbObject>
149 <bsbObject version="2" type="BSBVSlider">
150 <objectName>rel</objectName>
151 <x>117</x>
152 <y>49</y>
153 <width>20</width>
154 <height>100</height>
155 <uuid>{1b8f2ec1-d0d8-4f4f-905e-cc302929c6c5}</uuid>
156 <visible>true</visible>
157 <midichan>0</midichan>
158 <midicc>0</midicc>
159 <minimum>1.00000000</minimum>
160 <maximum>50.00000000</maximum>
161 <value>47.06000000</value>
162 <mode>lin</mode>
163 <mouseControl act="jump">continuous</mouseControl>
164 <resolution>-1.00000000</resolution>
165 <randomizable group="0">false</randomizable>
166 </bsbObject>
167 <bsbObject version="2" type="BSBLabel">
168 <objectName/>
169 <x>86</x>
170 <y>147</y>
171 <width>80</width>
172 <height>25</height>
173 <uuid>{695caaa8-f252-4487-8e9b-97cd19647a41}</uuid>
174 <visible>true</visible>
175 <midichan>0</midichan>
176 <midicc>0</midicc>
177 <label>Release</label>
178 <alignment>center</alignment>
179 <font>Arial</font>
180 <fontsize>10</fontsize>
181 <precision>3</precision>
182 <color>
183 <r>0</r>
184 <g>0</g>
185 <b>0</b>
186 </color>
187 <bgcolor mode="nobackground">
188 <r>255</r>
189 <g>255</g>
190 <b>255</b>
191 </bgcolor>
192 <bordermode>noborder</bordermode>
193 <borderradius>1</borderradius>
194 <borderwidth>1</borderwidth>
195 </bsbObject>
196 <bsbObject version="2" type="BSBLabel">
197 <objectName/>
198 <x>248</x>
199 <y>128</y>
200 <width>80</width>
201 <height>25</height>
202 <uuid>{1602d8a5-715e-4794-9c95-29d8487b60de}</uuid>
203 <visible>true</visible>
204 <midichan>0</midichan>
205 <midicc>0</midicc>
206 <label>Slow</label>
207 <alignment>left</alignment>
208 <font>Arial</font>
209 <fontsize>10</fontsize>
210 <precision>3</precision>
211 <color>
212 <r>0</r>
213 <g>0</g>
214 <b>0</b>
215 </color>
216 <bgcolor mode="nobackground">
217 <r>255</r>
218 <g>255</g>
219 <b>255</b>
220 </bgcolor>
221 <bordermode>noborder</bordermode>
222 <borderradius>1</borderradius>
223 <borderwidth>1</borderwidth>
224 </bsbObject>
225 <bsbObject version="2" type="BSBLabel">
226 <objectName/>
227 <x>247</x>
228 <y>49</y>
229 <width>80</width>
230 <height>25</height>
231 <uuid>{c2aa0e27-472b-4b75-ba40-2537fe6d3082}</uuid>
232 <visible>true</visible>
233 <midichan>0</midichan>
234 <midicc>0</midicc>
235 <label>Fast</label>
236 <alignment>left</alignment>
237 <font>Arial</font>
238 <fontsize>10</fontsize>
239 <precision>3</precision>
240 <color>
241 <r>0</r>
242 <g>0</g>
243 <b>0</b>
244 </color>
245 <bgcolor mode="nobackground">
246 <r>255</r>
247 <g>255</g>
248 <b>255</b>
249 </bgcolor>
250 <bordermode>noborder</bordermode>
251 <borderradius>1</borderradius>
252 <borderwidth>1</borderwidth>
253 </bsbObject>
254 <bsbObject version="2" type="BSBLabel">
255 <objectName/>
256 <x>257</x>
257 <y>72</y>
258 <width>10</width>
259 <height>60</height>
260 <uuid>{158e8a3a-a4e1-4bc2-b32e-017d6b7109c1}</uuid>
261 <visible>true</visible>
262 <midichan>0</midichan>
263 <midicc>0</midicc>
264 <label/>
265 <alignment>left</alignment>
266 <font>Arial</font>
267 <fontsize>10</fontsize>
268 <precision>3</precision>
269 <color>
270 <r>0</r>
271 <g>0</g>
272 <b>0</b>
273 </color>
274 <bgcolor mode="background">
275 <r>0</r>
276 <g>0</g>
277 <b>0</b>
278 </bgcolor>
279 <bordermode>border</bordermode>
280 <borderradius>1</borderradius>
281 <borderwidth>1</borderwidth>
282 </bsbObject>
283 <bsbObject version="2" type="BSBVSlider">
284 <objectName>pitchglide</objectName>
285 <x>195</x>
286 <y>49</y>
287 <width>20</width>
288 <height>100</height>
289 <uuid>{dc0d7428-b329-44e8-afb4-b76a0b5b734c}</uuid>
290 <visible>true</visible>
291 <midichan>0</midichan>
292 <midicc>0</midicc>
293 <minimum>1.00000000</minimum>
294 <maximum>50.00000000</maximum>
295 <value>16.68000000</value>
296 <mode>lin</mode>
297 <mouseControl act="jump">continuous</mouseControl>
298 <resolution>-1.00000000</resolution>
299 <randomizable group="0">false</randomizable>
300 </bsbObject>
301 <bsbObject version="2" type="BSBLabel">
302 <objectName/>
303 <x>164</x>
304 <y>147</y>
305 <width>80</width>
306 <height>25</height>
307 <uuid>{73ffdd1b-bc20-4c21-8442-35b5c04dba11}</uuid>
308 <visible>true</visible>
309 <midichan>0</midichan>
310 <midicc>0</midicc>
311 <label>Glide</label>
312 <alignment>center</alignment>
313 <font>Arial</font>
314 <fontsize>10</fontsize>
315 <precision>3</precision>
316 <color>
317 <r>0</r>
318 <g>0</g>
319 <b>0</b>
320 </color>
321 <bgcolor mode="nobackground">
322 <r>255</r>
323 <g>255</g>
324 <b>255</b>
325 </bgcolor>
326 <bordermode>noborder</bordermode>
327 <borderradius>1</borderradius>
328 <borderwidth>1</borderwidth>
329 </bsbObject>
330 </bsbPanel>
331 <bsbPresets>
332 </bsbPresets>
333 <MacOptions>
334 Version: 3
335 Render: Real
336 Ask: Yes
337 Functions: ioObject
338 Listing: Window
339 WindowBounds: 72 179 400 200
340 CurrentView: io
341 IOViewEdit: On
342 Options:
343 </MacOptions>
344
345 <MacGUI>
346 ioView background {21845, 43690, 32639}
347 ioSlider {60, 49} {20, 100} 1.000000 80.000000 1.000000 att
348 ioText {176, 172} {80, 25} label 0.000000 0.00100 "" center "Arial" 10 {0, 0, 0} {61440, 60160, 57856} nobackground noborder Attack
349 ioSlider {117, 49} {20, 100} 1.000000 50.000000 47.060000 rel
350 ioText {225, 164} {80, 25} label 0.000000 0.00100 "" center "Arial" 10 {0, 0, 0} {61440, 60160, 57856} nobackground noborder Release
351 ioText {199, 116} {80, 25} label 0.000000 0.00100 "" left "Arial" 10 {0, 0, 0} {61440, 60160, 57856} nobackground noborder Slow
352 ioText {173, 35} {80, 25} label 0.000000 0.00100 "" left "Arial" 10 {0, 0, 0} {61440, 60160, 57856} nobackground noborder Fast
353 ioText {183, 56} {10, 60} label 0.000000 0.00100 "" left "Arial" 10 {0, 0, 0} {0, 0, 0} nobackground noborder
354 ioSlider {195, 49} {20, 100} 1.000000 50.000000 16.680000 pitchglide
355 ioText {164, 147} {80, 25} label 0.000000 0.00100 "" center "Arial" 10 {0, 0, 0} {61440, 60160, 57856} nobackground noborder Glide
356 </MacGUI>