Debian Codegraph @

src/Examples/McCurdy Collection/LiveAudioIn/follow2gate.csd

raw
1 ;Written by Iain McCurdy, 2006
2
3 ; Modified for QuteCsound by René, January 2011
4 ; Tested on Ubuntu 10.04 with csound-float 5.13.0 January 2011 and QuteCsound svn rev 817
5
6
7 ;Notes on modifications from original csd:
8 ; Add table(s) for exp slider
9
10
11 ;my flags on Ubuntu: -dm0 -iadc -odac -+rtaudio=jack -b16 -B4096 --expression-opt -+rtmidi=null
12 <CsoundSynthesizer>
13 <CsOptions>
14
15 </CsOptions>
16 <CsInstruments>
17 sr = 44100 ;SAMPLE RATE
18 ksmps = 16 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
19 nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
20 0dbfs = 1 ;MAXIMUM AMPLITUDE REGARDLESS OF BIT DEPTH
21
22
23 giExp1 ftgen 0, 0, 129, -25, 0, 0.0001, 128, 1.0 ;TABLE FOR EXP SLIDER
24
25
26 instr 1
27 kgain invalue "Gain"
28 katt invalue "Attack"
29 krel invalue "Release"
30 kthresh invalue "Threshold"
31 kthresh tablei kthresh, giExp1, 1
32 outvalue "Threshold_Value", kthresh
33
34 aL, aR ins ;READ STEREO INPUT
35 aL = aL * kgain ;AUDIO SIGNALS ARE SCALED BY THE FLTK GAIN CONTROL
36 aR = aR * kgain ;AUDIO SIGNALS ARE SCALED BY THE FLTK GAIN CONTROL
37 afollow follow2 aL, katt, krel ;CREATE A AMPLITUDE FOLLOWING UNIPOLAR SIGNAL
38 kfollow downsamp afollow ;DOWNSAMPLE TO CREATE A K-RATE VERSION OF THE AMPLITUDE FOLLOWING SIGNAL
39 kmeter portk kfollow, .05 ;SMOOTH THE MOVEMENT OF THE AMPLITUDE FOLLOWING SIGNAL - THIS WILL MAKE THE METERS EASIER TO VIEW
40 ktrig changed kmeter ;IF THE AMPLIUDE FOLLOWING SIGNAL CHANGES GENERATE A TRIGGER SIGNAL (A MOMENTARY '1' VALUE)
41 if ktrig == 1 then
42 outvalue "Meter", kmeter ;UPDATE AMPLITUDE METER
43 endif
44
45 kgate = (kfollow < kthresh?0:1) ;CREATE A GATE SIGNAL (EITHER 1 OR ZERO DEPENDING UPON COMPARISON WITH THE THRESHOLD VALUE
46 kgate port kgate,.01 ;SMOOTH THE OPENING AND CLOSING OF THE GATE TO PREVENT CLICKS
47 outs aL*kgate, aR*kgate ;SEND AUDIO TO THE OUTPUTS AND APPLY THE GATING SIGNAL
48 endin
49 </CsInstruments>
50 <CsScore>
51 ;INSTR | START | DURATION
52 i 1 0 3600 ;INSTRUMENT 1 PLAYS FOR 1 HOUR (AND KEEPS PERFORMANCE GOING)
53 </CsScore>
54 </CsoundSynthesizer>
55
56 <bsbPanel>
57 <label>Widgets</label>
58 <objectName/>
59 <x>72</x>
60 <y>179</y>
61 <width>400</width>
62 <height>200</height>
63 <visible>true</visible>
64 <uuid/>
65 <bgcolor mode="background">
66 <r>241</r>
67 <g>226</g>
68 <b>185</b>
69 </bgcolor>
70 <bsbObject version="2" type="BSBLabel">
71 <objectName/>
72 <x>2</x>
73 <y>2</y>
74 <width>512</width>
75 <height>238</height>
76 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
77 <visible>true</visible>
78 <midichan>0</midichan>
79 <midicc>0</midicc>
80 <label>follow2 gate</label>
81 <alignment>center</alignment>
82 <font>Liberation Sans</font>
83 <fontsize>18</fontsize>
84 <precision>3</precision>
85 <color>
86 <r>0</r>
87 <g>0</g>
88 <b>0</b>
89 </color>
90 <bgcolor mode="background">
91 <r>158</r>
92 <g>220</g>
93 <b>158</b>
94 </bgcolor>
95 <bordermode>border</bordermode>
96 <borderradius>5</borderradius>
97 <borderwidth>2</borderwidth>
98 </bsbObject>
99 <bsbObject version="2" type="BSBLabel">
100 <objectName/>
101 <x>8</x>
102 <y>64</y>
103 <width>100</width>
104 <height>30</height>
105 <uuid>{2c897206-0dbc-47b5-ba68-915d83839ab6}</uuid>
106 <visible>true</visible>
107 <midichan>0</midichan>
108 <midicc>0</midicc>
109 <label>Input Gain Control</label>
110 <alignment>left</alignment>
111 <font>Liberation Sans</font>
112 <fontsize>10</fontsize>
113 <precision>3</precision>
114 <color>
115 <r>0</r>
116 <g>0</g>
117 <b>0</b>
118 </color>
119 <bgcolor mode="nobackground">
120 <r>255</r>
121 <g>255</g>
122 <b>255</b>
123 </bgcolor>
124 <bordermode>noborder</bordermode>
125 <borderradius>1</borderradius>
126 <borderwidth>1</borderwidth>
127 </bsbObject>
128 <bsbObject version="2" type="BSBHSlider">
129 <objectName>Gain</objectName>
130 <x>8</x>
131 <y>47</y>
132 <width>500</width>
133 <height>27</height>
134 <uuid>{304e78d8-b320-453a-b28f-86b0ca872b86}</uuid>
135 <visible>true</visible>
136 <midichan>0</midichan>
137 <midicc>0</midicc>
138 <minimum>0.00000000</minimum>
139 <maximum>5.00000000</maximum>
140 <value>0.65000000</value>
141 <mode>lin</mode>
142 <mouseControl act="jump">continuous</mouseControl>
143 <resolution>-1.00000000</resolution>
144 <randomizable group="0">false</randomizable>
145 </bsbObject>
146 <bsbObject version="2" type="BSBDisplay">
147 <objectName>Gain</objectName>
148 <x>448</x>
149 <y>64</y>
150 <width>60</width>
151 <height>30</height>
152 <uuid>{94c7e961-7981-4d21-942f-80bcc647daf5}</uuid>
153 <visible>true</visible>
154 <midichan>0</midichan>
155 <midicc>0</midicc>
156 <label>0.650</label>
157 <alignment>right</alignment>
158 <font>Liberation Sans</font>
159 <fontsize>9</fontsize>
160 <precision>3</precision>
161 <color>
162 <r>0</r>
163 <g>0</g>
164 <b>0</b>
165 </color>
166 <bgcolor mode="nobackground">
167 <r>255</r>
168 <g>255</g>
169 <b>255</b>
170 </bgcolor>
171 <bordermode>noborder</bordermode>
172 <borderradius>1</borderradius>
173 <borderwidth>1</borderwidth>
174 </bsbObject>
175 <bsbObject version="2" type="BSBLabel">
176 <objectName/>
177 <x>516</x>
178 <y>2</y>
179 <width>489</width>
180 <height>238</height>
181 <uuid>{cebe7e5c-304d-4db6-8da2-0e27c0616bab}</uuid>
182 <visible>true</visible>
183 <midichan>0</midichan>
184 <midicc>0</midicc>
185 <label>follow2 gate</label>
186 <alignment>center</alignment>
187 <font>Liberation Sans</font>
188 <fontsize>18</fontsize>
189 <precision>3</precision>
190 <color>
191 <r>0</r>
192 <g>0</g>
193 <b>0</b>
194 </color>
195 <bgcolor mode="background">
196 <r>158</r>
197 <g>220</g>
198 <b>158</b>
199 </bgcolor>
200 <bordermode>border</bordermode>
201 <borderradius>5</borderradius>
202 <borderwidth>2</borderwidth>
203 </bsbObject>
204 <bsbObject version="2" type="BSBLabel">
205 <objectName/>
206 <x>520</x>
207 <y>22</y>
208 <width>480</width>
209 <height>213</height>
210 <uuid>{c24a85f3-363e-476e-81da-37729ad65bb7}</uuid>
211 <visible>true</visible>
212 <midichan>0</midichan>
213 <midicc>0</midicc>
214 <label>---------------------------------------------------------------------------------------------------------------------
215 In this example follow2 is used to implement a simple audio gate.
216 An amplitude following signal is created and then continuously compared with a threshold value (defined by the 'Threshold' slider).
217 If signal amplitude is above the threshold value then the signal passes through the gate unaffected, if signal amplitude is below the threshold value then the gate closes and no signal passes through.
218 An amplitude meter is included to give visual confirmation of the gates functioning.
219 The left channel input only is scanned by the gate but the gate is subsequently applied to both channels.</label>
220 <alignment>left</alignment>
221 <font>Liberation Sans</font>
222 <fontsize>14</fontsize>
223 <precision>3</precision>
224 <color>
225 <r>0</r>
226 <g>0</g>
227 <b>0</b>
228 </color>
229 <bgcolor mode="nobackground">
230 <r>158</r>
231 <g>220</g>
232 <b>158</b>
233 </bgcolor>
234 <bordermode>noborder</bordermode>
235 <borderradius>1</borderradius>
236 <borderwidth>1</borderwidth>
237 </bsbObject>
238 <bsbObject version="2" type="BSBController">
239 <objectName>Meter</objectName>
240 <x>8</x>
241 <y>204</y>
242 <width>500</width>
243 <height>12</height>
244 <uuid>{62c7b289-2e6d-4604-bb01-e3cfe5d79438}</uuid>
245 <visible>true</visible>
246 <midichan>0</midichan>
247 <midicc>0</midicc>
248 <objectName2/>
249 <xMin>0.00000000</xMin>
250 <xMax>1.00000000</xMax>
251 <yMin>0.00000000</yMin>
252 <yMax>1.00000000</yMax>
253 <xValue>0.06994184</xValue>
254 <yValue>0.00000000</yValue>
255 <type>fill</type>
256 <pointsize>1</pointsize>
257 <fadeSpeed>0.00000000</fadeSpeed>
258 <mouseControl act="press">jump</mouseControl>
259 <color>
260 <r>255</r>
261 <g>0</g>
262 <b>0</b>
263 </color>
264 <randomizable mode="both" group="0">false</randomizable>
265 <bgcolor>
266 <r>0</r>
267 <g>0</g>
268 <b>0</b>
269 </bgcolor>
270 </bsbObject>
271 <bsbObject version="2" type="BSBLabel">
272 <objectName/>
273 <x>8</x>
274 <y>216</y>
275 <width>100</width>
276 <height>30</height>
277 <uuid>{f7011b01-1101-41a8-93aa-41ed4e46adc6}</uuid>
278 <visible>true</visible>
279 <midichan>0</midichan>
280 <midicc>0</midicc>
281 <label>Meter</label>
282 <alignment>left</alignment>
283 <font>Liberation Sans</font>
284 <fontsize>10</fontsize>
285 <precision>3</precision>
286 <color>
287 <r>0</r>
288 <g>0</g>
289 <b>0</b>
290 </color>
291 <bgcolor mode="nobackground">
292 <r>255</r>
293 <g>255</g>
294 <b>255</b>
295 </bgcolor>
296 <bordermode>noborder</bordermode>
297 <borderradius>1</borderradius>
298 <borderwidth>1</borderwidth>
299 </bsbObject>
300 <bsbObject version="2" type="BSBLabel">
301 <objectName/>
302 <x>8</x>
303 <y>100</y>
304 <width>100</width>
305 <height>30</height>
306 <uuid>{63ab529c-3f14-4886-8215-fd6e8f1a37ce}</uuid>
307 <visible>true</visible>
308 <midichan>0</midichan>
309 <midicc>0</midicc>
310 <label>Attack Time</label>
311 <alignment>left</alignment>
312 <font>Liberation Sans</font>
313 <fontsize>10</fontsize>
314 <precision>3</precision>
315 <color>
316 <r>0</r>
317 <g>0</g>
318 <b>0</b>
319 </color>
320 <bgcolor mode="nobackground">
321 <r>255</r>
322 <g>255</g>
323 <b>255</b>
324 </bgcolor>
325 <bordermode>noborder</bordermode>
326 <borderradius>1</borderradius>
327 <borderwidth>1</borderwidth>
328 </bsbObject>
329 <bsbObject version="2" type="BSBHSlider">
330 <objectName>Attack</objectName>
331 <x>8</x>
332 <y>83</y>
333 <width>500</width>
334 <height>27</height>
335 <uuid>{a7c37920-a18a-446b-8b66-6a1119503da0}</uuid>
336 <visible>true</visible>
337 <midichan>0</midichan>
338 <midicc>0</midicc>
339 <minimum>0.00010000</minimum>
340 <maximum>2.00000000</maximum>
341 <value>0.00409980</value>
342 <mode>lin</mode>
343 <mouseControl act="jump">continuous</mouseControl>
344 <resolution>-1.00000000</resolution>
345 <randomizable group="0">false</randomizable>
346 </bsbObject>
347 <bsbObject version="2" type="BSBDisplay">
348 <objectName>Attack</objectName>
349 <x>448</x>
350 <y>100</y>
351 <width>60</width>
352 <height>30</height>
353 <uuid>{b453c0e4-809f-4074-94fd-506ebb68f3b8}</uuid>
354 <visible>true</visible>
355 <midichan>0</midichan>
356 <midicc>0</midicc>
357 <label>0.004</label>
358 <alignment>right</alignment>
359 <font>Liberation Sans</font>
360 <fontsize>9</fontsize>
361 <precision>3</precision>
362 <color>
363 <r>0</r>
364 <g>0</g>
365 <b>0</b>
366 </color>
367 <bgcolor mode="nobackground">
368 <r>255</r>
369 <g>255</g>
370 <b>255</b>
371 </bgcolor>
372 <bordermode>noborder</bordermode>
373 <borderradius>1</borderradius>
374 <borderwidth>1</borderwidth>
375 </bsbObject>
376 <bsbObject version="2" type="BSBLabel">
377 <objectName/>
378 <x>8</x>
379 <y>136</y>
380 <width>100</width>
381 <height>30</height>
382 <uuid>{760945fc-2052-4408-8344-abdb00ead7b0}</uuid>
383 <visible>true</visible>
384 <midichan>0</midichan>
385 <midicc>0</midicc>
386 <label>Release Time</label>
387 <alignment>left</alignment>
388 <font>Liberation Sans</font>
389 <fontsize>10</fontsize>
390 <precision>3</precision>
391 <color>
392 <r>0</r>
393 <g>0</g>
394 <b>0</b>
395 </color>
396 <bgcolor mode="nobackground">
397 <r>255</r>
398 <g>255</g>
399 <b>255</b>
400 </bgcolor>
401 <bordermode>noborder</bordermode>
402 <borderradius>1</borderradius>
403 <borderwidth>1</borderwidth>
404 </bsbObject>
405 <bsbObject version="2" type="BSBHSlider">
406 <objectName>Release</objectName>
407 <x>8</x>
408 <y>119</y>
409 <width>500</width>
410 <height>27</height>
411 <uuid>{d5b42e3d-c45f-4288-bb9c-16eb365124bc}</uuid>
412 <visible>true</visible>
413 <midichan>0</midichan>
414 <midicc>0</midicc>
415 <minimum>0.00010000</minimum>
416 <maximum>2.00000000</maximum>
417 <value>0.03609820</value>
418 <mode>lin</mode>
419 <mouseControl act="jump">continuous</mouseControl>
420 <resolution>-1.00000000</resolution>
421 <randomizable group="0">false</randomizable>
422 </bsbObject>
423 <bsbObject version="2" type="BSBDisplay">
424 <objectName>Release</objectName>
425 <x>448</x>
426 <y>136</y>
427 <width>60</width>
428 <height>30</height>
429 <uuid>{3837993c-b043-4b23-a36f-83ea6a2f2d2b}</uuid>
430 <visible>true</visible>
431 <midichan>0</midichan>
432 <midicc>0</midicc>
433 <label>0.036</label>
434 <alignment>right</alignment>
435 <font>Liberation Sans</font>
436 <fontsize>9</fontsize>
437 <precision>3</precision>
438 <color>
439 <r>0</r>
440 <g>0</g>
441 <b>0</b>
442 </color>
443 <bgcolor mode="nobackground">
444 <r>255</r>
445 <g>255</g>
446 <b>255</b>
447 </bgcolor>
448 <bordermode>noborder</bordermode>
449 <borderradius>1</borderradius>
450 <borderwidth>1</borderwidth>
451 </bsbObject>
452 <bsbObject version="2" type="BSBLabel">
453 <objectName/>
454 <x>8</x>
455 <y>172</y>
456 <width>100</width>
457 <height>30</height>
458 <uuid>{7e59b44f-2b3b-4941-9e17-c56369f9316a}</uuid>
459 <visible>true</visible>
460 <midichan>0</midichan>
461 <midicc>0</midicc>
462 <label>Gate Threshold</label>
463 <alignment>left</alignment>
464 <font>Liberation Sans</font>
465 <fontsize>10</fontsize>
466 <precision>3</precision>
467 <color>
468 <r>0</r>
469 <g>0</g>
470 <b>0</b>
471 </color>
472 <bgcolor mode="nobackground">
473 <r>255</r>
474 <g>255</g>
475 <b>255</b>
476 </bgcolor>
477 <bordermode>noborder</bordermode>
478 <borderradius>1</borderradius>
479 <borderwidth>1</borderwidth>
480 </bsbObject>
481 <bsbObject version="2" type="BSBHSlider">
482 <objectName>Threshold</objectName>
483 <x>8</x>
484 <y>155</y>
485 <width>500</width>
486 <height>27</height>
487 <uuid>{84d39e8a-7044-4434-92fd-919cc03f9d01}</uuid>
488 <visible>true</visible>
489 <midichan>0</midichan>
490 <midicc>0</midicc>
491 <minimum>0.00000000</minimum>
492 <maximum>1.00000000</maximum>
493 <value>0.75000000</value>
494 <mode>lin</mode>
495 <mouseControl act="jump">continuous</mouseControl>
496 <resolution>-1.00000000</resolution>
497 <randomizable group="0">false</randomizable>
498 </bsbObject>
499 <bsbObject version="2" type="BSBDisplay">
500 <objectName>Threshold_Value</objectName>
501 <x>448</x>
502 <y>172</y>
503 <width>60</width>
504 <height>30</height>
505 <uuid>{a4a174c2-d21c-4f3b-a485-d396bc7e9495}</uuid>
506 <visible>true</visible>
507 <midichan>0</midichan>
508 <midicc>0</midicc>
509 <label>0.100</label>
510 <alignment>right</alignment>
511 <font>Liberation Sans</font>
512 <fontsize>9</fontsize>
513 <precision>3</precision>
514 <color>
515 <r>0</r>
516 <g>0</g>
517 <b>0</b>
518 </color>
519 <bgcolor mode="nobackground">
520 <r>255</r>
521 <g>255</g>
522 <b>255</b>
523 </bgcolor>
524 <bordermode>noborder</bordermode>
525 <borderradius>1</borderradius>
526 <borderwidth>1</borderwidth>
527 </bsbObject>
528 </bsbPanel>
529 <bsbPresets>
530 </bsbPresets>
531 <EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="true" loopStart="0" loopEnd="0"> </EventPanel>