Debian Codegraph @

src/Examples/McCurdy Collection/Reverbs/reverb.csd

raw
1 ;Written by Iain McCurdy, 2006
2
3 ;THE REVERB OPCODE IS PLACED IN A SEPARATE, ALWAYS ON, INSTRUMENT FROM THE SOURCE SOUND PRODUCING INSTRUMENT.
4 ;THE IS A COMMONLY USED TECHNIQUE WITH TIME SMEARING OPCODES AND EFFECTS LIKE REVERBS AND DELAYS.
5
6
7 ;Modified for QuteCsound by René, April 2011
8 ;Tested on Ubuntu 10.04 with csound-float 5.13.0 and QuteCsound svn rev 817
9
10 ;Notes on modifications from original csd:
11 ; Add Browser for audio file and use of FilePlay2 udo, now accept mono or stereo wav files
12
13
14 ;Reverb structure:
15
16 ; +----+
17 ; +-|comb|-+
18 ; | +----+ |
19 ; + +
20 ; | +----+ |
21 ; +-|comb|-+
22 ; | +----+ | +------+ +------+
23 ; IN-->| |-|alpass|-|alpass|-->OUT
24 ; | +----+ | +------+ +------+
25 ; +-|comb|-+
26 ; | +----+ |
27 ; | |
28 ; | +----+ |
29 ; +-|comb|-+
30 ; +----+
31
32
33 ;my flags on Ubuntu: -iadc -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=null -m0
34 <CsoundSynthesizer>
35 <CsOptions>
36 --env:SSDIR+=../../SourceMaterials
37 </CsOptions>
38 <CsInstruments>
39 sr = 44100 ;SAMPLE RATE
40 ksmps = 100 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
41 nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
42
43
44 opcode FilePlay2, aa, Skoo ; Credit to Joachim Heintz
45 ;gives stereo output regardless your soundfile is mono or stereo
46 Sfil, kspeed, iskip, iloop xin
47 ichn filenchnls Sfil
48 if ichn == 1 then
49 aL diskin2 Sfil, kspeed, iskip, iloop
50 aR = aL
51 else
52 aL, aR diskin2 Sfil, kspeed, iskip, iloop
53 endif
54 xout aL, aR
55 endop
56
57
58 instr 10 ;GUI
59 ktrig metro 10
60 if (ktrig == 1) then
61 gkingain invalue "LiveGain"
62 gkmix invalue "Mix"
63 gkrvbtime invalue "ReverbTime"
64 gkinput invalue "Input"
65 endif
66 endin
67
68 instr 1 ;PLAYS FILE AND OUTPUTS GLOBAL VARIABLES
69 if gkinput==0 then ;IF FILE INPUT IS SELECTED...
70 Sfile invalue "_Browse1"
71 gasigL, gasigR FilePlay2 Sfile, 1, 0, 1 ;GENERATE 2 AUDIO SIGNALS FROM A SOUND FILE (NOTE THE USE OF GLOBAL VARIABLES)
72 else ;OTHERWISE
73 asigL, asigR ins ;TAKE INPUT FROM COMPUTER'S AUDIO INPUT
74 gasigL = asigL * gkingain ;SCALE USING 'Input Gain' SLIDER
75 gasigR = asigR * gkingain ;SCALE USING 'Input Gain' SLIDER
76 endif ;END OF CONDITIONAL BRANCHING
77 endin
78
79 instr 2 ;REVERBERATING INSTRUMENT
80 aRvbL reverb gasigL*.3, gkrvbtime ;CREATE LEFT CHANNEL REVERB
81 aRvbR reverb gasigR*.3, gkrvbtime ;CREATE RIGHT CHANNEL REVERB
82 outs (aRvbL*gkmix*.5)+(gasigL*(1-gkmix)), (aRvbR*gkmix*.5)+(gasigR*(1-gkmix)) ;MIX SOURCE SIGNAL AND REVERB SIGNAL AT THE OUTPUT AND IMPLEMENT WET/DRY CONTROL USING THE FLTK SLIDER VARIABLE gkmix
83 clear gasigL, gasigR ;CLEAR GLOBAL AUDIO VARIABLES
84 endin
85 </CsInstruments>
86 <CsScore>
87 ;INSTR | START | DURATION
88 i 10 0.0 3600 ;GUI
89 i 2 0.0 3600 ;REVERB INSTRUMENT PLAYS FOR 1 HOUR (AND KEEPS PERFORMANCE GOING)
90 </CsScore>
91 </CsoundSynthesizer>
92 <bsbPanel>
93 <label>Widgets</label>
94 <objectName/>
95 <x>1</x>
96 <y>28</y>
97 <width>951</width>
98 <height>321</height>
99 <visible>true</visible>
100 <uuid/>
101 <bgcolor mode="background">
102 <r>241</r>
103 <g>226</g>
104 <b>185</b>
105 </bgcolor>
106 <bsbObject version="2" type="BSBLabel">
107 <objectName/>
108 <x>2</x>
109 <y>2</y>
110 <width>512</width>
111 <height>316</height>
112 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
113 <visible>true</visible>
114 <midichan>0</midichan>
115 <midicc>0</midicc>
116 <label>reverb</label>
117 <alignment>center</alignment>
118 <font>Liberation Sans</font>
119 <fontsize>18</fontsize>
120 <precision>3</precision>
121 <color>
122 <r>0</r>
123 <g>0</g>
124 <b>0</b>
125 </color>
126 <bgcolor mode="background">
127 <r>158</r>
128 <g>220</g>
129 <b>217</b>
130 </bgcolor>
131 <bordermode>border</bordermode>
132 <borderradius>5</borderradius>
133 <borderwidth>2</borderwidth>
134 </bsbObject>
135 <bsbObject version="2" type="BSBButton">
136 <objectName/>
137 <x>8</x>
138 <y>10</y>
139 <width>100</width>
140 <height>30</height>
141 <uuid>{487d5181-d838-4cce-9628-317fefc350cb}</uuid>
142 <visible>true</visible>
143 <midichan>0</midichan>
144 <midicc>0</midicc>
145 <type>event</type>
146 <pressedValue>1.00000000</pressedValue>
147 <stringvalue/>
148 <text> ON / OFF</text>
149 <image>/</image>
150 <eventLine>i 1 0 -1</eventLine>
151 <latch>true</latch>
152 <latched>false</latched>
153 </bsbObject>
154 <bsbObject version="2" type="BSBLabel">
155 <objectName/>
156 <x>8</x>
157 <y>72</y>
158 <width>120</width>
159 <height>30</height>
160 <uuid>{0200a063-5db8-4668-bc2d-2d989a083f6e}</uuid>
161 <visible>true</visible>
162 <midichan>0</midichan>
163 <midicc>0</midicc>
164 <label>Live input Gain</label>
165 <alignment>left</alignment>
166 <font>Liberation Sans</font>
167 <fontsize>10</fontsize>
168 <precision>3</precision>
169 <color>
170 <r>0</r>
171 <g>0</g>
172 <b>0</b>
173 </color>
174 <bgcolor mode="nobackground">
175 <r>255</r>
176 <g>255</g>
177 <b>255</b>
178 </bgcolor>
179 <bordermode>noborder</bordermode>
180 <borderradius>1</borderradius>
181 <borderwidth>1</borderwidth>
182 </bsbObject>
183 <bsbObject version="2" type="BSBDisplay">
184 <objectName>LiveGain</objectName>
185 <x>448</x>
186 <y>72</y>
187 <width>60</width>
188 <height>30</height>
189 <uuid>{ab191e3a-430d-4f1d-88aa-9840342cd2d3}</uuid>
190 <visible>true</visible>
191 <midichan>0</midichan>
192 <midicc>0</midicc>
193 <label>0.130</label>
194 <alignment>right</alignment>
195 <font>Liberation Sans</font>
196 <fontsize>9</fontsize>
197 <precision>3</precision>
198 <color>
199 <r>0</r>
200 <g>0</g>
201 <b>0</b>
202 </color>
203 <bgcolor mode="nobackground">
204 <r>255</r>
205 <g>255</g>
206 <b>255</b>
207 </bgcolor>
208 <bordermode>noborder</bordermode>
209 <borderradius>1</borderradius>
210 <borderwidth>1</borderwidth>
211 </bsbObject>
212 <bsbObject version="2" type="BSBLabel">
213 <objectName/>
214 <x>516</x>
215 <y>2</y>
216 <width>430</width>
217 <height>316</height>
218 <uuid>{74928ed2-b701-4668-9a11-74763d317e9b}</uuid>
219 <visible>true</visible>
220 <midichan>0</midichan>
221 <midicc>0</midicc>
222 <label>reverb</label>
223 <alignment>center</alignment>
224 <font>Liberation Sans</font>
225 <fontsize>18</fontsize>
226 <precision>3</precision>
227 <color>
228 <r>0</r>
229 <g>0</g>
230 <b>0</b>
231 </color>
232 <bgcolor mode="background">
233 <r>158</r>
234 <g>220</g>
235 <b>217</b>
236 </bgcolor>
237 <bordermode>border</bordermode>
238 <borderradius>5</borderradius>
239 <borderwidth>2</borderwidth>
240 </bsbObject>
241 <bsbObject version="2" type="BSBLabel">
242 <objectName/>
243 <x>519</x>
244 <y>22</y>
245 <width>427</width>
246 <height>293</height>
247 <uuid>{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}</uuid>
248 <visible>true</visible>
249 <midichan>0</midichan>
250 <midicc>0</midicc>
251 <label>-------------------------------------------------------------------------------------------------------
252 reverb is a basic reverberation unit. Within the opcode an algorithm consisting of four parallel comb filters and two series allpass filters is employed Its only obligatory input argument besides the input audio signal is for reverb time in seconds. An optional 2-way switch defines the initial disposition of the delay loop data (0=cleared, 1=previous data retained). It should be bourne in mind that the 'reverb' algorithm represents quite a basic reverb algorithm and that with transient input audio granularity in the reverb effect becomes quite evident. (0=no filtering, 1=more filtering) In this example a Dry/Wet Mix crossfader is also implemented.
253
254 In this example the user can choose between a sound file input or the computer's live input. An input gain control on the live input is also provided.</label>
255 <alignment>left</alignment>
256 <font>Liberation Sans</font>
257 <fontsize>14</fontsize>
258 <precision>3</precision>
259 <color>
260 <r>0</r>
261 <g>0</g>
262 <b>0</b>
263 </color>
264 <bgcolor mode="nobackground">
265 <r>255</r>
266 <g>255</g>
267 <b>255</b>
268 </bgcolor>
269 <bordermode>noborder</bordermode>
270 <borderradius>1</borderradius>
271 <borderwidth>1</borderwidth>
272 </bsbObject>
273 <bsbObject version="2" type="BSBDropdown">
274 <objectName>Input</objectName>
275 <x>180</x>
276 <y>215</y>
277 <width>120</width>
278 <height>30</height>
279 <uuid>{9b81a1f2-bcb8-4582-925b-9ae56def3865}</uuid>
280 <visible>true</visible>
281 <midichan>0</midichan>
282 <midicc>0</midicc>
283 <bsbDropdownItemList>
284 <bsbDropdownItem>
285 <name>Audio File</name>
286 <value>0</value>
287 <stringvalue/>
288 </bsbDropdownItem>
289 <bsbDropdownItem>
290 <name> Live Input</name>
291 <value>1</value>
292 <stringvalue/>
293 </bsbDropdownItem>
294 </bsbDropdownItemList>
295 <selectedIndex>0</selectedIndex>
296 <randomizable group="0">false</randomizable>
297 </bsbObject>
298 <bsbObject version="2" type="BSBLabel">
299 <objectName/>
300 <x>98</x>
301 <y>215</y>
302 <width>80</width>
303 <height>30</height>
304 <uuid>{62eeb695-9b83-42da-81cd-8000c232d9b9}</uuid>
305 <visible>true</visible>
306 <midichan>0</midichan>
307 <midicc>0</midicc>
308 <label>Input</label>
309 <alignment>right</alignment>
310 <font>Arial</font>
311 <fontsize>10</fontsize>
312 <precision>3</precision>
313 <color>
314 <r>0</r>
315 <g>0</g>
316 <b>0</b>
317 </color>
318 <bgcolor mode="nobackground">
319 <r>255</r>
320 <g>255</g>
321 <b>255</b>
322 </bgcolor>
323 <bordermode>noborder</bordermode>
324 <borderradius>1</borderradius>
325 <borderwidth>1</borderwidth>
326 </bsbObject>
327 <bsbObject version="2" type="BSBButton">
328 <objectName>_Browse1</objectName>
329 <x>8</x>
330 <y>252</y>
331 <width>170</width>
332 <height>30</height>
333 <uuid>{9b992da1-8c0f-449e-af03-7913cc05efed}</uuid>
334 <visible>true</visible>
335 <midichan>0</midichan>
336 <midicc>0</midicc>
337 <type>value</type>
338 <pressedValue>1.00000000</pressedValue>
339 <stringvalue>808loop.wav</stringvalue>
340 <text>Browse Audio File</text>
341 <image>/</image>
342 <eventLine/>
343 <latch>false</latch>
344 <latched>false</latched>
345 </bsbObject>
346 <bsbObject version="2" type="BSBLineEdit">
347 <objectName>_Browse1</objectName>
348 <x>180</x>
349 <y>253</y>
350 <width>330</width>
351 <height>28</height>
352 <uuid>{15a8ec14-710f-43e6-be9e-f5dc8c8786cb}</uuid>
353 <visible>true</visible>
354 <midichan>0</midichan>
355 <midicc>0</midicc>
356 <label>808loop.wav</label>
357 <alignment>left</alignment>
358 <font>Arial</font>
359 <fontsize>10</fontsize>
360 <precision>3</precision>
361 <color>
362 <r>0</r>
363 <g>0</g>
364 <b>0</b>
365 </color>
366 <bgcolor mode="nobackground">
367 <r>229</r>
368 <g>229</g>
369 <b>229</b>
370 </bgcolor>
371 <background>nobackground</background>
372 </bsbObject>
373 <bsbObject version="2" type="BSBLabel">
374 <objectName/>
375 <x>180</x>
376 <y>282</y>
377 <width>330</width>
378 <height>34</height>
379 <uuid>{a63909ac-6fa4-41c8-a84b-ba08e76132ab}</uuid>
380 <visible>true</visible>
381 <midichan>0</midichan>
382 <midicc>0</midicc>
383 <label>Restart the instrument after changing the audio file.</label>
384 <alignment>left</alignment>
385 <font>Liberation Sans</font>
386 <fontsize>12</fontsize>
387 <precision>3</precision>
388 <color>
389 <r>0</r>
390 <g>0</g>
391 <b>0</b>
392 </color>
393 <bgcolor mode="nobackground">
394 <r>255</r>
395 <g>255</g>
396 <b>255</b>
397 </bgcolor>
398 <bordermode>noborder</bordermode>
399 <borderradius>1</borderradius>
400 <borderwidth>1</borderwidth>
401 </bsbObject>
402 <bsbObject version="2" type="BSBHSlider">
403 <objectName>LiveGain</objectName>
404 <x>8</x>
405 <y>56</y>
406 <width>500</width>
407 <height>27</height>
408 <uuid>{2a8dc6e2-12f4-443d-af9b-59e4373cc24b}</uuid>
409 <visible>true</visible>
410 <midichan>0</midichan>
411 <midicc>0</midicc>
412 <minimum>0.00000000</minimum>
413 <maximum>1.00000000</maximum>
414 <value>0.13000000</value>
415 <mode>lin</mode>
416 <mouseControl act="jump">continuous</mouseControl>
417 <resolution>-1.00000000</resolution>
418 <randomizable group="0">false</randomizable>
419 </bsbObject>
420 <bsbObject version="2" type="BSBLabel">
421 <objectName/>
422 <x>8</x>
423 <y>150</y>
424 <width>120</width>
425 <height>30</height>
426 <uuid>{4fa545c6-e2f1-4387-8c9f-4a9dd388bb42}</uuid>
427 <visible>true</visible>
428 <midichan>0</midichan>
429 <midicc>0</midicc>
430 <label>Reverb Time</label>
431 <alignment>left</alignment>
432 <font>Liberation Sans</font>
433 <fontsize>10</fontsize>
434 <precision>3</precision>
435 <color>
436 <r>0</r>
437 <g>0</g>
438 <b>0</b>
439 </color>
440 <bgcolor mode="nobackground">
441 <r>255</r>
442 <g>255</g>
443 <b>255</b>
444 </bgcolor>
445 <bordermode>noborder</bordermode>
446 <borderradius>1</borderradius>
447 <borderwidth>1</borderwidth>
448 </bsbObject>
449 <bsbObject version="2" type="BSBDisplay">
450 <objectName>ReverbTime</objectName>
451 <x>448</x>
452 <y>150</y>
453 <width>60</width>
454 <height>30</height>
455 <uuid>{b0ad1916-b43e-44c2-be40-bca29f5cb1f4}</uuid>
456 <visible>true</visible>
457 <midichan>0</midichan>
458 <midicc>0</midicc>
459 <label>5.121</label>
460 <alignment>right</alignment>
461 <font>Liberation Sans</font>
462 <fontsize>9</fontsize>
463 <precision>3</precision>
464 <color>
465 <r>0</r>
466 <g>0</g>
467 <b>0</b>
468 </color>
469 <bgcolor mode="nobackground">
470 <r>255</r>
471 <g>255</g>
472 <b>255</b>
473 </bgcolor>
474 <bordermode>noborder</bordermode>
475 <borderradius>1</borderradius>
476 <borderwidth>1</borderwidth>
477 </bsbObject>
478 <bsbObject version="2" type="BSBHSlider">
479 <objectName>ReverbTime</objectName>
480 <x>8</x>
481 <y>134</y>
482 <width>500</width>
483 <height>27</height>
484 <uuid>{9069e547-5638-4568-896f-980087c61de0}</uuid>
485 <visible>true</visible>
486 <midichan>0</midichan>
487 <midicc>0</midicc>
488 <minimum>0.00100000</minimum>
489 <maximum>20.00000000</maximum>
490 <value>5.12074400</value>
491 <mode>lin</mode>
492 <mouseControl act="jump">continuous</mouseControl>
493 <resolution>-1.00000000</resolution>
494 <randomizable group="0">false</randomizable>
495 </bsbObject>
496 <bsbObject version="2" type="BSBLabel">
497 <objectName/>
498 <x>8</x>
499 <y>110</y>
500 <width>172</width>
501 <height>33</height>
502 <uuid>{aea49d35-076f-4f53-973f-218c07658afd}</uuid>
503 <visible>true</visible>
504 <midichan>0</midichan>
505 <midicc>0</midicc>
506 <label>Dry / Wet Mix</label>
507 <alignment>left</alignment>
508 <font>Liberation Sans</font>
509 <fontsize>10</fontsize>
510 <precision>3</precision>
511 <color>
512 <r>0</r>
513 <g>0</g>
514 <b>0</b>
515 </color>
516 <bgcolor mode="nobackground">
517 <r>255</r>
518 <g>255</g>
519 <b>255</b>
520 </bgcolor>
521 <bordermode>noborder</bordermode>
522 <borderradius>1</borderradius>
523 <borderwidth>1</borderwidth>
524 </bsbObject>
525 <bsbObject version="2" type="BSBDisplay">
526 <objectName>Mix</objectName>
527 <x>448</x>
528 <y>110</y>
529 <width>60</width>
530 <height>30</height>
531 <uuid>{e618dde4-1681-4841-ad6b-2f09a0dc7e42}</uuid>
532 <visible>true</visible>
533 <midichan>0</midichan>
534 <midicc>0</midicc>
535 <label>0.534</label>
536 <alignment>right</alignment>
537 <font>Liberation Sans</font>
538 <fontsize>9</fontsize>
539 <precision>3</precision>
540 <color>
541 <r>0</r>
542 <g>0</g>
543 <b>0</b>
544 </color>
545 <bgcolor mode="nobackground">
546 <r>255</r>
547 <g>255</g>
548 <b>255</b>
549 </bgcolor>
550 <bordermode>noborder</bordermode>
551 <borderradius>1</borderradius>
552 <borderwidth>1</borderwidth>
553 </bsbObject>
554 <bsbObject version="2" type="BSBHSlider">
555 <objectName>Mix</objectName>
556 <x>8</x>
557 <y>95</y>
558 <width>500</width>
559 <height>27</height>
560 <uuid>{d92cf2f2-852e-4c61-ba7a-5211a302ad02}</uuid>
561 <visible>true</visible>
562 <midichan>0</midichan>
563 <midicc>0</midicc>
564 <minimum>0.00000000</minimum>
565 <maximum>1.00000000</maximum>
566 <value>0.53400000</value>
567 <mode>lin</mode>
568 <mouseControl act="jump">continuous</mouseControl>
569 <resolution>-1.00000000</resolution>
570 <randomizable group="0">false</randomizable>
571 </bsbObject>
572 </bsbPanel>
573 <bsbPresets>
574 </bsbPresets>