Debian Codegraph @

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

raw
1 ;Written by Iain McCurdy, 2006
2
3 ;THE NREVERB 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 ; Add init instrument
13
14
15 ;Reverb structure:
16
17 ; +----+
18 ; +-|comb|-+
19 ; | +----+ |
20 ; | |
21 ; | +----+ |
22 ; +-|comb|-+
23 ; | +----+ |
24 ; + +
25 ; | +----+ |
26 ; +-|comb|-+
27 ; | +----+ | +------+ +------+ +------+ +------+ +------+
28 ; IN-->| |-|alpass|-|alpass|-|alpass|-|alpass|-|alpass|-->OUT
29 ; | +----+ | +------+ +------+ +------+ +------+ +------+
30 ; +-|comb|-+
31 ; | +----+ |
32 ; | |
33 ; | +----+ |
34 ; +-|comb|-+
35 ; | +----+ |
36 ; | |
37 ; | +----+ |
38 ; +-|comb|-+
39 ; +----+
40
41
42 ;my flags on Ubuntu: -iadc -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=null -m0
43 <CsoundSynthesizer>
44 <CsOptions>
45 --env:SSDIR+=../../SourceMaterials
46 </CsOptions>
47 <CsInstruments>
48 sr = 44100 ;SAMPLE RATE
49 ksmps = 100 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
50 nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
51
52
53 opcode FilePlay2, aa, Skoo ; Credit to Joachim Heintz
54 ;gives stereo output regardless your soundfile is mono or stereo
55 Sfil, kspeed, iskip, iloop xin
56 ichn filenchnls Sfil
57 if ichn == 1 then
58 aL diskin2 Sfil, kspeed, iskip, iloop
59 aR = aL
60 else
61 aL, aR diskin2 Sfil, kspeed, iskip, iloop
62 endif
63 xout aL, aR
64 endop
65
66
67 instr 10 ;GUI
68 ktrig metro 10
69 if (ktrig == 1) then
70 gkingain invalue "LiveGain"
71 gkmix invalue "Mix"
72 gkrvbtime invalue "ReverbTime"
73 gkHFDiff invalue "HFDiffusion"
74 gkinput invalue "Input"
75 endif
76 endin
77
78 instr 1 ;PLAYS FILE AND OUTPUTS GLOBAL VARIABLES
79 if gkinput==0 then ;IF FILE INPUT IS SELECTED...
80 Sfile invalue "_Browse1"
81 gasigL, gasigR FilePlay2 Sfile, 1, 0, 1 ;GENERATE 2 AUDIO SIGNALS FROM A SOUND FILE (NOTE THE USE OF GLOBAL VARIABLES)
82 else ;OTHERWISE
83 asigL, asigR ins ;TAKE INPUT FROM COMPUTER'S AUDIO INPUT
84 gasigL = asigL * gkingain ;SCALE USING 'Input Gain' SLIDER
85 gasigR = asigR * gkingain ;SCALE USING 'Input Gain' SLIDER
86 endif ;END OF CONDITIONAL BRANCHING
87 endin
88
89 instr 2 ;REVERB - ALWAYS ON
90 aRvbL nreverb gasigL*.3, gkrvbtime, gkHFDiff ;CREATE LEFT CHANNEL REVERB
91 aRvbR nreverb gasigR*.3, gkrvbtime, gkHFDiff ;CREATE RIGHT CHANNEL REVERB
92 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
93 clear gasigL, gasigR ;CLEAR GLOBAL AUDIO VARIABLES
94 endin
95
96 instr 11 ;INIT
97 outvalue "Mix" , .5
98 outvalue "ReverbTime" , .5
99 outvalue "HFDiffusion" , .5
100 endin
101 </CsInstruments>
102 <CsScore>
103 ;INSTR | START | DURATION
104 i 10 0.0 3600 ;GUI
105 i 2 0.0 3600 ;REVERB INSTRUMENT PLAYS FOR 1 HOUR (AND KEEPS PERFORMANCE GOING)
106 i 11 0.0 0.1 ;INIT
107 </CsScore>
108 </CsoundSynthesizer>
109 <bsbPanel>
110 <label>Widgets</label>
111 <objectName/>
112 <x>73</x>
113 <y>206</y>
114 <width>946</width>
115 <height>318</height>
116 <visible>true</visible>
117 <uuid/>
118 <bgcolor mode="background">
119 <r>241</r>
120 <g>226</g>
121 <b>185</b>
122 </bgcolor>
123 <bsbObject version="2" type="BSBLabel">
124 <objectName/>
125 <x>2</x>
126 <y>2</y>
127 <width>512</width>
128 <height>316</height>
129 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
130 <visible>true</visible>
131 <midichan>0</midichan>
132 <midicc>0</midicc>
133 <label>nreverb</label>
134 <alignment>center</alignment>
135 <font>Liberation Sans</font>
136 <fontsize>18</fontsize>
137 <precision>3</precision>
138 <color>
139 <r>0</r>
140 <g>0</g>
141 <b>0</b>
142 </color>
143 <bgcolor mode="background">
144 <r>158</r>
145 <g>220</g>
146 <b>217</b>
147 </bgcolor>
148 <bordermode>border</bordermode>
149 <borderradius>5</borderradius>
150 <borderwidth>2</borderwidth>
151 </bsbObject>
152 <bsbObject version="2" type="BSBButton">
153 <objectName/>
154 <x>8</x>
155 <y>10</y>
156 <width>100</width>
157 <height>30</height>
158 <uuid>{487d5181-d838-4cce-9628-317fefc350cb}</uuid>
159 <visible>true</visible>
160 <midichan>0</midichan>
161 <midicc>0</midicc>
162 <type>event</type>
163 <pressedValue>1.00000000</pressedValue>
164 <stringvalue/>
165 <text> ON / OFF</text>
166 <image>/</image>
167 <eventLine>i 1 0 -1</eventLine>
168 <latch>true</latch>
169 <latched>false</latched>
170 </bsbObject>
171 <bsbObject version="2" type="BSBLabel">
172 <objectName/>
173 <x>8</x>
174 <y>72</y>
175 <width>120</width>
176 <height>30</height>
177 <uuid>{0200a063-5db8-4668-bc2d-2d989a083f6e}</uuid>
178 <visible>true</visible>
179 <midichan>0</midichan>
180 <midicc>0</midicc>
181 <label>Live input Gain</label>
182 <alignment>left</alignment>
183 <font>Liberation Sans</font>
184 <fontsize>10</fontsize>
185 <precision>3</precision>
186 <color>
187 <r>0</r>
188 <g>0</g>
189 <b>0</b>
190 </color>
191 <bgcolor mode="nobackground">
192 <r>255</r>
193 <g>255</g>
194 <b>255</b>
195 </bgcolor>
196 <bordermode>noborder</bordermode>
197 <borderradius>1</borderradius>
198 <borderwidth>1</borderwidth>
199 </bsbObject>
200 <bsbObject version="2" type="BSBDisplay">
201 <objectName>LiveGain</objectName>
202 <x>448</x>
203 <y>72</y>
204 <width>60</width>
205 <height>30</height>
206 <uuid>{ab191e3a-430d-4f1d-88aa-9840342cd2d3}</uuid>
207 <visible>true</visible>
208 <midichan>0</midichan>
209 <midicc>0</midicc>
210 <label>0.228</label>
211 <alignment>right</alignment>
212 <font>Liberation Sans</font>
213 <fontsize>9</fontsize>
214 <precision>3</precision>
215 <color>
216 <r>0</r>
217 <g>0</g>
218 <b>0</b>
219 </color>
220 <bgcolor mode="nobackground">
221 <r>255</r>
222 <g>255</g>
223 <b>255</b>
224 </bgcolor>
225 <bordermode>noborder</bordermode>
226 <borderradius>1</borderradius>
227 <borderwidth>1</borderwidth>
228 </bsbObject>
229 <bsbObject version="2" type="BSBLabel">
230 <objectName/>
231 <x>516</x>
232 <y>2</y>
233 <width>430</width>
234 <height>316</height>
235 <uuid>{74928ed2-b701-4668-9a11-74763d317e9b}</uuid>
236 <visible>true</visible>
237 <midichan>0</midichan>
238 <midicc>0</midicc>
239 <label>nreverb</label>
240 <alignment>center</alignment>
241 <font>Liberation Sans</font>
242 <fontsize>18</fontsize>
243 <precision>3</precision>
244 <color>
245 <r>0</r>
246 <g>0</g>
247 <b>0</b>
248 </color>
249 <bgcolor mode="background">
250 <r>158</r>
251 <g>220</g>
252 <b>217</b>
253 </bgcolor>
254 <bordermode>border</bordermode>
255 <borderradius>5</borderradius>
256 <borderwidth>2</borderwidth>
257 </bsbObject>
258 <bsbObject version="2" type="BSBLabel">
259 <objectName/>
260 <x>519</x>
261 <y>22</y>
262 <width>427</width>
263 <height>293</height>
264 <uuid>{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}</uuid>
265 <visible>true</visible>
266 <midichan>0</midichan>
267 <midicc>0</midicc>
268 <label>-------------------------------------------------------------------------------------------------------
269 nreverb is a reverberation unit within which is contained an algorithm consisting of six parallel comb filters and five series allpass filters (as shown below). Obligatory input arguments besides the input audio signal are for reverb time in seconds and for high frequency diffusion (range: 0 to 1). Use of high frequency diffusion activates low pass filters within the algorithm which can help improve the simulation of a real acoustic space. An optional 2-wayswitch 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. In this example a Dry/Wet Mix crossfader is also implemented.
270 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>
271 <alignment>left</alignment>
272 <font>Liberation Sans</font>
273 <fontsize>14</fontsize>
274 <precision>3</precision>
275 <color>
276 <r>0</r>
277 <g>0</g>
278 <b>0</b>
279 </color>
280 <bgcolor mode="nobackground">
281 <r>255</r>
282 <g>255</g>
283 <b>255</b>
284 </bgcolor>
285 <bordermode>noborder</bordermode>
286 <borderradius>1</borderradius>
287 <borderwidth>1</borderwidth>
288 </bsbObject>
289 <bsbObject version="2" type="BSBDropdown">
290 <objectName>Input</objectName>
291 <x>180</x>
292 <y>215</y>
293 <width>120</width>
294 <height>30</height>
295 <uuid>{9b81a1f2-bcb8-4582-925b-9ae56def3865}</uuid>
296 <visible>true</visible>
297 <midichan>0</midichan>
298 <midicc>0</midicc>
299 <bsbDropdownItemList>
300 <bsbDropdownItem>
301 <name>Audio File</name>
302 <value>0</value>
303 <stringvalue/>
304 </bsbDropdownItem>
305 <bsbDropdownItem>
306 <name> Live Input</name>
307 <value>1</value>
308 <stringvalue/>
309 </bsbDropdownItem>
310 </bsbDropdownItemList>
311 <selectedIndex>0</selectedIndex>
312 <randomizable group="0">false</randomizable>
313 </bsbObject>
314 <bsbObject version="2" type="BSBLabel">
315 <objectName/>
316 <x>98</x>
317 <y>215</y>
318 <width>80</width>
319 <height>30</height>
320 <uuid>{62eeb695-9b83-42da-81cd-8000c232d9b9}</uuid>
321 <visible>true</visible>
322 <midichan>0</midichan>
323 <midicc>0</midicc>
324 <label>Input</label>
325 <alignment>right</alignment>
326 <font>Arial</font>
327 <fontsize>10</fontsize>
328 <precision>3</precision>
329 <color>
330 <r>0</r>
331 <g>0</g>
332 <b>0</b>
333 </color>
334 <bgcolor mode="nobackground">
335 <r>255</r>
336 <g>255</g>
337 <b>255</b>
338 </bgcolor>
339 <bordermode>noborder</bordermode>
340 <borderradius>1</borderradius>
341 <borderwidth>1</borderwidth>
342 </bsbObject>
343 <bsbObject version="2" type="BSBButton">
344 <objectName>_Browse1</objectName>
345 <x>8</x>
346 <y>252</y>
347 <width>170</width>
348 <height>30</height>
349 <uuid>{9b992da1-8c0f-449e-af03-7913cc05efed}</uuid>
350 <visible>true</visible>
351 <midichan>0</midichan>
352 <midicc>0</midicc>
353 <type>value</type>
354 <pressedValue>1.00000000</pressedValue>
355 <stringvalue>808loop.wav</stringvalue>
356 <text>Browse Audio File</text>
357 <image>/</image>
358 <eventLine/>
359 <latch>false</latch>
360 <latched>false</latched>
361 </bsbObject>
362 <bsbObject version="2" type="BSBLineEdit">
363 <objectName>_Browse1</objectName>
364 <x>180</x>
365 <y>253</y>
366 <width>330</width>
367 <height>28</height>
368 <uuid>{15a8ec14-710f-43e6-be9e-f5dc8c8786cb}</uuid>
369 <visible>true</visible>
370 <midichan>0</midichan>
371 <midicc>0</midicc>
372 <label>808loop.wav</label>
373 <alignment>left</alignment>
374 <font>Arial</font>
375 <fontsize>10</fontsize>
376 <precision>3</precision>
377 <color>
378 <r>0</r>
379 <g>0</g>
380 <b>0</b>
381 </color>
382 <bgcolor mode="nobackground">
383 <r>229</r>
384 <g>229</g>
385 <b>229</b>
386 </bgcolor>
387 <background>nobackground</background>
388 </bsbObject>
389 <bsbObject version="2" type="BSBLabel">
390 <objectName/>
391 <x>180</x>
392 <y>282</y>
393 <width>330</width>
394 <height>34</height>
395 <uuid>{a63909ac-6fa4-41c8-a84b-ba08e76132ab}</uuid>
396 <visible>true</visible>
397 <midichan>0</midichan>
398 <midicc>0</midicc>
399 <label>Restart the instrument after changing the audio file.</label>
400 <alignment>left</alignment>
401 <font>Liberation Sans</font>
402 <fontsize>12</fontsize>
403 <precision>3</precision>
404 <color>
405 <r>0</r>
406 <g>0</g>
407 <b>0</b>
408 </color>
409 <bgcolor mode="nobackground">
410 <r>255</r>
411 <g>255</g>
412 <b>255</b>
413 </bgcolor>
414 <bordermode>noborder</bordermode>
415 <borderradius>1</borderradius>
416 <borderwidth>1</borderwidth>
417 </bsbObject>
418 <bsbObject version="2" type="BSBHSlider">
419 <objectName>LiveGain</objectName>
420 <x>8</x>
421 <y>56</y>
422 <width>500</width>
423 <height>27</height>
424 <uuid>{2a8dc6e2-12f4-443d-af9b-59e4373cc24b}</uuid>
425 <visible>true</visible>
426 <midichan>0</midichan>
427 <midicc>0</midicc>
428 <minimum>0.00000000</minimum>
429 <maximum>1.00000000</maximum>
430 <value>0.22800000</value>
431 <mode>lin</mode>
432 <mouseControl act="jump">continuous</mouseControl>
433 <resolution>-1.00000000</resolution>
434 <randomizable group="0">false</randomizable>
435 </bsbObject>
436 <bsbObject version="2" type="BSBLabel">
437 <objectName/>
438 <x>8</x>
439 <y>150</y>
440 <width>120</width>
441 <height>30</height>
442 <uuid>{4fa545c6-e2f1-4387-8c9f-4a9dd388bb42}</uuid>
443 <visible>true</visible>
444 <midichan>0</midichan>
445 <midicc>0</midicc>
446 <label>Reverb Time</label>
447 <alignment>left</alignment>
448 <font>Liberation Sans</font>
449 <fontsize>10</fontsize>
450 <precision>3</precision>
451 <color>
452 <r>0</r>
453 <g>0</g>
454 <b>0</b>
455 </color>
456 <bgcolor mode="nobackground">
457 <r>255</r>
458 <g>255</g>
459 <b>255</b>
460 </bgcolor>
461 <bordermode>noborder</bordermode>
462 <borderradius>1</borderradius>
463 <borderwidth>1</borderwidth>
464 </bsbObject>
465 <bsbObject version="2" type="BSBDisplay">
466 <objectName>ReverbTime</objectName>
467 <x>448</x>
468 <y>150</y>
469 <width>60</width>
470 <height>30</height>
471 <uuid>{b0ad1916-b43e-44c2-be40-bca29f5cb1f4}</uuid>
472 <visible>true</visible>
473 <midichan>0</midichan>
474 <midicc>0</midicc>
475 <label>0.500</label>
476 <alignment>right</alignment>
477 <font>Liberation Sans</font>
478 <fontsize>9</fontsize>
479 <precision>3</precision>
480 <color>
481 <r>0</r>
482 <g>0</g>
483 <b>0</b>
484 </color>
485 <bgcolor mode="nobackground">
486 <r>255</r>
487 <g>255</g>
488 <b>255</b>
489 </bgcolor>
490 <bordermode>noborder</bordermode>
491 <borderradius>1</borderradius>
492 <borderwidth>1</borderwidth>
493 </bsbObject>
494 <bsbObject version="2" type="BSBHSlider">
495 <objectName>ReverbTime</objectName>
496 <x>8</x>
497 <y>134</y>
498 <width>500</width>
499 <height>27</height>
500 <uuid>{9069e547-5638-4568-896f-980087c61de0}</uuid>
501 <visible>true</visible>
502 <midichan>0</midichan>
503 <midicc>0</midicc>
504 <minimum>0.00100000</minimum>
505 <maximum>20.00000000</maximum>
506 <value>0.50000000</value>
507 <mode>lin</mode>
508 <mouseControl act="jump">continuous</mouseControl>
509 <resolution>-1.00000000</resolution>
510 <randomizable group="0">false</randomizable>
511 </bsbObject>
512 <bsbObject version="2" type="BSBLabel">
513 <objectName/>
514 <x>8</x>
515 <y>189</y>
516 <width>180</width>
517 <height>30</height>
518 <uuid>{ada34c8d-83fe-4eae-b207-ac7e38c5251f}</uuid>
519 <visible>true</visible>
520 <midichan>0</midichan>
521 <midicc>0</midicc>
522 <label>High Frequency Diffusion</label>
523 <alignment>left</alignment>
524 <font>Liberation Sans</font>
525 <fontsize>10</fontsize>
526 <precision>3</precision>
527 <color>
528 <r>0</r>
529 <g>0</g>
530 <b>0</b>
531 </color>
532 <bgcolor mode="nobackground">
533 <r>255</r>
534 <g>255</g>
535 <b>255</b>
536 </bgcolor>
537 <bordermode>noborder</bordermode>
538 <borderradius>1</borderradius>
539 <borderwidth>1</borderwidth>
540 </bsbObject>
541 <bsbObject version="2" type="BSBDisplay">
542 <objectName>HFDiffusion</objectName>
543 <x>448</x>
544 <y>189</y>
545 <width>60</width>
546 <height>30</height>
547 <uuid>{c333f6de-006b-45d6-bfec-c6a0205b39e8}</uuid>
548 <visible>true</visible>
549 <midichan>0</midichan>
550 <midicc>0</midicc>
551 <label>0.500</label>
552 <alignment>right</alignment>
553 <font>Liberation Sans</font>
554 <fontsize>9</fontsize>
555 <precision>3</precision>
556 <color>
557 <r>0</r>
558 <g>0</g>
559 <b>0</b>
560 </color>
561 <bgcolor mode="nobackground">
562 <r>255</r>
563 <g>255</g>
564 <b>255</b>
565 </bgcolor>
566 <bordermode>noborder</bordermode>
567 <borderradius>1</borderradius>
568 <borderwidth>1</borderwidth>
569 </bsbObject>
570 <bsbObject version="2" type="BSBHSlider">
571 <objectName>HFDiffusion</objectName>
572 <x>8</x>
573 <y>173</y>
574 <width>500</width>
575 <height>27</height>
576 <uuid>{07f985ef-961c-4c4a-b40b-ac266b8e938d}</uuid>
577 <visible>true</visible>
578 <midichan>0</midichan>
579 <midicc>0</midicc>
580 <minimum>0.00000000</minimum>
581 <maximum>1.00000000</maximum>
582 <value>0.50000000</value>
583 <mode>lin</mode>
584 <mouseControl act="jump">continuous</mouseControl>
585 <resolution>-1.00000000</resolution>
586 <randomizable group="0">false</randomizable>
587 </bsbObject>
588 <bsbObject version="2" type="BSBLabel">
589 <objectName/>
590 <x>8</x>
591 <y>110</y>
592 <width>172</width>
593 <height>33</height>
594 <uuid>{aea49d35-076f-4f53-973f-218c07658afd}</uuid>
595 <visible>true</visible>
596 <midichan>0</midichan>
597 <midicc>0</midicc>
598 <label>Dry / Wet Mix</label>
599 <alignment>left</alignment>
600 <font>Liberation Sans</font>
601 <fontsize>10</fontsize>
602 <precision>3</precision>
603 <color>
604 <r>0</r>
605 <g>0</g>
606 <b>0</b>
607 </color>
608 <bgcolor mode="nobackground">
609 <r>255</r>
610 <g>255</g>
611 <b>255</b>
612 </bgcolor>
613 <bordermode>noborder</bordermode>
614 <borderradius>1</borderradius>
615 <borderwidth>1</borderwidth>
616 </bsbObject>
617 <bsbObject version="2" type="BSBDisplay">
618 <objectName>Mix</objectName>
619 <x>448</x>
620 <y>110</y>
621 <width>60</width>
622 <height>30</height>
623 <uuid>{e618dde4-1681-4841-ad6b-2f09a0dc7e42}</uuid>
624 <visible>true</visible>
625 <midichan>0</midichan>
626 <midicc>0</midicc>
627 <label>0.500</label>
628 <alignment>right</alignment>
629 <font>Liberation Sans</font>
630 <fontsize>9</fontsize>
631 <precision>3</precision>
632 <color>
633 <r>0</r>
634 <g>0</g>
635 <b>0</b>
636 </color>
637 <bgcolor mode="nobackground">
638 <r>255</r>
639 <g>255</g>
640 <b>255</b>
641 </bgcolor>
642 <bordermode>noborder</bordermode>
643 <borderradius>1</borderradius>
644 <borderwidth>1</borderwidth>
645 </bsbObject>
646 <bsbObject version="2" type="BSBHSlider">
647 <objectName>Mix</objectName>
648 <x>8</x>
649 <y>95</y>
650 <width>500</width>
651 <height>27</height>
652 <uuid>{d92cf2f2-852e-4c61-ba7a-5211a302ad02}</uuid>
653 <visible>true</visible>
654 <midichan>0</midichan>
655 <midicc>0</midicc>
656 <minimum>0.00000000</minimum>
657 <maximum>1.00000000</maximum>
658 <value>0.50000000</value>
659 <mode>lin</mode>
660 <mouseControl act="jump">continuous</mouseControl>
661 <resolution>-1.00000000</resolution>
662 <randomizable group="0">false</randomizable>
663 </bsbObject>
664 </bsbPanel>
665 <bsbPresets>
666 </bsbPresets>