Debian Codegraph @

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

raw
1 ;Written by Iain McCurdy, 2006
2
3 ;Modified for QuteCsound by René, November 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 = 100 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
19 nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
20 0dbfs = 1 ;MAXIMUM SOUND INTENSITY LEVEL REGARDLESS OF BIT DEPTH
21
22
23 ;TABLES FOR EXP SLIDER
24 giExp10000 ftgen 0, 0, 129, -25, 0, 0.1, 128, 10000.0
25 giExp20000 ftgen 0, 0, 129, -25, 0, 20.0, 128, 20000.0
26
27
28 opcode FilePlay2, aa, Skoo ; Credit to Joachim Heintz
29 ;gives stereo output regardless your soundfile is mono or stereo
30 Sfil, kspeed, iskip, iloop xin
31 ichn filenchnls Sfil
32 if ichn == 1 then
33 aL diskin2 Sfil, kspeed, iskip, iloop
34 aR = aL
35 else
36 aL, aR diskin2 Sfil, kspeed, iskip, iloop
37 endif
38 xout aL, aR
39 endop
40
41
42 instr 1 ;GUI
43 ktrig metro 10
44 if (ktrig == 1) then
45
46 Sfile_new strcpy "" ;INIT TO EMPTY STRING
47
48 kcf invalue "Filter_Cutoff"
49 gkcf tablei kcf, giExp20000, 1
50 outvalue "Filter_Cutoff_Value", gkcf
51 kbw invalue "Bandwidth"
52 gkbw tablei kbw, giExp10000, 1
53 outvalue "Bandwidth_Value", gkbw
54 gkamp invalue "Amplitude"
55
56 gkskip invalue "Initialisation"
57 gkscl invalue "Mode"
58
59 gSfile invalue "_Browse"
60 Sfile_old strcpyk Sfile_new
61 Sfile_new strcpyk gSfile
62 gkfile strcmpk Sfile_new, Sfile_old
63 endif
64 endin
65
66 instr 2
67 kporttime linseg 0,0.001,0.005,1,0.005 ;CREATE A VARIABLE FUNCTION THAT RAPIDLY RAMPS UP TO A SET VALUE
68 kcf portk gkcf, kporttime ;SMOOTH MOVEMENT OF SLIDER VARIABLE
69
70 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)
71 if kNew_file=1 then ;IF I-RATE VARIABLE CHANGE TRIGGER IS '1'...
72 reinit NEW_FILE ;BEGIN A REINITIALISATION PASS FROM LABEL 'START'
73 endif
74 NEW_FILE:
75 ;OUTPUTS OPCODE FILE | SPEED | INSKIP | LOOPING (0=OFF 1=ON)
76 asigL, asigR FilePlay2 gSfile, 1, 0, 1 ;GENERATE 2 AUDIO SIGNALS FROM A STEREO SOUND FILE
77 rireturn ;RETURN FROM REINITIALISATION PASS TO PERFORMANCE TIME PASSES
78
79 kSwitch changed gkscl, gkskip ;GENERATE A MOMENTARY '1' PULSE IN OUTPUT 'kSwitch' IF ANY OF THE SCANNED INPUT VARIABLES CHANGE. (OUTPUT 'kSwitch' IS NORMALLY ZERO)
80 if kSwitch=1 then ;IF I-RATE VARIABLE CHANGE TRIGGER IS '1'...
81 reinit START ;BEGIN A REINITIALISATION PASS FROM LABEL 'START'
82 endif
83 START:
84 aresL reson asigL, kcf, gkbw , i(gkscl), i(gkskip)
85 aresR reson asigR, kcf, gkbw , i(gkscl), i(gkskip)
86 rireturn ;RETURN FROM REINITIALISATION PASS TO PERFORMANCE TIME PASSES
87 outs aresL * gkamp, aresR * gkamp ;SEND FILTER OUTPUT TO THE AUDIO OUTPUTS AND SCALE USING THE FLTK SLIDER VARIABLE gkamp
88 endin
89 </CsInstruments>
90 <CsScore>
91 ;INSTR | START | DURATION
92 i 1 0 3600 ;GUI
93 </CsScore>
94 </CsoundSynthesizer>
95
96 <bsbPanel>
97 <label>Widgets</label>
98 <objectName/>
99 <x>72</x>
100 <y>179</y>
101 <width>400</width>
102 <height>200</height>
103 <visible>true</visible>
104 <uuid/>
105 <bgcolor mode="background">
106 <r>241</r>
107 <g>226</g>
108 <b>185</b>
109 </bgcolor>
110 <bsbObject version="2" type="BSBLabel">
111 <objectName/>
112 <x>2</x>
113 <y>2</y>
114 <width>512</width>
115 <height>270</height>
116 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
117 <visible>true</visible>
118 <midichan>0</midichan>
119 <midicc>0</midicc>
120 <label>reson</label>
121 <alignment>center</alignment>
122 <font>Liberation Sans</font>
123 <fontsize>18</fontsize>
124 <precision>3</precision>
125 <color>
126 <r>0</r>
127 <g>0</g>
128 <b>0</b>
129 </color>
130 <bgcolor mode="background">
131 <r>106</r>
132 <g>117</g>
133 <b>150</b>
134 </bgcolor>
135 <bordermode>border</bordermode>
136 <borderradius>5</borderradius>
137 <borderwidth>2</borderwidth>
138 </bsbObject>
139 <bsbObject version="2" type="BSBLabel">
140 <objectName/>
141 <x>515</x>
142 <y>2</y>
143 <width>451</width>
144 <height>270</height>
145 <uuid>{74928ed2-b701-4668-9a11-74763d317e9b}</uuid>
146 <visible>true</visible>
147 <midichan>0</midichan>
148 <midicc>0</midicc>
149 <label>reson</label>
150 <alignment>center</alignment>
151 <font>Liberation Sans</font>
152 <fontsize>18</fontsize>
153 <precision>3</precision>
154 <color>
155 <r>0</r>
156 <g>0</g>
157 <b>0</b>
158 </color>
159 <bgcolor mode="background">
160 <r>106</r>
161 <g>117</g>
162 <b>150</b>
163 </bgcolor>
164 <bordermode>border</bordermode>
165 <borderradius>5</borderradius>
166 <borderwidth>2</borderwidth>
167 </bsbObject>
168 <bsbObject version="2" type="BSBLabel">
169 <objectName/>
170 <x>516</x>
171 <y>18</y>
172 <width>448</width>
173 <height>253</height>
174 <uuid>{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}</uuid>
175 <visible>true</visible>
176 <midichan>0</midichan>
177 <midicc>0</midicc>
178 <label>-------------------------------------------------------------------------------------------------------------
179 reson is an implementation of a resonant second-order band--pass filter. Its input arguments are for filter centre frequency (in hertz), bandwidth of the notch (also in hertz) a 3-way switch offering a choice 3 modes by which the output amplitude will be dynamically scaled 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. The audible results of the reson filter are similar to those of a sweepable parametric EQ. Setting 'Scaling Mode' to 0 will provide the mose dynamically transparent effect but some manual rescaling of the amplitude of the output signal may be necessary. In this example this can be performed using the 'Output Amplitude Scaling' slider. Settings for 'Scaling Mode' of 1 or 2 force dynamic containment of the output signal similar to the effect of a compressor.</label>
180 <alignment>left</alignment>
181 <font>Liberation Sans</font>
182 <fontsize>14</fontsize>
183 <precision>3</precision>
184 <color>
185 <r>0</r>
186 <g>0</g>
187 <b>0</b>
188 </color>
189 <bgcolor mode="nobackground">
190 <r>255</r>
191 <g>255</g>
192 <b>255</b>
193 </bgcolor>
194 <bordermode>noborder</bordermode>
195 <borderradius>1</borderradius>
196 <borderwidth>1</borderwidth>
197 </bsbObject>
198 <bsbObject version="2" type="BSBButton">
199 <objectName/>
200 <x>8</x>
201 <y>6</y>
202 <width>100</width>
203 <height>30</height>
204 <uuid>{24979132-c53f-4414-ac6b-6b4f503ecfe8}</uuid>
205 <visible>true</visible>
206 <midichan>0</midichan>
207 <midicc>0</midicc>
208 <type>event</type>
209 <pressedValue>1.00000000</pressedValue>
210 <stringvalue/>
211 <text> ON / OFF</text>
212 <image>/</image>
213 <eventLine>i 2 0 -1</eventLine>
214 <latch>true</latch>
215 <latched>false</latched>
216 </bsbObject>
217 <bsbObject version="2" type="BSBDisplay">
218 <objectName>Filter_Cutoff_Value</objectName>
219 <x>448</x>
220 <y>63</y>
221 <width>60</width>
222 <height>30</height>
223 <uuid>{745d6bee-b951-4a03-9fe8-9e10d5ae4556}</uuid>
224 <visible>true</visible>
225 <midichan>0</midichan>
226 <midicc>0</midicc>
227 <label>650.411</label>
228 <alignment>right</alignment>
229 <font>Arial</font>
230 <fontsize>9</fontsize>
231 <precision>3</precision>
232 <color>
233 <r>0</r>
234 <g>0</g>
235 <b>0</b>
236 </color>
237 <bgcolor mode="nobackground">
238 <r>255</r>
239 <g>255</g>
240 <b>255</b>
241 </bgcolor>
242 <bordermode>noborder</bordermode>
243 <borderradius>1</borderradius>
244 <borderwidth>1</borderwidth>
245 </bsbObject>
246 <bsbObject version="2" type="BSBHSlider">
247 <objectName>Filter_Cutoff</objectName>
248 <x>8</x>
249 <y>46</y>
250 <width>500</width>
251 <height>27</height>
252 <uuid>{06814721-6151-4baa-84e2-8f39843b07a4}</uuid>
253 <visible>true</visible>
254 <midichan>0</midichan>
255 <midicc>0</midicc>
256 <minimum>0.00000000</minimum>
257 <maximum>1.00000000</maximum>
258 <value>0.50400000</value>
259 <mode>lin</mode>
260 <mouseControl act="jump">continuous</mouseControl>
261 <resolution>-1.00000000</resolution>
262 <randomizable group="0">false</randomizable>
263 </bsbObject>
264 <bsbObject version="2" type="BSBLabel">
265 <objectName/>
266 <x>8</x>
267 <y>63</y>
268 <width>180</width>
269 <height>30</height>
270 <uuid>{c6d7165c-6730-426f-b293-52b411bc73cf}</uuid>
271 <visible>true</visible>
272 <midichan>0</midichan>
273 <midicc>0</midicc>
274 <label>Filter Cutoff</label>
275 <alignment>left</alignment>
276 <font>Arial</font>
277 <fontsize>10</fontsize>
278 <precision>3</precision>
279 <color>
280 <r>0</r>
281 <g>0</g>
282 <b>0</b>
283 </color>
284 <bgcolor mode="nobackground">
285 <r>255</r>
286 <g>255</g>
287 <b>255</b>
288 </bgcolor>
289 <bordermode>noborder</bordermode>
290 <borderradius>1</borderradius>
291 <borderwidth>1</borderwidth>
292 </bsbObject>
293 <bsbObject version="2" type="BSBHSlider">
294 <objectName>Bandwidth</objectName>
295 <x>8</x>
296 <y>84</y>
297 <width>500</width>
298 <height>27</height>
299 <uuid>{42fe25e5-e98f-4f00-872c-f791822a1b3e}</uuid>
300 <visible>true</visible>
301 <midichan>0</midichan>
302 <midicc>0</midicc>
303 <minimum>0.00000000</minimum>
304 <maximum>1.00000000</maximum>
305 <value>0.84000000</value>
306 <mode>lin</mode>
307 <mouseControl act="jump">continuous</mouseControl>
308 <resolution>-1.00000000</resolution>
309 <randomizable group="0">false</randomizable>
310 </bsbObject>
311 <bsbObject version="2" type="BSBDisplay">
312 <objectName>Bandwidth_Value</objectName>
313 <x>448</x>
314 <y>101</y>
315 <width>60</width>
316 <height>30</height>
317 <uuid>{a8f35453-f236-447d-88d9-1a0b135383b6}</uuid>
318 <visible>true</visible>
319 <midichan>0</midichan>
320 <midicc>0</midicc>
321 <label>1586.494</label>
322 <alignment>right</alignment>
323 <font>Arial</font>
324 <fontsize>9</fontsize>
325 <precision>3</precision>
326 <color>
327 <r>0</r>
328 <g>0</g>
329 <b>0</b>
330 </color>
331 <bgcolor mode="nobackground">
332 <r>255</r>
333 <g>255</g>
334 <b>255</b>
335 </bgcolor>
336 <bordermode>noborder</bordermode>
337 <borderradius>1</borderradius>
338 <borderwidth>1</borderwidth>
339 </bsbObject>
340 <bsbObject version="2" type="BSBButton">
341 <objectName>Initialisation</objectName>
342 <x>380</x>
343 <y>6</y>
344 <width>130</width>
345 <height>30</height>
346 <uuid>{88395e38-ecab-4818-bef3-1a18b504f914}</uuid>
347 <visible>true</visible>
348 <midichan>0</midichan>
349 <midicc>0</midicc>
350 <type>value</type>
351 <pressedValue>1.00000000</pressedValue>
352 <stringvalue/>
353 <text> No Initialisation</text>
354 <image>/</image>
355 <eventLine/>
356 <latch>true</latch>
357 <latched>false</latched>
358 </bsbObject>
359 <bsbObject version="2" type="BSBButton">
360 <objectName>_Browse</objectName>
361 <x>8</x>
362 <y>228</y>
363 <width>170</width>
364 <height>30</height>
365 <uuid>{43341095-bc3a-4607-bd0e-01254da7bc67}</uuid>
366 <visible>true</visible>
367 <midichan>0</midichan>
368 <midicc>0</midicc>
369 <type>value</type>
370 <pressedValue>1.00000000</pressedValue>
371 <stringvalue>Seashore.wav</stringvalue>
372 <text>Browse Audio File</text>
373 <image>/</image>
374 <eventLine/>
375 <latch>false</latch>
376 <latched>false</latched>
377 </bsbObject>
378 <bsbObject version="2" type="BSBLineEdit">
379 <objectName>_Browse</objectName>
380 <x>178</x>
381 <y>229</y>
382 <width>330</width>
383 <height>28</height>
384 <uuid>{b66f3878-dfd0-4290-9b9d-73be88197222}</uuid>
385 <visible>true</visible>
386 <midichan>0</midichan>
387 <midicc>0</midicc>
388 <label>Seashore.wav</label>
389 <alignment>left</alignment>
390 <font>Arial</font>
391 <fontsize>10</fontsize>
392 <precision>3</precision>
393 <color>
394 <r>0</r>
395 <g>0</g>
396 <b>0</b>
397 </color>
398 <bgcolor mode="nobackground">
399 <r>229</r>
400 <g>229</g>
401 <b>229</b>
402 </bgcolor>
403 <background>nobackground</background>
404 </bsbObject>
405 <bsbObject version="2" type="BSBLabel">
406 <objectName/>
407 <x>8</x>
408 <y>206</y>
409 <width>160</width>
410 <height>30</height>
411 <uuid>{7e1e7af4-88dd-4046-a781-fa2dc828b980}</uuid>
412 <visible>true</visible>
413 <midichan>0</midichan>
414 <midicc>0</midicc>
415 <label>File Input</label>
416 <alignment>left</alignment>
417 <font>Arial</font>
418 <fontsize>10</fontsize>
419 <precision>3</precision>
420 <color>
421 <r>0</r>
422 <g>0</g>
423 <b>0</b>
424 </color>
425 <bgcolor mode="nobackground">
426 <r>255</r>
427 <g>255</g>
428 <b>255</b>
429 </bgcolor>
430 <bordermode>noborder</bordermode>
431 <borderradius>1</borderradius>
432 <borderwidth>1</borderwidth>
433 </bsbObject>
434 <bsbObject version="2" type="BSBDropdown">
435 <objectName>Mode</objectName>
436 <x>177</x>
437 <y>130</y>
438 <width>250</width>
439 <height>30</height>
440 <uuid>{b8bfe659-5312-49a2-9638-79871f93a3c3}</uuid>
441 <visible>true</visible>
442 <midichan>0</midichan>
443 <midicc>0</midicc>
444 <bsbDropdownItemList>
445 <bsbDropdownItem>
446 <name>None</name>
447 <value>0</value>
448 <stringvalue/>
449 </bsbDropdownItem>
450 <bsbDropdownItem>
451 <name>Peak Response Factor = 1</name>
452 <value>1</value>
453 <stringvalue/>
454 </bsbDropdownItem>
455 <bsbDropdownItem>
456 <name>Overall RMS Response Factor = 1</name>
457 <value>2</value>
458 <stringvalue/>
459 </bsbDropdownItem>
460 </bsbDropdownItemList>
461 <selectedIndex>0</selectedIndex>
462 <randomizable group="0">false</randomizable>
463 </bsbObject>
464 <bsbObject version="2" type="BSBLabel">
465 <objectName/>
466 <x>77</x>
467 <y>130</y>
468 <width>100</width>
469 <height>30</height>
470 <uuid>{ce8e6e3a-e84e-4ef0-9084-00ec44afb9ba}</uuid>
471 <visible>true</visible>
472 <midichan>0</midichan>
473 <midicc>0</midicc>
474 <label>Scaling Mode</label>
475 <alignment>right</alignment>
476 <font>Arial</font>
477 <fontsize>10</fontsize>
478 <precision>3</precision>
479 <color>
480 <r>0</r>
481 <g>0</g>
482 <b>0</b>
483 </color>
484 <bgcolor mode="nobackground">
485 <r>255</r>
486 <g>255</g>
487 <b>255</b>
488 </bgcolor>
489 <bordermode>noborder</bordermode>
490 <borderradius>1</borderradius>
491 <borderwidth>1</borderwidth>
492 </bsbObject>
493 <bsbObject version="2" type="BSBLabel">
494 <objectName/>
495 <x>8</x>
496 <y>184</y>
497 <width>160</width>
498 <height>30</height>
499 <uuid>{84df1cbe-b2a7-4a3c-bb4c-91bd48efb2ea}</uuid>
500 <visible>true</visible>
501 <midichan>0</midichan>
502 <midicc>0</midicc>
503 <label>Output Amplitude Scaling</label>
504 <alignment>left</alignment>
505 <font>Arial</font>
506 <fontsize>10</fontsize>
507 <precision>3</precision>
508 <color>
509 <r>0</r>
510 <g>0</g>
511 <b>0</b>
512 </color>
513 <bgcolor mode="nobackground">
514 <r>255</r>
515 <g>255</g>
516 <b>255</b>
517 </bgcolor>
518 <bordermode>noborder</bordermode>
519 <borderradius>1</borderradius>
520 <borderwidth>1</borderwidth>
521 </bsbObject>
522 <bsbObject version="2" type="BSBHSlider">
523 <objectName>Amplitude</objectName>
524 <x>8</x>
525 <y>167</y>
526 <width>500</width>
527 <height>27</height>
528 <uuid>{f4302743-9d62-480e-823e-48caef584b70}</uuid>
529 <visible>true</visible>
530 <midichan>0</midichan>
531 <midicc>0</midicc>
532 <minimum>0.00000000</minimum>
533 <maximum>1.00000000</maximum>
534 <value>0.03200000</value>
535 <mode>lin</mode>
536 <mouseControl act="jump">continuous</mouseControl>
537 <resolution>-1.00000000</resolution>
538 <randomizable group="0">false</randomizable>
539 </bsbObject>
540 <bsbObject version="2" type="BSBDisplay">
541 <objectName>Amplitude</objectName>
542 <x>448</x>
543 <y>184</y>
544 <width>60</width>
545 <height>30</height>
546 <uuid>{64e46c55-ba7a-4cc6-9b81-55365860a8f1}</uuid>
547 <visible>true</visible>
548 <midichan>0</midichan>
549 <midicc>0</midicc>
550 <label>0.032</label>
551 <alignment>right</alignment>
552 <font>Arial</font>
553 <fontsize>9</fontsize>
554 <precision>3</precision>
555 <color>
556 <r>0</r>
557 <g>0</g>
558 <b>0</b>
559 </color>
560 <bgcolor mode="nobackground">
561 <r>255</r>
562 <g>255</g>
563 <b>255</b>
564 </bgcolor>
565 <bordermode>noborder</bordermode>
566 <borderradius>1</borderradius>
567 <borderwidth>1</borderwidth>
568 </bsbObject>
569 <bsbObject version="2" type="BSBLabel">
570 <objectName/>
571 <x>8</x>
572 <y>101</y>
573 <width>180</width>
574 <height>30</height>
575 <uuid>{027163fb-bbfe-488e-9351-1c1cd9a9d626}</uuid>
576 <visible>true</visible>
577 <midichan>0</midichan>
578 <midicc>0</midicc>
579 <label>Bandwidth</label>
580 <alignment>left</alignment>
581 <font>Arial</font>
582 <fontsize>10</fontsize>
583 <precision>3</precision>
584 <color>
585 <r>0</r>
586 <g>0</g>
587 <b>0</b>
588 </color>
589 <bgcolor mode="nobackground">
590 <r>255</r>
591 <g>255</g>
592 <b>255</b>
593 </bgcolor>
594 <bordermode>noborder</bordermode>
595 <borderradius>1</borderradius>
596 <borderwidth>1</borderwidth>
597 </bsbObject>
598 </bsbPanel>
599 <bsbPresets>
600 </bsbPresets>
601 <EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="false" loopStart="0" loopEnd="0"> </EventPanel>