Debian Codegraph @

src/Examples/McCurdy Collection/Filters/bqrez.csd

raw
1 ;Written by Iain McCurdy, 2006
2
3 ;Modified for QuteCsound by René, October 2010, updated Feb 2011
4 ;Tested on Ubuntu 10.04 with csound-float 5.13.0 and QuteCsound svn rev 817
5
6 ;Notes on modifications from original csd:
7 ; Add table(s) for exp slider
8 ; Add Browser for audio file and use of FilePlay2 udo, now accept mono or stereo wav files
9
10
11 ;my flags on Ubuntu: -iadc -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=null -m0
12 <CsoundSynthesizer>
13 <CsOptions>
14 --env:SSDIR+=../../SourceMaterials
15 </CsOptions>
16 <CsInstruments>
17 sr = 44100 ;SAMPLE RATE
18 ksmps = 2 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
19 nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
20
21
22 giExp20000 ftgen 0, 0, 129, -25, 0, 20.0, 128, 20000.0 ;TABLE FOR EXP SLIDER
23
24
25 opcode FilePlay2, aa, Skoo ; Credit to Joachim Heintz
26 ;gives stereo output regardless your soundfile is mono or stereo
27 Sfil, kspeed, iskip, iloop xin
28 ichn filenchnls Sfil
29 if ichn == 1 then
30 aL diskin2 Sfil, kspeed, iskip, iloop
31 aR = aL
32 else
33 aL, aR diskin2 Sfil, kspeed, iskip, iloop
34 endif
35 xout aL, aR
36 endop
37
38
39 instr 1 ;GUI
40
41 Sfile_new strcpy "" ;INIT TO EMPTY STRING
42
43 ktrig metro 10
44 if (ktrig == 1) then
45 kfco invalue "Filter_Cutoff"
46 gkfco tablei kfco, giExp20000, 1
47 outvalue "Filter_Cutoff_Value", gkfco
48 gkres invalue "Resonance"
49 gkamp invalue "Amplitude"
50
51 gkmode invalue "Type"
52 gkskip invalue "Initialisation"
53
54 gSfile invalue "_Browse"
55 Sfile_old strcpyk Sfile_new
56 Sfile_new strcpyk gSfile
57 gkfile strcmpk Sfile_new, Sfile_old
58 endif
59 endin
60
61 instr 2
62 kporttime linseg 0,0.001,0.005,1,0.005 ;CREATE A VARIABLE FUNCTION THAT RAPIDLY RAMPS UP TO A SET VALUE
63 kfco portk gkfco, kporttime ;SMOOTH MOVEMENT OF SLIDER VARIABLE
64
65 kNew_file changed gkfile ;GENERATE A MOMENTARY '1' PULSE IN OUTPUT 'kSwitch' IF ANY OF THE SCANNED INPUT VARIABLES CHANGE. (OUTPUT 'kSwitch' IS NORMALLY ZERO)
66 if kNew_file=1 then ;IF I-RATE VARIABLE CHANGE TRIGGER IS '1'...
67 reinit NEW_FILE ;BEGIN A REINITIALISATION PASS FROM LABEL 'START'
68 endif
69 NEW_FILE:
70 ;OUTPUTS OPCODE FILE | SPEED | INSKIP | LOOPING (0=OFF 1=ON)
71 asigL, asigR FilePlay2 gSfile, 1, 0, 1 ;GENERATE 2 AUDIO SIGNALS FROM A STEREO SOUND FILE
72 rireturn ;RETURN FROM REINITIALISATION PASS TO PERFORMANCE TIME PASSES
73
74 kSwitch changed gkmode, gkskip ;GENERATE A MOMENTARY '1' PULSE IN OUTPUT 'kSwitch' IF ANY OF THE SCANNED INPUT VARIABLES CHANGE. (OUTPUT 'kSwitch' IS NORMALLY ZERO)
75 if kSwitch=1 then ;IF I-RATE VARIABLE CHANGE TRIGGER IS '1'...
76 reinit START ;BEGIN A REINITIALISATION PASS FROM LABEL 'START'
77 endif
78 START:
79 aresL bqrez asigL, kfco, gkres , i(gkmode), i(gkskip)
80 aresR bqrez asigR, kfco, gkres , i(gkmode), i(gkskip)
81 rireturn ;RETURN FROM REINITIALISATION PASS TO PERFORMANCE TIME PASSES
82 outs aresL * gkamp, aresR * gkamp ;SEND FILTER OUTPUT TO THE AUDIO OUTPUTS, RESCALE USING SLIDER VARIABLE gkgain
83 endin
84 </CsInstruments>
85 <CsScore>
86 ;INSTR | START | DURATION
87 i 1 0 3600 ;INSTRUMENT 1 PLAYS FOR 1 HOUR
88 </CsScore>
89 </CsoundSynthesizer>
90
91 <bsbPanel>
92 <label>Widgets</label>
93 <objectName/>
94 <x>374</x>
95 <y>367</y>
96 <width>785</width>
97 <height>296</height>
98 <visible>true</visible>
99 <uuid/>
100 <bgcolor mode="background">
101 <r>241</r>
102 <g>226</g>
103 <b>185</b>
104 </bgcolor>
105 <bsbObject version="2" type="BSBLabel">
106 <objectName/>
107 <x>2</x>
108 <y>2</y>
109 <width>512</width>
110 <height>292</height>
111 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
112 <visible>true</visible>
113 <midichan>0</midichan>
114 <midicc>0</midicc>
115 <label>bqrez</label>
116 <alignment>center</alignment>
117 <font>Liberation Sans</font>
118 <fontsize>18</fontsize>
119 <precision>3</precision>
120 <color>
121 <r>0</r>
122 <g>0</g>
123 <b>0</b>
124 </color>
125 <bgcolor mode="background">
126 <r>106</r>
127 <g>117</g>
128 <b>150</b>
129 </bgcolor>
130 <bordermode>border</bordermode>
131 <borderradius>5</borderradius>
132 <borderwidth>2</borderwidth>
133 </bsbObject>
134 <bsbObject version="2" type="BSBLabel">
135 <objectName/>
136 <x>515</x>
137 <y>2</y>
138 <width>266</width>
139 <height>292</height>
140 <uuid>{74928ed2-b701-4668-9a11-74763d317e9b}</uuid>
141 <visible>true</visible>
142 <midichan>0</midichan>
143 <midicc>0</midicc>
144 <label>bqrez</label>
145 <alignment>center</alignment>
146 <font>Liberation Sans</font>
147 <fontsize>18</fontsize>
148 <precision>3</precision>
149 <color>
150 <r>0</r>
151 <g>0</g>
152 <b>0</b>
153 </color>
154 <bgcolor mode="background">
155 <r>106</r>
156 <g>117</g>
157 <b>150</b>
158 </bgcolor>
159 <bordermode>border</bordermode>
160 <borderradius>5</borderradius>
161 <borderwidth>2</borderwidth>
162 </bsbObject>
163 <bsbObject version="2" type="BSBLabel">
164 <objectName/>
165 <x>518</x>
166 <y>21</y>
167 <width>263</width>
168 <height>270</height>
169 <uuid>{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}</uuid>
170 <visible>true</visible>
171 <midichan>0</midichan>
172 <midicc>0</midicc>
173 <label>--------------------------------------------------------------
174 bqrez is an implementation of a second-order multi-mode filter. Its input arguments are for filter cutoff frequency, amount of resonance, a five-way switch selecting filter mode and a 2-way switch selecting whether the data space for feedback within the filter is initially cleared or allowed to retain previously held information. Use of resonance can create large increases in amplitude in the output signal. In may be necessary, therefore, to rescale the amplitude of the output signal. In this example a slider has been provided to achieve this.</label>
175 <alignment>left</alignment>
176 <font>Arial</font>
177 <fontsize>14</fontsize>
178 <precision>3</precision>
179 <color>
180 <r>0</r>
181 <g>0</g>
182 <b>0</b>
183 </color>
184 <bgcolor mode="nobackground">
185 <r>255</r>
186 <g>255</g>
187 <b>255</b>
188 </bgcolor>
189 <bordermode>noborder</bordermode>
190 <borderradius>1</borderradius>
191 <borderwidth>1</borderwidth>
192 </bsbObject>
193 <bsbObject version="2" type="BSBButton">
194 <objectName/>
195 <x>8</x>
196 <y>8</y>
197 <width>100</width>
198 <height>30</height>
199 <uuid>{24979132-c53f-4414-ac6b-6b4f503ecfe8}</uuid>
200 <visible>true</visible>
201 <midichan>0</midichan>
202 <midicc>0</midicc>
203 <type>event</type>
204 <pressedValue>1.00000000</pressedValue>
205 <stringvalue/>
206 <text> ON / OFF</text>
207 <image>/</image>
208 <eventLine>i 2 0 -1</eventLine>
209 <latch>true</latch>
210 <latched>false</latched>
211 </bsbObject>
212 <bsbObject version="2" type="BSBDisplay">
213 <objectName>Filter_Cutoff_Value</objectName>
214 <x>448</x>
215 <y>118</y>
216 <width>60</width>
217 <height>30</height>
218 <uuid>{745d6bee-b951-4a03-9fe8-9e10d5ae4556}</uuid>
219 <visible>true</visible>
220 <midichan>0</midichan>
221 <midicc>0</midicc>
222 <label>757.130</label>
223 <alignment>right</alignment>
224 <font>Arial</font>
225 <fontsize>9</fontsize>
226 <precision>3</precision>
227 <color>
228 <r>0</r>
229 <g>0</g>
230 <b>0</b>
231 </color>
232 <bgcolor mode="nobackground">
233 <r>255</r>
234 <g>255</g>
235 <b>255</b>
236 </bgcolor>
237 <bordermode>noborder</bordermode>
238 <borderradius>1</borderradius>
239 <borderwidth>1</borderwidth>
240 </bsbObject>
241 <bsbObject version="2" type="BSBHSlider">
242 <objectName>Filter_Cutoff</objectName>
243 <x>8</x>
244 <y>101</y>
245 <width>500</width>
246 <height>27</height>
247 <uuid>{06814721-6151-4baa-84e2-8f39843b07a4}</uuid>
248 <visible>true</visible>
249 <midichan>0</midichan>
250 <midicc>0</midicc>
251 <minimum>0.00000000</minimum>
252 <maximum>1.00000000</maximum>
253 <value>0.52600000</value>
254 <mode>lin</mode>
255 <mouseControl act="jump">continuous</mouseControl>
256 <resolution>-1.00000000</resolution>
257 <randomizable group="0">false</randomizable>
258 </bsbObject>
259 <bsbObject version="2" type="BSBLabel">
260 <objectName/>
261 <x>8</x>
262 <y>118</y>
263 <width>180</width>
264 <height>30</height>
265 <uuid>{c6d7165c-6730-426f-b293-52b411bc73cf}</uuid>
266 <visible>true</visible>
267 <midichan>0</midichan>
268 <midicc>0</midicc>
269 <label>Filter Cutoff</label>
270 <alignment>left</alignment>
271 <font>Arial</font>
272 <fontsize>10</fontsize>
273 <precision>3</precision>
274 <color>
275 <r>0</r>
276 <g>0</g>
277 <b>0</b>
278 </color>
279 <bgcolor mode="nobackground">
280 <r>255</r>
281 <g>255</g>
282 <b>255</b>
283 </bgcolor>
284 <bordermode>noborder</bordermode>
285 <borderradius>1</borderradius>
286 <borderwidth>1</borderwidth>
287 </bsbObject>
288 <bsbObject version="2" type="BSBButton">
289 <objectName>_Browse</objectName>
290 <x>8</x>
291 <y>254</y>
292 <width>170</width>
293 <height>30</height>
294 <uuid>{b9431a61-61f7-432b-bf6f-c47ddc7f9050}</uuid>
295 <visible>true</visible>
296 <midichan>0</midichan>
297 <midicc>0</midicc>
298 <type>value</type>
299 <pressedValue>1.00000000</pressedValue>
300 <stringvalue>Seashore.wav</stringvalue>
301 <text>Browse Audio File</text>
302 <image>/</image>
303 <eventLine/>
304 <latch>false</latch>
305 <latched>false</latched>
306 </bsbObject>
307 <bsbObject version="2" type="BSBLineEdit">
308 <objectName>_Browse</objectName>
309 <x>179</x>
310 <y>255</y>
311 <width>330</width>
312 <height>28</height>
313 <uuid>{68b5f90b-b78e-4581-b434-232db5f4c40f}</uuid>
314 <visible>true</visible>
315 <midichan>0</midichan>
316 <midicc>0</midicc>
317 <label>Seashore.wav</label>
318 <alignment>left</alignment>
319 <font>Arial</font>
320 <fontsize>10</fontsize>
321 <precision>3</precision>
322 <color>
323 <r>0</r>
324 <g>0</g>
325 <b>0</b>
326 </color>
327 <bgcolor mode="nobackground">
328 <r>229</r>
329 <g>229</g>
330 <b>229</b>
331 </bgcolor>
332 <background>nobackground</background>
333 </bsbObject>
334 <bsbObject version="2" type="BSBLabel">
335 <objectName/>
336 <x>8</x>
337 <y>233</y>
338 <width>150</width>
339 <height>30</height>
340 <uuid>{936f6eb0-5225-4bd7-a5fe-a49df1c9c5ac}</uuid>
341 <visible>true</visible>
342 <midichan>0</midichan>
343 <midicc>0</midicc>
344 <label>Audio File</label>
345 <alignment>left</alignment>
346 <font>Arial</font>
347 <fontsize>10</fontsize>
348 <precision>3</precision>
349 <color>
350 <r>0</r>
351 <g>0</g>
352 <b>0</b>
353 </color>
354 <bgcolor mode="nobackground">
355 <r>255</r>
356 <g>255</g>
357 <b>255</b>
358 </bgcolor>
359 <bordermode>noborder</bordermode>
360 <borderradius>1</borderradius>
361 <borderwidth>1</borderwidth>
362 </bsbObject>
363 <bsbObject version="2" type="BSBLabel">
364 <objectName/>
365 <x>8</x>
366 <y>203</y>
367 <width>180</width>
368 <height>30</height>
369 <uuid>{2e52a7a7-dc13-405e-896d-db2a7431d8dd}</uuid>
370 <visible>true</visible>
371 <midichan>0</midichan>
372 <midicc>0</midicc>
373 <label>Output Amplitude Scaling</label>
374 <alignment>left</alignment>
375 <font>Arial</font>
376 <fontsize>10</fontsize>
377 <precision>3</precision>
378 <color>
379 <r>0</r>
380 <g>0</g>
381 <b>0</b>
382 </color>
383 <bgcolor mode="nobackground">
384 <r>255</r>
385 <g>255</g>
386 <b>255</b>
387 </bgcolor>
388 <bordermode>noborder</bordermode>
389 <borderradius>1</borderradius>
390 <borderwidth>1</borderwidth>
391 </bsbObject>
392 <bsbObject version="2" type="BSBHSlider">
393 <objectName>Amplitude</objectName>
394 <x>8</x>
395 <y>186</y>
396 <width>500</width>
397 <height>27</height>
398 <uuid>{6ab84e0f-82a7-4b9c-af23-35bd7d9b7fa2}</uuid>
399 <visible>true</visible>
400 <midichan>0</midichan>
401 <midicc>0</midicc>
402 <minimum>0.00000000</minimum>
403 <maximum>1.00000000</maximum>
404 <value>0.12600000</value>
405 <mode>lin</mode>
406 <mouseControl act="jump">continuous</mouseControl>
407 <resolution>-1.00000000</resolution>
408 <randomizable group="0">false</randomizable>
409 </bsbObject>
410 <bsbObject version="2" type="BSBDisplay">
411 <objectName>Amplitude</objectName>
412 <x>448</x>
413 <y>203</y>
414 <width>60</width>
415 <height>30</height>
416 <uuid>{99d6bf8b-3c85-4911-a29a-7dd678a940ed}</uuid>
417 <visible>true</visible>
418 <midichan>0</midichan>
419 <midicc>0</midicc>
420 <label>0.126</label>
421 <alignment>right</alignment>
422 <font>Arial</font>
423 <fontsize>9</fontsize>
424 <precision>3</precision>
425 <color>
426 <r>0</r>
427 <g>0</g>
428 <b>0</b>
429 </color>
430 <bgcolor mode="nobackground">
431 <r>255</r>
432 <g>255</g>
433 <b>255</b>
434 </bgcolor>
435 <bordermode>noborder</bordermode>
436 <borderradius>1</borderradius>
437 <borderwidth>1</borderwidth>
438 </bsbObject>
439 <bsbObject version="2" type="BSBButton">
440 <objectName>Initialisation</objectName>
441 <x>380</x>
442 <y>52</y>
443 <width>130</width>
444 <height>30</height>
445 <uuid>{b6345774-7938-4e62-9d8b-0ada81f7bcc5}</uuid>
446 <visible>true</visible>
447 <midichan>0</midichan>
448 <midicc>0</midicc>
449 <type>value</type>
450 <pressedValue>1.00000000</pressedValue>
451 <stringvalue/>
452 <text> No Initialisation</text>
453 <image>/</image>
454 <eventLine/>
455 <latch>true</latch>
456 <latched>false</latched>
457 </bsbObject>
458 <bsbObject version="2" type="BSBLabel">
459 <objectName/>
460 <x>170</x>
461 <y>52</y>
462 <width>84</width>
463 <height>29</height>
464 <uuid>{257d2fe0-c15d-4d4e-8f40-fc1ea010d5bf}</uuid>
465 <visible>true</visible>
466 <midichan>0</midichan>
467 <midicc>0</midicc>
468 <label>Type</label>
469 <alignment>right</alignment>
470 <font>Arial</font>
471 <fontsize>10</fontsize>
472 <precision>3</precision>
473 <color>
474 <r>0</r>
475 <g>0</g>
476 <b>0</b>
477 </color>
478 <bgcolor mode="nobackground">
479 <r>255</r>
480 <g>255</g>
481 <b>255</b>
482 </bgcolor>
483 <bordermode>noborder</bordermode>
484 <borderradius>1</borderradius>
485 <borderwidth>1</borderwidth>
486 </bsbObject>
487 <bsbObject version="2" type="BSBDropdown">
488 <objectName>Type</objectName>
489 <x>255</x>
490 <y>52</y>
491 <width>120</width>
492 <height>30</height>
493 <uuid>{e804f0ba-085b-49ac-8078-0b38a0fb498a}</uuid>
494 <visible>true</visible>
495 <midichan>0</midichan>
496 <midicc>0</midicc>
497 <bsbDropdownItemList>
498 <bsbDropdownItem>
499 <name>Low-pass</name>
500 <value>0</value>
501 <stringvalue/>
502 </bsbDropdownItem>
503 <bsbDropdownItem>
504 <name>High-pass</name>
505 <value>1</value>
506 <stringvalue/>
507 </bsbDropdownItem>
508 <bsbDropdownItem>
509 <name>Band-pass</name>
510 <value>2</value>
511 <stringvalue/>
512 </bsbDropdownItem>
513 <bsbDropdownItem>
514 <name>Band-reject</name>
515 <value>3</value>
516 <stringvalue/>
517 </bsbDropdownItem>
518 <bsbDropdownItem>
519 <name>All-pass</name>
520 <value>4</value>
521 <stringvalue/>
522 </bsbDropdownItem>
523 </bsbDropdownItemList>
524 <selectedIndex>0</selectedIndex>
525 <randomizable group="0">false</randomizable>
526 </bsbObject>
527 <bsbObject version="2" type="BSBLabel">
528 <objectName/>
529 <x>8</x>
530 <y>156</y>
531 <width>180</width>
532 <height>30</height>
533 <uuid>{4b8cc27a-e102-4e54-abd9-b563c507ee44}</uuid>
534 <visible>true</visible>
535 <midichan>0</midichan>
536 <midicc>0</midicc>
537 <label>Resonance</label>
538 <alignment>left</alignment>
539 <font>Arial</font>
540 <fontsize>10</fontsize>
541 <precision>3</precision>
542 <color>
543 <r>0</r>
544 <g>0</g>
545 <b>0</b>
546 </color>
547 <bgcolor mode="nobackground">
548 <r>255</r>
549 <g>255</g>
550 <b>255</b>
551 </bgcolor>
552 <bordermode>noborder</bordermode>
553 <borderradius>1</borderradius>
554 <borderwidth>1</borderwidth>
555 </bsbObject>
556 <bsbObject version="2" type="BSBHSlider">
557 <objectName>Resonance</objectName>
558 <x>8</x>
559 <y>139</y>
560 <width>500</width>
561 <height>27</height>
562 <uuid>{eec983db-87f2-4ff0-b409-ed8ec573b9ae}</uuid>
563 <visible>true</visible>
564 <midichan>0</midichan>
565 <midicc>0</midicc>
566 <minimum>1.00000000</minimum>
567 <maximum>100.00000000</maximum>
568 <value>16.24600000</value>
569 <mode>lin</mode>
570 <mouseControl act="jump">continuous</mouseControl>
571 <resolution>-1.00000000</resolution>
572 <randomizable group="0">false</randomizable>
573 </bsbObject>
574 <bsbObject version="2" type="BSBDisplay">
575 <objectName>Resonance</objectName>
576 <x>448</x>
577 <y>156</y>
578 <width>60</width>
579 <height>30</height>
580 <uuid>{bf739784-7c38-4ecb-90ac-9a603e010479}</uuid>
581 <visible>true</visible>
582 <midichan>0</midichan>
583 <midicc>0</midicc>
584 <label>16.246</label>
585 <alignment>right</alignment>
586 <font>Arial</font>
587 <fontsize>9</fontsize>
588 <precision>3</precision>
589 <color>
590 <r>0</r>
591 <g>0</g>
592 <b>0</b>
593 </color>
594 <bgcolor mode="nobackground">
595 <r>255</r>
596 <g>255</g>
597 <b>255</b>
598 </bgcolor>
599 <bordermode>noborder</bordermode>
600 <borderradius>1</borderradius>
601 <borderwidth>1</borderwidth>
602 </bsbObject>
603 </bsbPanel>
604 <bsbPresets>
605 </bsbPresets>
606 <EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="false" loopStart="0" loopEnd="0"> </EventPanel>