Debian Codegraph @

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

raw
1 ;Written by Iain McCurdy, 2006
2
3 ;CAREFUL MONITORING OF THE OUTPUT AMPLITUDE IS NEEDED TO PREVENT DISTORTION
4
5 ;Modified for QuteCsound by René, November 2010, updated Feb 2011
6 ;Tested on Ubuntu 10.04 with csound-float 5.13.0 and QuteCsound svn rev 817
7
8 ;Notes on modifications from original csd:
9 ; Add table(s) for exp slider
10 ; Add Browser for audio file and use of FilePlay2 udo, now accept mono or stereo wav files
11
12
13 ;my flags on Ubuntu: -iadc -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=null -m0
14 <CsoundSynthesizer>
15 <CsOptions>
16 --env:SSDIR+=../../SourceMaterials
17 </CsOptions>
18 <CsInstruments>
19 sr = 44100 ;SAMPLE RATE
20 ksmps = 100 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
21 nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
22
23
24 ;TABLES FOR EXP SLIDER
25 giExp500 ftgen 0, 0, 129, -25, 0, 0.01, 128, 500.0
26 giExp5000 ftgen 0, 0, 129, -25, 0, 0.01, 128, 5000.0
27
28
29 opcode FilePlay2, aa, Skoo ; Credit to Joachim Heintz
30 ;gives stereo output regardless your soundfile is mono or stereo
31 Sfil, kspeed, iskip, iloop xin
32 ichn filenchnls Sfil
33 if ichn == 1 then
34 aL diskin2 Sfil, kspeed, iskip, iloop
35 aR = aL
36 else
37 aL, aR diskin2 Sfil, kspeed, iskip, iloop
38 endif
39 xout aL, aR
40 endop
41
42
43 instr 1 ;GUI
44 ktrig metro 10
45 if (ktrig == 1) then
46
47 Sfile_new strcpy "" ;INIT TO EMPTY STRING
48
49 kfco invalue "Filter_Cutoff"
50 gkfco tablei kfco, giExp5000, 1
51 outvalue "Filter_Cutoff_Value", gkfco
52 kres invalue "Resonance"
53 gkres tablei kres, giExp500, 1
54 outvalue "Resonance_Value", gkres
55 gksep invalue "Separation"
56 gkamp invalue "Amplitude"
57
58 gkord invalue "Ordinates"
59
60 gSfile invalue "_Browse"
61 Sfile_old strcpyk Sfile_new
62 Sfile_new strcpyk gSfile
63 gkfile strcmpk Sfile_new, Sfile_old
64 endif
65 endin
66
67 instr 2
68 kporttime linseg 0,0.001,0.005,1,0.005 ;CREATE A VARIABLE FUNCTION THAT RAPIDLY RAMPS UP TO A SET VALUE
69 kfco portk gkfco, kporttime ;SMOOTH MOVEMENT OF SLIDER VARIABLE
70 ksep portk gksep, kporttime ;SMOOTH MOVEMENT OF SLIDER VARIABLE
71
72 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)
73 if kNew_file=1 then ;IF I-RATE VARIABLE CHANGE TRIGGER IS '1'...
74 reinit NEW_FILE ;BEGIN A REINITIALISATION PASS FROM LABEL 'START'
75 endif
76 NEW_FILE:
77 ;OUTPUTS OPCODE FILE | SPEED | INSKIP | LOOPING (0=OFF 1=ON)
78 asigL, asigR FilePlay2 gSfile, 1, 0, 1 ;GENERATE 2 AUDIO SIGNALS FROM A STEREO SOUND FILE
79 rireturn ;RETURN FROM REINITIALISATION PASS TO PERFORMANCE TIME PASSES
80
81 kSwitch changed gkord ;GENERATE A MOMENTARY '1' PULSE IN OUTPUT 'kSwitch' IF ANY OF THE SCANNED INPUT VARIABLES CHANGE. (OUTPUT 'kSwitch' IS NORMALLY ZERO)
82 if kSwitch=1 then ;IF I-RATE VARIABLE CHANGE TRIGGER IS '1'...
83 reinit START ;BEGIN A REINITIALISATION PASS FROM LABEL 'START'
84 endif
85 START:
86 aresL vlowres asigL, kfco, gkres, i(gkord), ksep ;FILTER BOTH CHANNELS SEPARATELY
87 aresR vlowres asigR, kfco, gkres, i(gkord), ksep ;FILTER BOTH CHANNELS SEPARATELY
88 outs aresL * gkamp, aresR * gkamp ;SEND FILTER OUTPUT TO THE AUDIO OUTPUTS AND SCALE USING THE FLTK SLIDER VARIABLE gkamp
89 endin
90 </CsInstruments>
91 <CsScore>
92 ;INSTR | START | DURATION
93 i 1 0 3600 ;GUI
94 </CsScore>
95 </CsoundSynthesizer>
96
97 <bsbPanel>
98 <label>Widgets</label>
99 <objectName/>
100 <x>401</x>
101 <y>409</y>
102 <width>940</width>
103 <height>302</height>
104 <visible>true</visible>
105 <uuid/>
106 <bgcolor mode="background">
107 <r>241</r>
108 <g>226</g>
109 <b>185</b>
110 </bgcolor>
111 <bsbObject version="2" type="BSBLabel">
112 <objectName/>
113 <x>2</x>
114 <y>2</y>
115 <width>512</width>
116 <height>300</height>
117 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
118 <visible>true</visible>
119 <midichan>0</midichan>
120 <midicc>0</midicc>
121 <label>vlowres</label>
122 <alignment>center</alignment>
123 <font>Liberation Sans</font>
124 <fontsize>18</fontsize>
125 <precision>3</precision>
126 <color>
127 <r>0</r>
128 <g>0</g>
129 <b>0</b>
130 </color>
131 <bgcolor mode="background">
132 <r>106</r>
133 <g>117</g>
134 <b>150</b>
135 </bgcolor>
136 <bordermode>border</bordermode>
137 <borderradius>5</borderradius>
138 <borderwidth>2</borderwidth>
139 </bsbObject>
140 <bsbObject version="2" type="BSBLabel">
141 <objectName/>
142 <x>515</x>
143 <y>2</y>
144 <width>425</width>
145 <height>300</height>
146 <uuid>{74928ed2-b701-4668-9a11-74763d317e9b}</uuid>
147 <visible>true</visible>
148 <midichan>0</midichan>
149 <midicc>0</midicc>
150 <label>vlowres</label>
151 <alignment>center</alignment>
152 <font>Liberation Sans</font>
153 <fontsize>18</fontsize>
154 <precision>3</precision>
155 <color>
156 <r>0</r>
157 <g>0</g>
158 <b>0</b>
159 </color>
160 <bgcolor mode="background">
161 <r>106</r>
162 <g>117</g>
163 <b>150</b>
164 </bgcolor>
165 <bordermode>border</bordermode>
166 <borderradius>5</borderradius>
167 <borderwidth>2</borderwidth>
168 </bsbObject>
169 <bsbObject version="2" type="BSBLabel">
170 <objectName/>
171 <x>516</x>
172 <y>16</y>
173 <width>422</width>
174 <height>284</height>
175 <uuid>{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}</uuid>
176 <visible>true</visible>
177 <midichan>0</midichan>
178 <midicc>0</midicc>
179 <label>------------------------------------------------------------------------------------------------------
180 vlowres is an implementation of a resonant low-pass filter. Its input arguments are for filter cutoff frequency, resonance, number of parallel iterations of the filter (1 to 10) and cutoff frequency separation between the first and last filters. Cutoff frequency is not in hertz and resonance is not in decibels so experimentation is needed. Use of high levels of resonance can cause significant increases in the overall output amplitude. It may be desired to make use of the balance opcode to control these fluctuations in amplitude. Alternatively a control to scale the output amplitude can be implemented (as has been done in this example). vlowres is equivalent to multiple iterations of the lowres opcode connected in parallel with cutoff frequencies spaced according to a combination of the Separation and the Number of Ordinates arguments. Separation defines the interval in hertz between the first and last filters, intervening filter cutoff frequencies are spaced evenly.</label>
181 <alignment>left</alignment>
182 <font>Arial</font>
183 <fontsize>14</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="BSBButton">
200 <objectName/>
201 <x>8</x>
202 <y>6</y>
203 <width>100</width>
204 <height>30</height>
205 <uuid>{24979132-c53f-4414-ac6b-6b4f503ecfe8}</uuid>
206 <visible>true</visible>
207 <midichan>0</midichan>
208 <midicc>0</midicc>
209 <type>event</type>
210 <pressedValue>1.00000000</pressedValue>
211 <stringvalue/>
212 <text> ON / OFF</text>
213 <image>/</image>
214 <eventLine>i 2 0 -1</eventLine>
215 <latch>true</latch>
216 <latched>false</latched>
217 </bsbObject>
218 <bsbObject version="2" type="BSBDisplay">
219 <objectName>Filter_Cutoff_Value</objectName>
220 <x>448</x>
221 <y>63</y>
222 <width>60</width>
223 <height>30</height>
224 <uuid>{745d6bee-b951-4a03-9fe8-9e10d5ae4556}</uuid>
225 <visible>true</visible>
226 <midichan>0</midichan>
227 <midicc>0</midicc>
228 <label>29.194</label>
229 <alignment>right</alignment>
230 <font>Arial</font>
231 <fontsize>9</fontsize>
232 <precision>3</precision>
233 <color>
234 <r>0</r>
235 <g>0</g>
236 <b>0</b>
237 </color>
238 <bgcolor mode="nobackground">
239 <r>255</r>
240 <g>255</g>
241 <b>255</b>
242 </bgcolor>
243 <bordermode>noborder</bordermode>
244 <borderradius>1</borderradius>
245 <borderwidth>1</borderwidth>
246 </bsbObject>
247 <bsbObject version="2" type="BSBHSlider">
248 <objectName>Filter_Cutoff</objectName>
249 <x>8</x>
250 <y>46</y>
251 <width>500</width>
252 <height>27</height>
253 <uuid>{06814721-6151-4baa-84e2-8f39843b07a4}</uuid>
254 <visible>true</visible>
255 <midichan>0</midichan>
256 <midicc>0</midicc>
257 <minimum>0.00000000</minimum>
258 <maximum>1.00000000</maximum>
259 <value>0.60800000</value>
260 <mode>lin</mode>
261 <mouseControl act="jump">continuous</mouseControl>
262 <resolution>-1.00000000</resolution>
263 <randomizable group="0">false</randomizable>
264 </bsbObject>
265 <bsbObject version="2" type="BSBLabel">
266 <objectName/>
267 <x>8</x>
268 <y>63</y>
269 <width>180</width>
270 <height>30</height>
271 <uuid>{c6d7165c-6730-426f-b293-52b411bc73cf}</uuid>
272 <visible>true</visible>
273 <midichan>0</midichan>
274 <midicc>0</midicc>
275 <label>Filter Cutoff (Not in Hertz!)</label>
276 <alignment>left</alignment>
277 <font>Arial</font>
278 <fontsize>10</fontsize>
279 <precision>3</precision>
280 <color>
281 <r>0</r>
282 <g>0</g>
283 <b>0</b>
284 </color>
285 <bgcolor mode="nobackground">
286 <r>255</r>
287 <g>255</g>
288 <b>255</b>
289 </bgcolor>
290 <bordermode>noborder</bordermode>
291 <borderradius>1</borderradius>
292 <borderwidth>1</borderwidth>
293 </bsbObject>
294 <bsbObject version="2" type="BSBHSlider">
295 <objectName>Resonance</objectName>
296 <x>8</x>
297 <y>84</y>
298 <width>500</width>
299 <height>27</height>
300 <uuid>{42fe25e5-e98f-4f00-872c-f791822a1b3e}</uuid>
301 <visible>true</visible>
302 <midichan>0</midichan>
303 <midicc>0</midicc>
304 <minimum>0.00000000</minimum>
305 <maximum>1.00000000</maximum>
306 <value>0.22200000</value>
307 <mode>lin</mode>
308 <mouseControl act="jump">continuous</mouseControl>
309 <resolution>-1.00000000</resolution>
310 <randomizable group="0">false</randomizable>
311 </bsbObject>
312 <bsbObject version="2" type="BSBDisplay">
313 <objectName>Resonance_Value</objectName>
314 <x>448</x>
315 <y>101</y>
316 <width>60</width>
317 <height>30</height>
318 <uuid>{a8f35453-f236-447d-88d9-1a0b135383b6}</uuid>
319 <visible>true</visible>
320 <midichan>0</midichan>
321 <midicc>0</midicc>
322 <label>0.111</label>
323 <alignment>right</alignment>
324 <font>Arial</font>
325 <fontsize>9</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>255</r>
334 <g>255</g>
335 <b>255</b>
336 </bgcolor>
337 <bordermode>noborder</bordermode>
338 <borderradius>1</borderradius>
339 <borderwidth>1</borderwidth>
340 </bsbObject>
341 <bsbObject version="2" type="BSBButton">
342 <objectName>_Browse</objectName>
343 <x>8</x>
344 <y>228</y>
345 <width>170</width>
346 <height>30</height>
347 <uuid>{43341095-bc3a-4607-bd0e-01254da7bc67}</uuid>
348 <visible>true</visible>
349 <midichan>0</midichan>
350 <midicc>0</midicc>
351 <type>value</type>
352 <pressedValue>1.00000000</pressedValue>
353 <stringvalue>Seashore.wav</stringvalue>
354 <text>Browse Audio File</text>
355 <image>/</image>
356 <eventLine/>
357 <latch>false</latch>
358 <latched>false</latched>
359 </bsbObject>
360 <bsbObject version="2" type="BSBLineEdit">
361 <objectName>_Browse</objectName>
362 <x>177</x>
363 <y>229</y>
364 <width>330</width>
365 <height>28</height>
366 <uuid>{b66f3878-dfd0-4290-9b9d-73be88197222}</uuid>
367 <visible>true</visible>
368 <midichan>0</midichan>
369 <midicc>0</midicc>
370 <label>Seashore.wav</label>
371 <alignment>left</alignment>
372 <font>Arial</font>
373 <fontsize>10</fontsize>
374 <precision>3</precision>
375 <color>
376 <r>0</r>
377 <g>0</g>
378 <b>0</b>
379 </color>
380 <bgcolor mode="nobackground">
381 <r>229</r>
382 <g>229</g>
383 <b>229</b>
384 </bgcolor>
385 <background>nobackground</background>
386 </bsbObject>
387 <bsbObject version="2" type="BSBLabel">
388 <objectName/>
389 <x>8</x>
390 <y>206</y>
391 <width>160</width>
392 <height>30</height>
393 <uuid>{7e1e7af4-88dd-4046-a781-fa2dc828b980}</uuid>
394 <visible>true</visible>
395 <midichan>0</midichan>
396 <midicc>0</midicc>
397 <label>File Input</label>
398 <alignment>left</alignment>
399 <font>Arial</font>
400 <fontsize>10</fontsize>
401 <precision>3</precision>
402 <color>
403 <r>0</r>
404 <g>0</g>
405 <b>0</b>
406 </color>
407 <bgcolor mode="nobackground">
408 <r>255</r>
409 <g>255</g>
410 <b>255</b>
411 </bgcolor>
412 <bordermode>noborder</bordermode>
413 <borderradius>1</borderradius>
414 <borderwidth>1</borderwidth>
415 </bsbObject>
416 <bsbObject version="2" type="BSBLabel">
417 <objectName/>
418 <x>8</x>
419 <y>101</y>
420 <width>180</width>
421 <height>30</height>
422 <uuid>{027163fb-bbfe-488e-9351-1c1cd9a9d626}</uuid>
423 <visible>true</visible>
424 <midichan>0</midichan>
425 <midicc>0</midicc>
426 <label>Resonance</label>
427 <alignment>left</alignment>
428 <font>Arial</font>
429 <fontsize>10</fontsize>
430 <precision>3</precision>
431 <color>
432 <r>0</r>
433 <g>0</g>
434 <b>0</b>
435 </color>
436 <bgcolor mode="nobackground">
437 <r>255</r>
438 <g>255</g>
439 <b>255</b>
440 </bgcolor>
441 <bordermode>noborder</bordermode>
442 <borderradius>1</borderradius>
443 <borderwidth>1</borderwidth>
444 </bsbObject>
445 <bsbObject version="2" type="BSBSpinBox">
446 <objectName>Ordinates</objectName>
447 <x>453</x>
448 <y>9</y>
449 <width>55</width>
450 <height>28</height>
451 <uuid>{67d31697-f639-4f22-8bb2-0c487a2d6bc9}</uuid>
452 <visible>true</visible>
453 <midichan>0</midichan>
454 <midicc>0</midicc>
455 <alignment>left</alignment>
456 <font>Arial</font>
457 <fontsize>14</fontsize>
458 <color>
459 <r>0</r>
460 <g>0</g>
461 <b>0</b>
462 </color>
463 <bgcolor mode="nobackground">
464 <r>255</r>
465 <g>255</g>
466 <b>255</b>
467 </bgcolor>
468 <resolution>1.00000000</resolution>
469 <minimum>1</minimum>
470 <maximum>10</maximum>
471 <randomizable group="0">false</randomizable>
472 <value>10</value>
473 </bsbObject>
474 <bsbObject version="2" type="BSBLabel">
475 <objectName/>
476 <x>322</x>
477 <y>8</y>
478 <width>130</width>
479 <height>30</height>
480 <uuid>{96faebf3-f79f-45ef-b54d-a1fc14b35497}</uuid>
481 <visible>true</visible>
482 <midichan>0</midichan>
483 <midicc>0</midicc>
484 <label>Number of Ordinates</label>
485 <alignment>right</alignment>
486 <font>Arial</font>
487 <fontsize>10</fontsize>
488 <precision>3</precision>
489 <color>
490 <r>0</r>
491 <g>0</g>
492 <b>0</b>
493 </color>
494 <bgcolor mode="nobackground">
495 <r>255</r>
496 <g>255</g>
497 <b>255</b>
498 </bgcolor>
499 <bordermode>noborder</bordermode>
500 <borderradius>1</borderradius>
501 <borderwidth>1</borderwidth>
502 </bsbObject>
503 <bsbObject version="2" type="BSBLabel">
504 <objectName/>
505 <x>8</x>
506 <y>176</y>
507 <width>180</width>
508 <height>30</height>
509 <uuid>{55b6e232-c48e-4f7d-a9c2-bb5845a86be6}</uuid>
510 <visible>true</visible>
511 <midichan>0</midichan>
512 <midicc>0</midicc>
513 <label>Output Amplitude Scaling</label>
514 <alignment>left</alignment>
515 <font>Arial</font>
516 <fontsize>10</fontsize>
517 <precision>3</precision>
518 <color>
519 <r>0</r>
520 <g>0</g>
521 <b>0</b>
522 </color>
523 <bgcolor mode="nobackground">
524 <r>255</r>
525 <g>255</g>
526 <b>255</b>
527 </bgcolor>
528 <bordermode>noborder</bordermode>
529 <borderradius>1</borderradius>
530 <borderwidth>1</borderwidth>
531 </bsbObject>
532 <bsbObject version="2" type="BSBDisplay">
533 <objectName>Amplitude</objectName>
534 <x>448</x>
535 <y>176</y>
536 <width>60</width>
537 <height>30</height>
538 <uuid>{8af638cf-01fd-481b-a760-f46fa98f7a33}</uuid>
539 <visible>true</visible>
540 <midichan>0</midichan>
541 <midicc>0</midicc>
542 <label>0.432</label>
543 <alignment>right</alignment>
544 <font>Arial</font>
545 <fontsize>9</fontsize>
546 <precision>3</precision>
547 <color>
548 <r>0</r>
549 <g>0</g>
550 <b>0</b>
551 </color>
552 <bgcolor mode="nobackground">
553 <r>255</r>
554 <g>255</g>
555 <b>255</b>
556 </bgcolor>
557 <bordermode>noborder</bordermode>
558 <borderradius>1</borderradius>
559 <borderwidth>1</borderwidth>
560 </bsbObject>
561 <bsbObject version="2" type="BSBHSlider">
562 <objectName>Amplitude</objectName>
563 <x>8</x>
564 <y>159</y>
565 <width>500</width>
566 <height>27</height>
567 <uuid>{cd0d0266-1e5e-4e06-a2fa-65c41c86ba54}</uuid>
568 <visible>true</visible>
569 <midichan>0</midichan>
570 <midicc>0</midicc>
571 <minimum>0.00000000</minimum>
572 <maximum>1.00000000</maximum>
573 <value>0.43200000</value>
574 <mode>lin</mode>
575 <mouseControl act="jump">continuous</mouseControl>
576 <resolution>-1.00000000</resolution>
577 <randomizable group="0">false</randomizable>
578 </bsbObject>
579 <bsbObject version="2" type="BSBLabel">
580 <objectName/>
581 <x>8</x>
582 <y>138</y>
583 <width>180</width>
584 <height>30</height>
585 <uuid>{57b12579-1ba1-4f85-afa6-ffaa19d65419}</uuid>
586 <visible>true</visible>
587 <midichan>0</midichan>
588 <midicc>0</midicc>
589 <label>Separation (in oct)</label>
590 <alignment>left</alignment>
591 <font>Arial</font>
592 <fontsize>10</fontsize>
593 <precision>3</precision>
594 <color>
595 <r>0</r>
596 <g>0</g>
597 <b>0</b>
598 </color>
599 <bgcolor mode="nobackground">
600 <r>255</r>
601 <g>255</g>
602 <b>255</b>
603 </bgcolor>
604 <bordermode>noborder</bordermode>
605 <borderradius>1</borderradius>
606 <borderwidth>1</borderwidth>
607 </bsbObject>
608 <bsbObject version="2" type="BSBHSlider">
609 <objectName>Separation</objectName>
610 <x>8</x>
611 <y>121</y>
612 <width>500</width>
613 <height>27</height>
614 <uuid>{a2eb824f-fb70-4708-a48e-5374dfc5bdac}</uuid>
615 <visible>true</visible>
616 <midichan>0</midichan>
617 <midicc>0</midicc>
618 <minimum>0.00000000</minimum>
619 <maximum>100.00000000</maximum>
620 <value>59.20000000</value>
621 <mode>lin</mode>
622 <mouseControl act="jump">continuous</mouseControl>
623 <resolution>-1.00000000</resolution>
624 <randomizable group="0">false</randomizable>
625 </bsbObject>
626 <bsbObject version="2" type="BSBDisplay">
627 <objectName>Separation</objectName>
628 <x>448</x>
629 <y>138</y>
630 <width>60</width>
631 <height>30</height>
632 <uuid>{624802ed-c73a-4abd-94d4-66ed69931416}</uuid>
633 <visible>true</visible>
634 <midichan>0</midichan>
635 <midicc>0</midicc>
636 <label>59.200</label>
637 <alignment>right</alignment>
638 <font>Arial</font>
639 <fontsize>9</fontsize>
640 <precision>3</precision>
641 <color>
642 <r>0</r>
643 <g>0</g>
644 <b>0</b>
645 </color>
646 <bgcolor mode="nobackground">
647 <r>255</r>
648 <g>255</g>
649 <b>255</b>
650 </bgcolor>
651 <bordermode>noborder</bordermode>
652 <borderradius>1</borderradius>
653 <borderwidth>1</borderwidth>
654 </bsbObject>
655 </bsbPanel>
656 <bsbPresets>
657 </bsbPresets>
658 <EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="true" loopStart="0" loopEnd="0"> </EventPanel>