Debian Codegraph @

src/Examples/McCurdy Collection/Filters/areson.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 = 2 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
19 nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
20
21
22 ;TABLES FOR EXP SLIDER
23 giExp10000 ftgen 0, 0, 129, -25, 0, 0.1, 128, 10000.0
24 giExp20000 ftgen 0, 0, 129, -25, 0, 20.0, 128, 20000.0
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 1 ;GUI
42
43 Sfile_new strcpy "" ;INIT TO EMPTY STRING
44
45 ktrig metro 10
46 if (ktrig == 1) then
47 kcf invalue "Frequency"
48 gkcf tablei kcf, giExp20000, 1
49 outvalue "Frequency_Value", gkcf
50 kbw invalue "Bandwidth"
51 gkbw tablei kbw, giExp10000, 1
52 outvalue "Bandwidth_Value", gkbw
53 gkamp invalue "Amplitude"
54
55 gkscl invalue "Scaling_Mode"
56 gkskip invalue "Initialisation"
57
58 gSfile invalue "_Browse"
59 Sfile_old strcpyk Sfile_new
60 Sfile_new strcpyk gSfile
61 gkfile strcmpk Sfile_new, Sfile_old
62 endif
63 endin
64
65 instr 2
66 kporttime linseg 0,0.001,0.005,1,0.005 ;CREATE A VARIABLE FUNCTION THAT RAPIDLY RAMPS UP TO A SET VALUE
67 kcf portk gkcf, kporttime ;SMOOTH MOVEMENT OF SLIDER VARIABLE
68 kbw portk gkbw, 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 areson asigL, kcf, kbw , i(gkscl), i(gkskip) ;FILTER EACH CHANNEL SEPARATELY
85 aresR areson asigR, kcf, kbw , i(gkscl), i(gkskip) ;FILTER EACH CHANNEL SEPARATELY
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 ;INSTRUMENT 1 PLAYS FOR 1 HOUR
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>513</width>
115 <height>352</height>
116 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
117 <visible>true</visible>
118 <midichan>0</midichan>
119 <midicc>0</midicc>
120 <label>areson</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>516</x>
142 <y>2</y>
143 <width>335</width>
144 <height>352</height>
145 <uuid>{74928ed2-b701-4668-9a11-74763d317e9b}</uuid>
146 <visible>true</visible>
147 <midichan>0</midichan>
148 <midicc>0</midicc>
149 <label>areson</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>520</x>
171 <y>25</y>
172 <width>330</width>
173 <height>326</height>
174 <uuid>{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}</uuid>
175 <visible>true</visible>
176 <midichan>0</midichan>
177 <midicc>0</midicc>
178 <label>-------------------------------------------------------------------------------
179 areson is an implementation of a resonant second-order notch 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 methods 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 areson filter are not dissimilar to those of a phaser effect. Setting 'Scaling Mode' to 0 will provide the most 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>Arial</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>8</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>Frequency_Value</objectName>
219 <x>448</x>
220 <y>77</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>623.949</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>Frequency</objectName>
248 <x>8</x>
249 <y>60</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.49800000</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>77</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 Centre Frequency</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="BSBButton">
294 <objectName>_Browse</objectName>
295 <x>8</x>
296 <y>288</y>
297 <width>170</width>
298 <height>30</height>
299 <uuid>{b9431a61-61f7-432b-bf6f-c47ddc7f9050}</uuid>
300 <visible>true</visible>
301 <midichan>0</midichan>
302 <midicc>0</midicc>
303 <type>value</type>
304 <pressedValue>1.00000000</pressedValue>
305 <stringvalue>Seashore.wav</stringvalue>
306 <text>Browse Audio File</text>
307 <image>/</image>
308 <eventLine/>
309 <latch>false</latch>
310 <latched>false</latched>
311 </bsbObject>
312 <bsbObject version="2" type="BSBLineEdit">
313 <objectName>_Browse</objectName>
314 <x>179</x>
315 <y>289</y>
316 <width>330</width>
317 <height>28</height>
318 <uuid>{68b5f90b-b78e-4581-b434-232db5f4c40f}</uuid>
319 <visible>true</visible>
320 <midichan>0</midichan>
321 <midicc>0</midicc>
322 <label>Seashore.wav</label>
323 <alignment>left</alignment>
324 <font>Arial</font>
325 <fontsize>10</fontsize>
326 <precision>3</precision>
327 <color>
328 <r>0</r>
329 <g>0</g>
330 <b>0</b>
331 </color>
332 <bgcolor mode="nobackground">
333 <r>229</r>
334 <g>229</g>
335 <b>229</b>
336 </bgcolor>
337 <background>nobackground</background>
338 </bsbObject>
339 <bsbObject version="2" type="BSBLabel">
340 <objectName/>
341 <x>8</x>
342 <y>267</y>
343 <width>150</width>
344 <height>30</height>
345 <uuid>{936f6eb0-5225-4bd7-a5fe-a49df1c9c5ac}</uuid>
346 <visible>true</visible>
347 <midichan>0</midichan>
348 <midicc>0</midicc>
349 <label>Audio File</label>
350 <alignment>left</alignment>
351 <font>Arial</font>
352 <fontsize>10</fontsize>
353 <precision>3</precision>
354 <color>
355 <r>0</r>
356 <g>0</g>
357 <b>0</b>
358 </color>
359 <bgcolor mode="nobackground">
360 <r>255</r>
361 <g>255</g>
362 <b>255</b>
363 </bgcolor>
364 <bordermode>noborder</bordermode>
365 <borderradius>1</borderradius>
366 <borderwidth>1</borderwidth>
367 </bsbObject>
368 <bsbObject version="2" type="BSBLabel">
369 <objectName/>
370 <x>8</x>
371 <y>115</y>
372 <width>180</width>
373 <height>30</height>
374 <uuid>{f4029fbc-c802-493b-aacb-44a251dfd70c}</uuid>
375 <visible>true</visible>
376 <midichan>0</midichan>
377 <midicc>0</midicc>
378 <label>Bandwidth</label>
379 <alignment>left</alignment>
380 <font>Arial</font>
381 <fontsize>10</fontsize>
382 <precision>3</precision>
383 <color>
384 <r>0</r>
385 <g>0</g>
386 <b>0</b>
387 </color>
388 <bgcolor mode="nobackground">
389 <r>255</r>
390 <g>255</g>
391 <b>255</b>
392 </bgcolor>
393 <bordermode>noborder</bordermode>
394 <borderradius>1</borderradius>
395 <borderwidth>1</borderwidth>
396 </bsbObject>
397 <bsbObject version="2" type="BSBHSlider">
398 <objectName>Bandwidth</objectName>
399 <x>8</x>
400 <y>98</y>
401 <width>500</width>
402 <height>27</height>
403 <uuid>{b5b98b11-0602-412e-9830-0bbe82f5476b}</uuid>
404 <visible>true</visible>
405 <midichan>0</midichan>
406 <midicc>0</midicc>
407 <minimum>0.00000000</minimum>
408 <maximum>1.00000000</maximum>
409 <value>0.55400000</value>
410 <mode>lin</mode>
411 <mouseControl act="jump">continuous</mouseControl>
412 <resolution>-1.00000000</resolution>
413 <randomizable group="0">false</randomizable>
414 </bsbObject>
415 <bsbObject version="2" type="BSBDisplay">
416 <objectName>Bandwidth_Value</objectName>
417 <x>448</x>
418 <y>115</y>
419 <width>60</width>
420 <height>30</height>
421 <uuid>{aa9d2e59-a8e3-4b3d-a00a-04fcecc3d502}</uuid>
422 <visible>true</visible>
423 <midichan>0</midichan>
424 <midicc>0</midicc>
425 <label>58.903</label>
426 <alignment>right</alignment>
427 <font>Arial</font>
428 <fontsize>9</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>8</x>
447 <y>229</y>
448 <width>180</width>
449 <height>30</height>
450 <uuid>{2e52a7a7-dc13-405e-896d-db2a7431d8dd}</uuid>
451 <visible>true</visible>
452 <midichan>0</midichan>
453 <midicc>0</midicc>
454 <label>Output Amplitude Scaling</label>
455 <alignment>left</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="BSBHSlider">
474 <objectName>Amplitude</objectName>
475 <x>8</x>
476 <y>212</y>
477 <width>500</width>
478 <height>27</height>
479 <uuid>{6ab84e0f-82a7-4b9c-af23-35bd7d9b7fa2}</uuid>
480 <visible>true</visible>
481 <midichan>0</midichan>
482 <midicc>0</midicc>
483 <minimum>0.00000000</minimum>
484 <maximum>1.00000000</maximum>
485 <value>0.18200000</value>
486 <mode>lin</mode>
487 <mouseControl act="jump">continuous</mouseControl>
488 <resolution>-1.00000000</resolution>
489 <randomizable group="0">false</randomizable>
490 </bsbObject>
491 <bsbObject version="2" type="BSBDisplay">
492 <objectName>Amplitude</objectName>
493 <x>448</x>
494 <y>229</y>
495 <width>60</width>
496 <height>30</height>
497 <uuid>{99d6bf8b-3c85-4911-a29a-7dd678a940ed}</uuid>
498 <visible>true</visible>
499 <midichan>0</midichan>
500 <midicc>0</midicc>
501 <label>0.182</label>
502 <alignment>right</alignment>
503 <font>Arial</font>
504 <fontsize>9</fontsize>
505 <precision>3</precision>
506 <color>
507 <r>0</r>
508 <g>0</g>
509 <b>0</b>
510 </color>
511 <bgcolor mode="nobackground">
512 <r>255</r>
513 <g>255</g>
514 <b>255</b>
515 </bgcolor>
516 <bordermode>noborder</bordermode>
517 <borderradius>1</borderradius>
518 <borderwidth>1</borderwidth>
519 </bsbObject>
520 <bsbObject version="2" type="BSBDropdown">
521 <objectName>Scaling_Mode</objectName>
522 <x>43</x>
523 <y>166</y>
524 <width>200</width>
525 <height>30</height>
526 <uuid>{6a55c957-42d0-48b7-b636-c5cbb2adc7d9}</uuid>
527 <visible>true</visible>
528 <midichan>0</midichan>
529 <midicc>0</midicc>
530 <bsbDropdownItemList>
531 <bsbDropdownItem>
532 <name>None</name>
533 <value>0</value>
534 <stringvalue/>
535 </bsbDropdownItem>
536 <bsbDropdownItem>
537 <name> Peak Response Factor = 1</name>
538 <value>1</value>
539 <stringvalue/>
540 </bsbDropdownItem>
541 <bsbDropdownItem>
542 <name> RMS Response Factor = 1</name>
543 <value>2</value>
544 <stringvalue/>
545 </bsbDropdownItem>
546 </bsbDropdownItemList>
547 <selectedIndex>1</selectedIndex>
548 <randomizable group="0">false</randomizable>
549 </bsbObject>
550 <bsbObject version="2" type="BSBLabel">
551 <objectName/>
552 <x>44</x>
553 <y>146</y>
554 <width>120</width>
555 <height>30</height>
556 <uuid>{47e9a2f7-66fe-45f6-965c-a52c28b135dc}</uuid>
557 <visible>true</visible>
558 <midichan>0</midichan>
559 <midicc>0</midicc>
560 <label>Scaling Modes</label>
561 <alignment>left</alignment>
562 <font>Arial</font>
563 <fontsize>10</fontsize>
564 <precision>3</precision>
565 <color>
566 <r>0</r>
567 <g>0</g>
568 <b>0</b>
569 </color>
570 <bgcolor mode="nobackground">
571 <r>255</r>
572 <g>255</g>
573 <b>255</b>
574 </bgcolor>
575 <bordermode>noborder</bordermode>
576 <borderradius>1</borderradius>
577 <borderwidth>1</borderwidth>
578 </bsbObject>
579 <bsbObject version="2" type="BSBButton">
580 <objectName>Initialisation</objectName>
581 <x>297</x>
582 <y>166</y>
583 <width>130</width>
584 <height>29</height>
585 <uuid>{b6345774-7938-4e62-9d8b-0ada81f7bcc5}</uuid>
586 <visible>true</visible>
587 <midichan>0</midichan>
588 <midicc>0</midicc>
589 <type>value</type>
590 <pressedValue>1.00000000</pressedValue>
591 <stringvalue/>
592 <text> No Initialisation</text>
593 <image>/</image>
594 <eventLine/>
595 <latch>true</latch>
596 <latched>false</latched>
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="true" loopStart="0" loopEnd="0"> </EventPanel>