Debian Codegraph @

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

raw
1 ;Written by Iain McCurdy, 2010
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 = 100 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
19 nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
20
21
22 ;TABLES FOR EXP SLIDER
23 giExp8 ftgen 0, 0, 129, -25, 0, 0.001, 128, 8.0
24 giExp10000 ftgen 0, 0, 129, -25, 0, 1.0, 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 gkstor invalue "Store"
46 kcf invalue "Frequency"
47 gkcf tablei kcf, giExp20000, 1
48 outvalue "Frequency_Value", gkcf
49 kbw invalue "Bandwidth"
50 gkbw tablei kbw, giExp10000, 1
51 outvalue "Bandwidth_Value", gkbw
52 kgain invalue "Gain"
53 gkgain tablei kgain, giExp8, 1
54 outvalue "Gain_Value", gkgain
55 gkamp invalue "Amplitude"
56
57 Sfile_new strcpy "" ;INIT TO EMPTY STRING
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 ;CREATE A VARIABLE FUNCTION THAT RAPIDLY RAMPS UP TO A SET VALUE
67 kcf portk gkcf, kporttime ;SMOOTH MOVEMENT OF SLIDER VARIABLE
68
69 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)
70 if kNew_file=1 then ;IF I-RATE VARIABLE CHANGE TRIGGER IS '1'...
71 reinit NEW_FILE ;BEGIN A REINITIALISATION PASS FROM LABEL 'NEW_FILE'
72 endif
73
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 ktrig changed gkstor
80 if ktrig=1 then
81 reinit UPDATE
82 endif
83
84 UPDATE:
85 aresL eqfil asigL, kcf, gkbw, gkgain, i(gkstor)
86 aresR eqfil asigR, kcf, gkbw, gkgain, i(gkstor)
87 rireturn
88 outs aresL * gkamp , aresR * gkamp ;SEND FILTER OUTPUT TO THE AUDIO OUTPUTS
89 endin
90 </CsInstruments>
91 <CsScore>
92 ;INSTR | START | DURATION
93 i 1 0 3600 ;GUI PLAYS FOR 1 HOUR
94 </CsScore>
95 </CsoundSynthesizer>
96
97
98 <bsbPanel>
99 <label>Widgets</label>
100 <objectName/>
101 <x>73</x>
102 <y>206</y>
103 <width>850</width>
104 <height>278</height>
105 <visible>true</visible>
106 <uuid/>
107 <bgcolor mode="background">
108 <r>241</r>
109 <g>226</g>
110 <b>185</b>
111 </bgcolor>
112 <bsbObject version="2" type="BSBLabel">
113 <objectName/>
114 <x>2</x>
115 <y>2</y>
116 <width>513</width>
117 <height>276</height>
118 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
119 <visible>true</visible>
120 <midichan>0</midichan>
121 <midicc>0</midicc>
122 <label>eqfil</label>
123 <alignment>center</alignment>
124 <font>Liberation Sans</font>
125 <fontsize>18</fontsize>
126 <precision>3</precision>
127 <color>
128 <r>0</r>
129 <g>0</g>
130 <b>0</b>
131 </color>
132 <bgcolor mode="background">
133 <r>106</r>
134 <g>117</g>
135 <b>150</b>
136 </bgcolor>
137 <bordermode>border</bordermode>
138 <borderradius>5</borderradius>
139 <borderwidth>2</borderwidth>
140 </bsbObject>
141 <bsbObject version="2" type="BSBLabel">
142 <objectName/>
143 <x>516</x>
144 <y>2</y>
145 <width>334</width>
146 <height>276</height>
147 <uuid>{74928ed2-b701-4668-9a11-74763d317e9b}</uuid>
148 <visible>true</visible>
149 <midichan>0</midichan>
150 <midicc>0</midicc>
151 <label>eqfil</label>
152 <alignment>center</alignment>
153 <font>Liberation Sans</font>
154 <fontsize>18</fontsize>
155 <precision>3</precision>
156 <color>
157 <r>0</r>
158 <g>0</g>
159 <b>0</b>
160 </color>
161 <bgcolor mode="background">
162 <r>106</r>
163 <g>117</g>
164 <b>150</b>
165 </bgcolor>
166 <bordermode>border</bordermode>
167 <borderradius>5</borderradius>
168 <borderwidth>2</borderwidth>
169 </bsbObject>
170 <bsbObject version="2" type="BSBLabel">
171 <objectName/>
172 <x>520</x>
173 <y>31</y>
174 <width>328</width>
175 <height>118</height>
176 <uuid>{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}</uuid>
177 <visible>true</visible>
178 <midichan>0</midichan>
179 <midicc>0</midicc>
180 <label>-------------------------------------------------------------------------------
181 eqfil is an implementation of a 2nd order tunable equalization filter with controls for centre frequency, bandwidth, and gain.</label>
182 <alignment>left</alignment>
183 <font>Liberation Sans</font>
184 <fontsize>14</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="BSBButton">
201 <objectName/>
202 <x>8</x>
203 <y>8</y>
204 <width>100</width>
205 <height>30</height>
206 <uuid>{24979132-c53f-4414-ac6b-6b4f503ecfe8}</uuid>
207 <visible>true</visible>
208 <midichan>0</midichan>
209 <midicc>0</midicc>
210 <type>event</type>
211 <pressedValue>1.00000000</pressedValue>
212 <stringvalue/>
213 <text> ON / OFF</text>
214 <image>/</image>
215 <eventLine>i 2 0 -1</eventLine>
216 <latch>true</latch>
217 <latched>false</latched>
218 </bsbObject>
219 <bsbObject version="2" type="BSBDisplay">
220 <objectName>Frequency_Value</objectName>
221 <x>448</x>
222 <y>77</y>
223 <width>60</width>
224 <height>30</height>
225 <uuid>{745d6bee-b951-4a03-9fe8-9e10d5ae4556}</uuid>
226 <visible>true</visible>
227 <midichan>0</midichan>
228 <midicc>0</midicc>
229 <label>800.157</label>
230 <alignment>right</alignment>
231 <font>Liberation Sans</font>
232 <fontsize>9</fontsize>
233 <precision>3</precision>
234 <color>
235 <r>0</r>
236 <g>0</g>
237 <b>0</b>
238 </color>
239 <bgcolor mode="nobackground">
240 <r>255</r>
241 <g>255</g>
242 <b>255</b>
243 </bgcolor>
244 <bordermode>noborder</bordermode>
245 <borderradius>1</borderradius>
246 <borderwidth>1</borderwidth>
247 </bsbObject>
248 <bsbObject version="2" type="BSBHSlider">
249 <objectName>Frequency</objectName>
250 <x>8</x>
251 <y>60</y>
252 <width>500</width>
253 <height>27</height>
254 <uuid>{06814721-6151-4baa-84e2-8f39843b07a4}</uuid>
255 <visible>true</visible>
256 <midichan>0</midichan>
257 <midicc>0</midicc>
258 <minimum>0.00000000</minimum>
259 <maximum>1.00000000</maximum>
260 <value>0.53400000</value>
261 <mode>lin</mode>
262 <mouseControl act="jump">continuous</mouseControl>
263 <resolution>-1.00000000</resolution>
264 <randomizable group="0">false</randomizable>
265 </bsbObject>
266 <bsbObject version="2" type="BSBLabel">
267 <objectName/>
268 <x>8</x>
269 <y>77</y>
270 <width>180</width>
271 <height>30</height>
272 <uuid>{c6d7165c-6730-426f-b293-52b411bc73cf}</uuid>
273 <visible>true</visible>
274 <midichan>0</midichan>
275 <midicc>0</midicc>
276 <label>Cutoff Frequency</label>
277 <alignment>left</alignment>
278 <font>Liberation Sans</font>
279 <fontsize>10</fontsize>
280 <precision>3</precision>
281 <color>
282 <r>0</r>
283 <g>0</g>
284 <b>0</b>
285 </color>
286 <bgcolor mode="nobackground">
287 <r>255</r>
288 <g>255</g>
289 <b>255</b>
290 </bgcolor>
291 <bordermode>noborder</bordermode>
292 <borderradius>1</borderradius>
293 <borderwidth>1</borderwidth>
294 </bsbObject>
295 <bsbObject version="2" type="BSBButton">
296 <objectName>_Browse</objectName>
297 <x>8</x>
298 <y>240</y>
299 <width>170</width>
300 <height>30</height>
301 <uuid>{b9431a61-61f7-432b-bf6f-c47ddc7f9050}</uuid>
302 <visible>true</visible>
303 <midichan>0</midichan>
304 <midicc>0</midicc>
305 <type>value</type>
306 <pressedValue>1.00000000</pressedValue>
307 <stringvalue>Seashore.wav</stringvalue>
308 <text>Browse Audio File</text>
309 <image>/</image>
310 <eventLine/>
311 <latch>false</latch>
312 <latched>false</latched>
313 </bsbObject>
314 <bsbObject version="2" type="BSBLineEdit">
315 <objectName>_Browse</objectName>
316 <x>179</x>
317 <y>241</y>
318 <width>330</width>
319 <height>28</height>
320 <uuid>{68b5f90b-b78e-4581-b434-232db5f4c40f}</uuid>
321 <visible>true</visible>
322 <midichan>0</midichan>
323 <midicc>0</midicc>
324 <label>Seashore.wav</label>
325 <alignment>left</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>229</r>
336 <g>229</g>
337 <b>229</b>
338 </bgcolor>
339 <background>nobackground</background>
340 </bsbObject>
341 <bsbObject version="2" type="BSBLabel">
342 <objectName/>
343 <x>8</x>
344 <y>219</y>
345 <width>150</width>
346 <height>30</height>
347 <uuid>{936f6eb0-5225-4bd7-a5fe-a49df1c9c5ac}</uuid>
348 <visible>true</visible>
349 <midichan>0</midichan>
350 <midicc>0</midicc>
351 <label>Audio File</label>
352 <alignment>left</alignment>
353 <font>Arial</font>
354 <fontsize>10</fontsize>
355 <precision>3</precision>
356 <color>
357 <r>0</r>
358 <g>0</g>
359 <b>0</b>
360 </color>
361 <bgcolor mode="nobackground">
362 <r>255</r>
363 <g>255</g>
364 <b>255</b>
365 </bgcolor>
366 <bordermode>noborder</bordermode>
367 <borderradius>1</borderradius>
368 <borderwidth>1</borderwidth>
369 </bsbObject>
370 <bsbObject version="2" type="BSBLabel">
371 <objectName/>
372 <x>8</x>
373 <y>115</y>
374 <width>180</width>
375 <height>30</height>
376 <uuid>{f4029fbc-c802-493b-aacb-44a251dfd70c}</uuid>
377 <visible>true</visible>
378 <midichan>0</midichan>
379 <midicc>0</midicc>
380 <label>Bandwidth</label>
381 <alignment>left</alignment>
382 <font>Arial</font>
383 <fontsize>10</fontsize>
384 <precision>3</precision>
385 <color>
386 <r>0</r>
387 <g>0</g>
388 <b>0</b>
389 </color>
390 <bgcolor mode="nobackground">
391 <r>255</r>
392 <g>255</g>
393 <b>255</b>
394 </bgcolor>
395 <bordermode>noborder</bordermode>
396 <borderradius>1</borderradius>
397 <borderwidth>1</borderwidth>
398 </bsbObject>
399 <bsbObject version="2" type="BSBHSlider">
400 <objectName>Bandwidth</objectName>
401 <x>8</x>
402 <y>98</y>
403 <width>500</width>
404 <height>27</height>
405 <uuid>{b5b98b11-0602-412e-9830-0bbe82f5476b}</uuid>
406 <visible>true</visible>
407 <midichan>0</midichan>
408 <midicc>0</midicc>
409 <minimum>0.00000000</minimum>
410 <maximum>1.00000000</maximum>
411 <value>0.57600000</value>
412 <mode>lin</mode>
413 <mouseControl act="jump">continuous</mouseControl>
414 <resolution>-1.00000000</resolution>
415 <randomizable group="0">false</randomizable>
416 </bsbObject>
417 <bsbObject version="2" type="BSBDisplay">
418 <objectName>Bandwidth_Value</objectName>
419 <x>448</x>
420 <y>115</y>
421 <width>60</width>
422 <height>30</height>
423 <uuid>{aa9d2e59-a8e3-4b3d-a00a-04fcecc3d502}</uuid>
424 <visible>true</visible>
425 <midichan>0</midichan>
426 <midicc>0</midicc>
427 <label>201.475</label>
428 <alignment>right</alignment>
429 <font>Liberation Sans</font>
430 <fontsize>9</fontsize>
431 <precision>3</precision>
432 <color>
433 <r>0</r>
434 <g>0</g>
435 <b>0</b>
436 </color>
437 <bgcolor mode="nobackground">
438 <r>255</r>
439 <g>255</g>
440 <b>255</b>
441 </bgcolor>
442 <bordermode>noborder</bordermode>
443 <borderradius>1</borderradius>
444 <borderwidth>1</borderwidth>
445 </bsbObject>
446 <bsbObject version="2" type="BSBLabel">
447 <objectName/>
448 <x>8</x>
449 <y>191</y>
450 <width>180</width>
451 <height>30</height>
452 <uuid>{2e52a7a7-dc13-405e-896d-db2a7431d8dd}</uuid>
453 <visible>true</visible>
454 <midichan>0</midichan>
455 <midicc>0</midicc>
456 <label>Output Amplitude</label>
457 <alignment>left</alignment>
458 <font>Liberation Sans</font>
459 <fontsize>10</fontsize>
460 <precision>3</precision>
461 <color>
462 <r>0</r>
463 <g>0</g>
464 <b>0</b>
465 </color>
466 <bgcolor mode="nobackground">
467 <r>255</r>
468 <g>255</g>
469 <b>255</b>
470 </bgcolor>
471 <bordermode>noborder</bordermode>
472 <borderradius>1</borderradius>
473 <borderwidth>1</borderwidth>
474 </bsbObject>
475 <bsbObject version="2" type="BSBHSlider">
476 <objectName>Amplitude</objectName>
477 <x>8</x>
478 <y>174</y>
479 <width>500</width>
480 <height>27</height>
481 <uuid>{6ab84e0f-82a7-4b9c-af23-35bd7d9b7fa2}</uuid>
482 <visible>true</visible>
483 <midichan>0</midichan>
484 <midicc>0</midicc>
485 <minimum>0.00000000</minimum>
486 <maximum>1.00000000</maximum>
487 <value>0.50000000</value>
488 <mode>lin</mode>
489 <mouseControl act="jump">continuous</mouseControl>
490 <resolution>-1.00000000</resolution>
491 <randomizable group="0">false</randomizable>
492 </bsbObject>
493 <bsbObject version="2" type="BSBDisplay">
494 <objectName>Amplitude</objectName>
495 <x>448</x>
496 <y>191</y>
497 <width>60</width>
498 <height>30</height>
499 <uuid>{99d6bf8b-3c85-4911-a29a-7dd678a940ed}</uuid>
500 <visible>true</visible>
501 <midichan>0</midichan>
502 <midicc>0</midicc>
503 <label>0.500</label>
504 <alignment>right</alignment>
505 <font>Arial</font>
506 <fontsize>9</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="BSBButton">
523 <objectName>Store</objectName>
524 <x>348</x>
525 <y>8</y>
526 <width>160</width>
527 <height>29</height>
528 <uuid>{b6345774-7938-4e62-9d8b-0ada81f7bcc5}</uuid>
529 <visible>true</visible>
530 <midichan>0</midichan>
531 <midicc>0</midicc>
532 <type>value</type>
533 <pressedValue>1.00000000</pressedValue>
534 <stringvalue/>
535 <text> Store Internal Space</text>
536 <image>/</image>
537 <eventLine/>
538 <latch>true</latch>
539 <latched>false</latched>
540 </bsbObject>
541 <bsbObject version="2" type="BSBLabel">
542 <objectName/>
543 <x>8</x>
544 <y>153</y>
545 <width>180</width>
546 <height>30</height>
547 <uuid>{329afaff-e80b-455c-b4b6-5a4027d9fefb}</uuid>
548 <visible>true</visible>
549 <midichan>0</midichan>
550 <midicc>0</midicc>
551 <label>Gain</label>
552 <alignment>left</alignment>
553 <font>Liberation Sans</font>
554 <fontsize>10</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>Gain</objectName>
572 <x>8</x>
573 <y>136</y>
574 <width>500</width>
575 <height>27</height>
576 <uuid>{0b5cf847-0da8-4dba-87ab-5232a6c3961b}</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.77000000</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="BSBDisplay">
589 <objectName>Gain_Value</objectName>
590 <x>448</x>
591 <y>153</y>
592 <width>60</width>
593 <height>30</height>
594 <uuid>{e6ecaf5a-27bf-4176-96d8-d0198ffe18a6}</uuid>
595 <visible>true</visible>
596 <midichan>0</midichan>
597 <midicc>0</midicc>
598 <label>1.013</label>
599 <alignment>right</alignment>
600 <font>Liberation Sans</font>
601 <fontsize>9</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 </bsbPanel>
618 <bsbPresets>
619 </bsbPresets>
620 <EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="true" loopStart="0" loopEnd="0"> </EventPanel>