Debian Codegraph @

src/Examples/McCurdy Collection/Convolution/dconv.csd

raw
1 ;Written by Iain McCurdy, 2009
2 ; Modified for QuteCsound by René, September 2010
3 ; Tested on Ubuntu 10.04 with csound-float 5.13.0 and QuteCsound svn rev 815
4
5 ;Notes on modifications from original csd:
6 ; Add Browser for audio file and use of FilePlay2 udo, now accept mono or stereo wav files
7
8
9 ;my flags on Ubuntu: -iadc -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=null -m0
10 <CsoundSynthesizer>
11 <CsOptions>
12 --env:SSDIR+=../../SourceMaterials
13 </CsOptions>
14 <CsInstruments>
15 sr = 44100 ;SAMPLE RATE
16 ksmps = 512 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
17 nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
18 0dbfs = 1 ;MAXIMUM SOUND INTENSITY LEVEL REGARDLESS OF BIT DEPTH
19
20 ;IMPULSE (SOUND) FILES
21 gifile1L ftgen 0,0,4096,1,"Wood.wav",0,0,1
22 gifile1R ftgen 0,0,4096,1,"Wood.wav",0,0,2
23 gifile2L ftgen 0,0,4096,1,"Mug.wav",0,0,1
24 gifile2R ftgen 0,0,4096,1,"Mug.wav",0,0,2
25
26
27 opcode FilePlay2, aa, Skoo ; Credit to Joachim Heintz
28 ;gives stereo output regardless your soundfile is mono or stereo
29 Sfil, kspeed, iskip, iloop xin
30 ichn filenchnls Sfil
31 if ichn == 1 then
32 aL diskin2 Sfil, kspeed, iskip, iloop
33 aR = aL
34 else
35 aL, aR diskin2 Sfil, kspeed, iskip, iloop
36 endif
37 xout aL, aR
38 endop
39
40
41 instr 10 ;GUI
42 ktrig metro 10
43 if (ktrig == 1) then
44 gkGain invalue "Gain" ;init 0.3
45 gkMix invalue "Mix" ;init 1.0
46 gkinput invalue "Input"
47 gkfile invalue "File"
48 endif
49 endin
50
51 instr 1 ;GENERATE INPUT AUDIO INDEPENDENTLY OF REVERBERATING INSTRUMENT
52 if gkinput= 0 then ;IF 'Sound File' IS SELECTED...
53 Sfile invalue "_Browse1"
54 gaL, gaR FilePlay2 Sfile, 1, 0, 1 ;READ AUDIO FROM SOUND FILE ON HARD DISC
55 elseif gkinput= 1 then ;IF 'Live Input' IS SELECTED
56 gaL inch 1 ;READ AUDIO FROM SOUND CARD'S FIRST (LEFT) INPUT
57 gaR = gaL ;MONO INPUT THEREFORE ASSIGN RIGHT CHANNEL TO LEFT CHANNEL ALSO
58 endif
59 endin
60
61 instr 2 ;CONVOLUTION REVERB INSTRUMENT (ALWAYS ON)
62 if gkfile=0 then ;IF 'STAIRWELL' IS CHOSEN AS CONVOLUTION FILE...
63 ifnL = gifile1L
64 ifnR = gifile1R
65 iftlen = ftlen(ifnL)
66 isize = iftlen
67 ar1 dconv gaL, isize, ifnL
68 ar2 dconv gaR, isize, ifnR
69 elseif gkfile=1 then ;IF 'DISH' IS CHOSEN AS CONVOLUTION FILE...
70 ifnL = gifile2L
71 ifnR = gifile2R
72 iftlen = ftlen(ifnL)
73 isize = iftlen
74 ar1 dconv gaL, isize, ifnL
75 ar2 dconv gaR, isize, ifnR
76 endif
77
78 aL ntrpol gaL, ar1*0.3, gkMix ;CREATE DRY/WET MIX (LEFT CHANNEL)
79 aR ntrpol gaR, ar2*0.3, gkMix ;CREATE DRY/WET MIX (RIGHT CHANNEL)
80 outs aL*gkGain, aR*gkGain ;SEND AUDIO TO OUTPUTS
81 gaL = 0 ;CLEAR GLOBAL AUDIO SIGNAL FROM INSTR 1 (LEFT CHANNEL)
82 gaR = 0 ;CLEAR GLOBAL AUDIO SIGNAL FROM INSTR 1 (RIGHT CHANNEL)
83 endin
84 </CsInstruments>
85 <CsScore>
86 i 10 0 3600 ;GUI
87 i 2 0 3600 ;INSTRUMENT 2 (CONVOLUTION INSTRUMENT) RUNS FOR 1 HOUR (AND KEEPS REAL-TIME PERFORMANCE GOING)
88 </CsScore>
89 </CsoundSynthesizer>
90 <bsbPanel>
91 <label>Widgets</label>
92 <objectName/>
93 <x>475</x>
94 <y>417</y>
95 <width>828</width>
96 <height>262</height>
97 <visible>true</visible>
98 <uuid/>
99 <bgcolor mode="background">
100 <r>241</r>
101 <g>226</g>
102 <b>185</b>
103 </bgcolor>
104 <bsbObject version="2" type="BSBLabel">
105 <objectName/>
106 <x>2</x>
107 <y>2</y>
108 <width>528</width>
109 <height>260</height>
110 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
111 <visible>true</visible>
112 <midichan>0</midichan>
113 <midicc>0</midicc>
114 <label>dconv</label>
115 <alignment>center</alignment>
116 <font>Arial Black</font>
117 <fontsize>18</fontsize>
118 <precision>3</precision>
119 <color>
120 <r>0</r>
121 <g>0</g>
122 <b>0</b>
123 </color>
124 <bgcolor mode="background">
125 <r>244</r>
126 <g>248</g>
127 <b>200</b>
128 </bgcolor>
129 <bordermode>border</bordermode>
130 <borderradius>5</borderradius>
131 <borderwidth>2</borderwidth>
132 </bsbObject>
133 <bsbObject version="2" type="BSBButton">
134 <objectName/>
135 <x>5</x>
136 <y>5</y>
137 <width>100</width>
138 <height>30</height>
139 <uuid>{487d5181-d838-4cce-9628-317fefc350cb}</uuid>
140 <visible>true</visible>
141 <midichan>0</midichan>
142 <midicc>0</midicc>
143 <type>event</type>
144 <pressedValue>1.00000000</pressedValue>
145 <stringvalue/>
146 <text> ON / OFF</text>
147 <image>/</image>
148 <eventLine>i 1 0 -1</eventLine>
149 <latch>true</latch>
150 <latched>false</latched>
151 </bsbObject>
152 <bsbObject version="2" type="BSBHSlider">
153 <objectName>Gain</objectName>
154 <x>16</x>
155 <y>55</y>
156 <width>500</width>
157 <height>27</height>
158 <uuid>{de47f47d-bcea-4c1c-ab4b-a323452b1f7e}</uuid>
159 <visible>true</visible>
160 <midichan>0</midichan>
161 <midicc>0</midicc>
162 <minimum>0.00000000</minimum>
163 <maximum>1.00000000</maximum>
164 <value>0.35800000</value>
165 <mode>lin</mode>
166 <mouseControl act="jump">continuous</mouseControl>
167 <resolution>-1.00000000</resolution>
168 <randomizable group="0">false</randomizable>
169 </bsbObject>
170 <bsbObject version="2" type="BSBLabel">
171 <objectName/>
172 <x>16</x>
173 <y>72</y>
174 <width>132</width>
175 <height>31</height>
176 <uuid>{0200a063-5db8-4668-bc2d-2d989a083f6e}</uuid>
177 <visible>true</visible>
178 <midichan>0</midichan>
179 <midicc>0</midicc>
180 <label>Gain</label>
181 <alignment>left</alignment>
182 <font>Arial</font>
183 <fontsize>10</fontsize>
184 <precision>3</precision>
185 <color>
186 <r>0</r>
187 <g>0</g>
188 <b>0</b>
189 </color>
190 <bgcolor mode="nobackground">
191 <r>255</r>
192 <g>255</g>
193 <b>255</b>
194 </bgcolor>
195 <bordermode>noborder</bordermode>
196 <borderradius>1</borderradius>
197 <borderwidth>1</borderwidth>
198 </bsbObject>
199 <bsbObject version="2" type="BSBDisplay">
200 <objectName>Gain</objectName>
201 <x>427</x>
202 <y>73</y>
203 <width>88</width>
204 <height>29</height>
205 <uuid>{ab191e3a-430d-4f1d-88aa-9840342cd2d3}</uuid>
206 <visible>true</visible>
207 <midichan>0</midichan>
208 <midicc>0</midicc>
209 <label>0.358</label>
210 <alignment>right</alignment>
211 <font>Arial</font>
212 <fontsize>9</fontsize>
213 <precision>3</precision>
214 <color>
215 <r>0</r>
216 <g>0</g>
217 <b>0</b>
218 </color>
219 <bgcolor mode="nobackground">
220 <r>255</r>
221 <g>255</g>
222 <b>255</b>
223 </bgcolor>
224 <bordermode>noborder</bordermode>
225 <borderradius>1</borderradius>
226 <borderwidth>1</borderwidth>
227 </bsbObject>
228 <bsbObject version="2" type="BSBLabel">
229 <objectName/>
230 <x>531</x>
231 <y>2</y>
232 <width>297</width>
233 <height>260</height>
234 <uuid>{74928ed2-b701-4668-9a11-74763d317e9b}</uuid>
235 <visible>true</visible>
236 <midichan>0</midichan>
237 <midicc>0</midicc>
238 <label>dconv</label>
239 <alignment>center</alignment>
240 <font>Arial Black</font>
241 <fontsize>18</fontsize>
242 <precision>3</precision>
243 <color>
244 <r>0</r>
245 <g>0</g>
246 <b>0</b>
247 </color>
248 <bgcolor mode="background">
249 <r>244</r>
250 <g>248</g>
251 <b>200</b>
252 </bgcolor>
253 <bordermode>border</bordermode>
254 <borderradius>5</borderradius>
255 <borderwidth>2</borderwidth>
256 </bsbObject>
257 <bsbObject version="2" type="BSBLabel">
258 <objectName/>
259 <x>537</x>
260 <y>26</y>
261 <width>289</width>
262 <height>232</height>
263 <uuid>{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}</uuid>
264 <visible>true</visible>
265 <midichan>0</midichan>
266 <midicc>0</midicc>
267 <label>---------------------------------------------------------------------
268 dconv performs direct convolution between an input signal and an impulse file.
269 dconv works best, at least in real-time, with very short impulse files and is therefore less well suited to reverberation application but better suited for filtering.
270 With long impulse files dconv will struggle to perform at all. The two impulse files provided with this example are both extremely short.</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="BSBDisplay">
290 <objectName>Mix</objectName>
291 <x>430</x>
292 <y>111</y>
293 <width>86</width>
294 <height>36</height>
295 <uuid>{732b2008-7445-4893-a260-e68561cf8e71}</uuid>
296 <visible>true</visible>
297 <midichan>0</midichan>
298 <midicc>0</midicc>
299 <label>0.588</label>
300 <alignment>right</alignment>
301 <font>Arial</font>
302 <fontsize>9</fontsize>
303 <precision>3</precision>
304 <color>
305 <r>0</r>
306 <g>0</g>
307 <b>0</b>
308 </color>
309 <bgcolor mode="nobackground">
310 <r>255</r>
311 <g>255</g>
312 <b>255</b>
313 </bgcolor>
314 <bordermode>noborder</bordermode>
315 <borderradius>1</borderradius>
316 <borderwidth>1</borderwidth>
317 </bsbObject>
318 <bsbObject version="2" type="BSBLabel">
319 <objectName/>
320 <x>16</x>
321 <y>111</y>
322 <width>130</width>
323 <height>31</height>
324 <uuid>{b57ba536-8f28-4986-9bf7-8eb84262d8ca}</uuid>
325 <visible>true</visible>
326 <midichan>0</midichan>
327 <midicc>0</midicc>
328 <label>Dry / Wet Mix</label>
329 <alignment>left</alignment>
330 <font>Arial</font>
331 <fontsize>10</fontsize>
332 <precision>3</precision>
333 <color>
334 <r>0</r>
335 <g>0</g>
336 <b>0</b>
337 </color>
338 <bgcolor mode="nobackground">
339 <r>255</r>
340 <g>255</g>
341 <b>255</b>
342 </bgcolor>
343 <bordermode>noborder</bordermode>
344 <borderradius>1</borderradius>
345 <borderwidth>1</borderwidth>
346 </bsbObject>
347 <bsbObject version="2" type="BSBHSlider">
348 <objectName>Mix</objectName>
349 <x>16</x>
350 <y>94</y>
351 <width>500</width>
352 <height>27</height>
353 <uuid>{b8fa76b9-3d04-4156-a2f2-a413d3864da3}</uuid>
354 <visible>true</visible>
355 <midichan>0</midichan>
356 <midicc>0</midicc>
357 <minimum>0.00000000</minimum>
358 <maximum>1.00000000</maximum>
359 <value>0.58800000</value>
360 <mode>lin</mode>
361 <mouseControl act="jump">continuous</mouseControl>
362 <resolution>-1.00000000</resolution>
363 <randomizable group="0">false</randomizable>
364 </bsbObject>
365 <bsbObject version="2" type="BSBDropdown">
366 <objectName>Input</objectName>
367 <x>93</x>
368 <y>147</y>
369 <width>120</width>
370 <height>30</height>
371 <uuid>{9b81a1f2-bcb8-4582-925b-9ae56def3865}</uuid>
372 <visible>true</visible>
373 <midichan>0</midichan>
374 <midicc>0</midicc>
375 <bsbDropdownItemList>
376 <bsbDropdownItem>
377 <name>Audio File</name>
378 <value>0</value>
379 <stringvalue/>
380 </bsbDropdownItem>
381 <bsbDropdownItem>
382 <name> Live Input</name>
383 <value>1</value>
384 <stringvalue/>
385 </bsbDropdownItem>
386 </bsbDropdownItemList>
387 <selectedIndex>0</selectedIndex>
388 <randomizable group="0">false</randomizable>
389 </bsbObject>
390 <bsbObject version="2" type="BSBDropdown">
391 <objectName>File</objectName>
392 <x>365</x>
393 <y>147</y>
394 <width>120</width>
395 <height>30</height>
396 <uuid>{4f12eb6a-c071-4199-8bad-bfe11a917032}</uuid>
397 <visible>true</visible>
398 <midichan>0</midichan>
399 <midicc>0</midicc>
400 <bsbDropdownItemList>
401 <bsbDropdownItem>
402 <name>Wood</name>
403 <value>0</value>
404 <stringvalue/>
405 </bsbDropdownItem>
406 <bsbDropdownItem>
407 <name> Mug</name>
408 <value>1</value>
409 <stringvalue/>
410 </bsbDropdownItem>
411 </bsbDropdownItemList>
412 <selectedIndex>0</selectedIndex>
413 <randomizable group="0">false</randomizable>
414 </bsbObject>
415 <bsbObject version="2" type="BSBLabel">
416 <objectName/>
417 <x>9</x>
418 <y>147</y>
419 <width>80</width>
420 <height>30</height>
421 <uuid>{62eeb695-9b83-42da-81cd-8000c232d9b9}</uuid>
422 <visible>true</visible>
423 <midichan>0</midichan>
424 <midicc>0</midicc>
425 <label>Input</label>
426 <alignment>right</alignment>
427 <font>Arial</font>
428 <fontsize>10</fontsize>
429 <precision>3</precision>
430 <color>
431 <r>0</r>
432 <g>0</g>
433 <b>0</b>
434 </color>
435 <bgcolor mode="nobackground">
436 <r>255</r>
437 <g>255</g>
438 <b>255</b>
439 </bgcolor>
440 <bordermode>noborder</bordermode>
441 <borderradius>1</borderradius>
442 <borderwidth>1</borderwidth>
443 </bsbObject>
444 <bsbObject version="2" type="BSBLabel">
445 <objectName/>
446 <x>263</x>
447 <y>147</y>
448 <width>100</width>
449 <height>30</height>
450 <uuid>{f0042687-944f-4ab5-a258-074f2aca5510}</uuid>
451 <visible>true</visible>
452 <midichan>0</midichan>
453 <midicc>0</midicc>
454 <label>Convolution file</label>
455 <alignment>right</alignment>
456 <font>Arial</font>
457 <fontsize>10</fontsize>
458 <precision>3</precision>
459 <color>
460 <r>0</r>
461 <g>0</g>
462 <b>0</b>
463 </color>
464 <bgcolor mode="nobackground">
465 <r>255</r>
466 <g>255</g>
467 <b>255</b>
468 </bgcolor>
469 <bordermode>noborder</bordermode>
470 <borderradius>1</borderradius>
471 <borderwidth>1</borderwidth>
472 </bsbObject>
473 <bsbObject version="2" type="BSBButton">
474 <objectName>_Browse1</objectName>
475 <x>6</x>
476 <y>193</y>
477 <width>170</width>
478 <height>30</height>
479 <uuid>{5766315a-d788-4a54-b092-54ba68f56c3a}</uuid>
480 <visible>true</visible>
481 <midichan>0</midichan>
482 <midicc>0</midicc>
483 <type>value</type>
484 <pressedValue>1.00000000</pressedValue>
485 <stringvalue>808loop.wav</stringvalue>
486 <text>Browse Audio File</text>
487 <image>/</image>
488 <eventLine/>
489 <latch>false</latch>
490 <latched>false</latched>
491 </bsbObject>
492 <bsbObject version="2" type="BSBLineEdit">
493 <objectName>_Browse1</objectName>
494 <x>177</x>
495 <y>194</y>
496 <width>330</width>
497 <height>28</height>
498 <uuid>{5be68a46-a493-4096-bd3e-f26d0bb35f76}</uuid>
499 <visible>true</visible>
500 <midichan>0</midichan>
501 <midicc>0</midicc>
502 <label>808loop.wav</label>
503 <alignment>left</alignment>
504 <font>Arial</font>
505 <fontsize>10</fontsize>
506 <precision>3</precision>
507 <color>
508 <r>0</r>
509 <g>0</g>
510 <b>0</b>
511 </color>
512 <bgcolor mode="nobackground">
513 <r>240</r>
514 <g>235</g>
515 <b>226</b>
516 </bgcolor>
517 <background>nobackground</background>
518 </bsbObject>
519 <bsbObject version="2" type="BSBLabel">
520 <objectName/>
521 <x>177</x>
522 <y>221</y>
523 <width>330</width>
524 <height>30</height>
525 <uuid>{a63909ac-6fa4-41c8-a84b-ba08e76132ab}</uuid>
526 <visible>true</visible>
527 <midichan>0</midichan>
528 <midicc>0</midicc>
529 <label>Restart the instrument after changing the audio file.</label>
530 <alignment>left</alignment>
531 <font>Liberation Sans</font>
532 <fontsize>12</fontsize>
533 <precision>3</precision>
534 <color>
535 <r>0</r>
536 <g>0</g>
537 <b>0</b>
538 </color>
539 <bgcolor mode="nobackground">
540 <r>255</r>
541 <g>255</g>
542 <b>255</b>
543 </bgcolor>
544 <bordermode>noborder</bordermode>
545 <borderradius>1</borderradius>
546 <borderwidth>1</borderwidth>
547 </bsbObject>
548 </bsbPanel>
549 <bsbPresets>
550 </bsbPresets>