Debian Codegraph @

src/Examples/McCurdy Collection/Filters/lowres.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
21
22 ;TABLES FOR EXP SLIDER
23 giExp500 ftgen 0, 0, 129, -25, 0, 0.01, 128, 500.0
24 giExp5000 ftgen 0, 0, 129, -25, 0, 1.0, 128, 5000.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 kcutoff invalue "Filter_Cutoff"
48 gkcutoff tablei kcutoff, giExp5000, 1
49 outvalue "Filter_Cutoff_Value", gkcutoff
50 kresonance invalue "Resonance"
51 gkresonance tablei kresonance, giExp500, 1
52 outvalue "Resonance_Value", gkresonance
53 gkamp invalue "Output_Amplitude_Scaling"
54
55 gkskip invalue "Initialisation"
56
57 gSfile invalue "_Browse"
58 Sfile_old strcpyk Sfile_new
59 Sfile_new strcpyk gSfile
60 gkfile strcmpk Sfile_new, Sfile_old
61 endif
62 endin
63
64 instr 2
65 kporttime linseg 0,0.001,0.005,1,0.005 ;CREATE A VARIABLE FUNCTION THAT RAPIDLY RAMPS UP TO A SET VALUE
66 kcutoff portk gkcutoff, kporttime ;SMOOTH MOVEMENT OF SLIDER VARIABLE
67
68 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)
69 if kNew_file=1 then ;IF I-RATE VARIABLE CHANGE TRIGGER IS '1'...
70 reinit NEW_FILE ;BEGIN A REINITIALISATION PASS FROM LABEL 'START'
71 endif
72 NEW_FILE:
73 ;OUTPUTS OPCODE FILE | SPEED | INSKIP | LOOPING (0=OFF 1=ON)
74 asigL, asigR FilePlay2 gSfile, 1, 0, 1 ;GENERATE 2 AUDIO SIGNALS FROM A STEREO SOUND FILE
75 rireturn ;RETURN FROM REINITIALISATION PASS TO PERFORMANCE TIME PASSES
76
77 kSwitch changed gkskip ;GENERATE A MOMENTARY '1' PULSE IN OUTPUT 'kSwitch' IF ANY OF THE SCANNED INPUT VARIABLES CHANGE. (OUTPUT 'kSwitch' IS NORMALLY ZERO)
78 if kSwitch=1 then ;IF I-RATE VARIABLE CHANGE TRIGGER IS '1'...
79 reinit START ;BEGIN A REINITIALISATION PASS FROM LABEL 'START'
80 endif
81 START:
82 aresL lowres asigL, kcutoff, gkresonance, i(gkskip) ;FILTER EACH CHANNEL SEPARATELY
83 aresR lowres asigR, kcutoff, gkresonance, i(gkskip) ;FILTER EACH CHANNEL SEPARATELY
84
85 rireturn ;RETURN FROM REINITIALISATION PASS TO PERFORMANCE TIME PASSES
86 outs aresL * gkamp, aresR * gkamp ;SEND FILTER OUTPUT TO THE AUDIO OUTPUTS AND SCALE USING THE FLTK SLIDER VARIABLE gkamp
87 endin
88 </CsInstruments>
89 <CsScore>
90 ;INSTR | START | DURATION
91 i 1 0 3600 ;GUI
92 </CsScore>
93 </CsoundSynthesizer>
94
95 <bsbPanel>
96 <label>Widgets</label>
97 <objectName/>
98 <x>181</x>
99 <y>311</y>
100 <width>935</width>
101 <height>234</height>
102 <visible>true</visible>
103 <uuid/>
104 <bgcolor mode="background">
105 <r>241</r>
106 <g>226</g>
107 <b>185</b>
108 </bgcolor>
109 <bsbObject version="2" type="BSBLabel">
110 <objectName/>
111 <x>2</x>
112 <y>2</y>
113 <width>513</width>
114 <height>230</height>
115 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
116 <visible>true</visible>
117 <midichan>0</midichan>
118 <midicc>0</midicc>
119 <label>lowres</label>
120 <alignment>center</alignment>
121 <font>Liberation Sans</font>
122 <fontsize>18</fontsize>
123 <precision>3</precision>
124 <color>
125 <r>0</r>
126 <g>0</g>
127 <b>0</b>
128 </color>
129 <bgcolor mode="background">
130 <r>106</r>
131 <g>117</g>
132 <b>150</b>
133 </bgcolor>
134 <bordermode>border</bordermode>
135 <borderradius>5</borderradius>
136 <borderwidth>2</borderwidth>
137 </bsbObject>
138 <bsbObject version="2" type="BSBLabel">
139 <objectName/>
140 <x>516</x>
141 <y>2</y>
142 <width>419</width>
143 <height>230</height>
144 <uuid>{74928ed2-b701-4668-9a11-74763d317e9b}</uuid>
145 <visible>true</visible>
146 <midichan>0</midichan>
147 <midicc>0</midicc>
148 <label>lowres</label>
149 <alignment>center</alignment>
150 <font>Liberation Sans</font>
151 <fontsize>18</fontsize>
152 <precision>3</precision>
153 <color>
154 <r>0</r>
155 <g>0</g>
156 <b>0</b>
157 </color>
158 <bgcolor mode="background">
159 <r>106</r>
160 <g>117</g>
161 <b>150</b>
162 </bgcolor>
163 <bordermode>border</bordermode>
164 <borderradius>5</borderradius>
165 <borderwidth>2</borderwidth>
166 </bsbObject>
167 <bsbObject version="2" type="BSBLabel">
168 <objectName/>
169 <x>518</x>
170 <y>18</y>
171 <width>413</width>
172 <height>214</height>
173 <uuid>{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}</uuid>
174 <visible>true</visible>
175 <midichan>0</midichan>
176 <midicc>0</midicc>
177 <label>------------------------------------------------------------------------------------------------------
178 lowres is an implementation of a resonant low-pass filter. Its input arguments are for filter cutoff frequency, resonance and an optional 2-way switch (default=0) to select whether the data space for feedback within the filter is initially cleared or allowed to retain previously held information. Cutoff frequency is not in hertz and resonance is not in decibels so experimentation is recommended. 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).</label>
179 <alignment>left</alignment>
180 <font>Arial</font>
181 <fontsize>14</fontsize>
182 <precision>3</precision>
183 <color>
184 <r>0</r>
185 <g>0</g>
186 <b>0</b>
187 </color>
188 <bgcolor mode="nobackground">
189 <r>255</r>
190 <g>255</g>
191 <b>255</b>
192 </bgcolor>
193 <bordermode>noborder</bordermode>
194 <borderradius>1</borderradius>
195 <borderwidth>1</borderwidth>
196 </bsbObject>
197 <bsbObject version="2" type="BSBButton">
198 <objectName/>
199 <x>8</x>
200 <y>6</y>
201 <width>100</width>
202 <height>30</height>
203 <uuid>{24979132-c53f-4414-ac6b-6b4f503ecfe8}</uuid>
204 <visible>true</visible>
205 <midichan>0</midichan>
206 <midicc>0</midicc>
207 <type>event</type>
208 <pressedValue>1.00000000</pressedValue>
209 <stringvalue/>
210 <text> ON / OFF</text>
211 <image>/</image>
212 <eventLine>i 2 0 -1</eventLine>
213 <latch>true</latch>
214 <latched>false</latched>
215 </bsbObject>
216 <bsbObject version="2" type="BSBDisplay">
217 <objectName>Filter_Cutoff_Value</objectName>
218 <x>448</x>
219 <y>63</y>
220 <width>60</width>
221 <height>30</height>
222 <uuid>{745d6bee-b951-4a03-9fe8-9e10d5ae4556}</uuid>
223 <visible>true</visible>
224 <midichan>0</midichan>
225 <midicc>0</midicc>
226 <label>59.668</label>
227 <alignment>right</alignment>
228 <font>Arial</font>
229 <fontsize>9</fontsize>
230 <precision>3</precision>
231 <color>
232 <r>0</r>
233 <g>0</g>
234 <b>0</b>
235 </color>
236 <bgcolor mode="nobackground">
237 <r>255</r>
238 <g>255</g>
239 <b>255</b>
240 </bgcolor>
241 <bordermode>noborder</bordermode>
242 <borderradius>1</borderradius>
243 <borderwidth>1</borderwidth>
244 </bsbObject>
245 <bsbObject version="2" type="BSBHSlider">
246 <objectName>Filter_Cutoff</objectName>
247 <x>8</x>
248 <y>46</y>
249 <width>500</width>
250 <height>27</height>
251 <uuid>{06814721-6151-4baa-84e2-8f39843b07a4}</uuid>
252 <visible>true</visible>
253 <midichan>0</midichan>
254 <midicc>0</midicc>
255 <minimum>0.00000000</minimum>
256 <maximum>1.00000000</maximum>
257 <value>0.48000000</value>
258 <mode>lin</mode>
259 <mouseControl act="jump">continuous</mouseControl>
260 <resolution>-1.00000000</resolution>
261 <randomizable group="0">false</randomizable>
262 </bsbObject>
263 <bsbObject version="2" type="BSBLabel">
264 <objectName/>
265 <x>8</x>
266 <y>63</y>
267 <width>180</width>
268 <height>30</height>
269 <uuid>{c6d7165c-6730-426f-b293-52b411bc73cf}</uuid>
270 <visible>true</visible>
271 <midichan>0</midichan>
272 <midicc>0</midicc>
273 <label>Filter Cutoff (Not in Hertz!)</label>
274 <alignment>left</alignment>
275 <font>Arial</font>
276 <fontsize>10</fontsize>
277 <precision>3</precision>
278 <color>
279 <r>0</r>
280 <g>0</g>
281 <b>0</b>
282 </color>
283 <bgcolor mode="nobackground">
284 <r>255</r>
285 <g>255</g>
286 <b>255</b>
287 </bgcolor>
288 <bordermode>noborder</bordermode>
289 <borderradius>1</borderradius>
290 <borderwidth>1</borderwidth>
291 </bsbObject>
292 <bsbObject version="2" type="BSBLabel">
293 <objectName/>
294 <x>8</x>
295 <y>101</y>
296 <width>160</width>
297 <height>30</height>
298 <uuid>{f9f4369b-a39e-45aa-ba99-7457a534535f}</uuid>
299 <visible>true</visible>
300 <midichan>0</midichan>
301 <midicc>0</midicc>
302 <label>Resonance</label>
303 <alignment>left</alignment>
304 <font>Arial</font>
305 <fontsize>10</fontsize>
306 <precision>3</precision>
307 <color>
308 <r>0</r>
309 <g>0</g>
310 <b>0</b>
311 </color>
312 <bgcolor mode="nobackground">
313 <r>255</r>
314 <g>255</g>
315 <b>255</b>
316 </bgcolor>
317 <bordermode>noborder</bordermode>
318 <borderradius>1</borderradius>
319 <borderwidth>1</borderwidth>
320 </bsbObject>
321 <bsbObject version="2" type="BSBHSlider">
322 <objectName>Resonance</objectName>
323 <x>8</x>
324 <y>84</y>
325 <width>500</width>
326 <height>27</height>
327 <uuid>{42fe25e5-e98f-4f00-872c-f791822a1b3e}</uuid>
328 <visible>true</visible>
329 <midichan>0</midichan>
330 <midicc>0</midicc>
331 <minimum>0.00000000</minimum>
332 <maximum>1.00000000</maximum>
333 <value>0.40800000</value>
334 <mode>lin</mode>
335 <mouseControl act="jump">continuous</mouseControl>
336 <resolution>-1.00000000</resolution>
337 <randomizable group="0">false</randomizable>
338 </bsbObject>
339 <bsbObject version="2" type="BSBDisplay">
340 <objectName>Resonance_Value</objectName>
341 <x>448</x>
342 <y>101</y>
343 <width>60</width>
344 <height>30</height>
345 <uuid>{a8f35453-f236-447d-88d9-1a0b135383b6}</uuid>
346 <visible>true</visible>
347 <midichan>0</midichan>
348 <midicc>0</midicc>
349 <label>0.827</label>
350 <alignment>right</alignment>
351 <font>Arial</font>
352 <fontsize>9</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>173</y>
372 <width>150</width>
373 <height>30</height>
374 <uuid>{daf8bc52-99b9-4fd2-bafd-29657d0894b8}</uuid>
375 <visible>true</visible>
376 <midichan>0</midichan>
377 <midicc>0</midicc>
378 <label>Audio File</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="BSBLineEdit">
398 <objectName>_Browse</objectName>
399 <x>179</x>
400 <y>195</y>
401 <width>328</width>
402 <height>28</height>
403 <uuid>{639e5abc-1c93-41c5-9b24-69c6ba420300}</uuid>
404 <visible>true</visible>
405 <midichan>0</midichan>
406 <midicc>0</midicc>
407 <label>Seashore.wav</label>
408 <alignment>left</alignment>
409 <font>Arial</font>
410 <fontsize>10</fontsize>
411 <precision>3</precision>
412 <color>
413 <r>0</r>
414 <g>0</g>
415 <b>0</b>
416 </color>
417 <bgcolor mode="nobackground">
418 <r>229</r>
419 <g>229</g>
420 <b>229</b>
421 </bgcolor>
422 <background>nobackground</background>
423 </bsbObject>
424 <bsbObject version="2" type="BSBButton">
425 <objectName>_Browse</objectName>
426 <x>8</x>
427 <y>194</y>
428 <width>170</width>
429 <height>30</height>
430 <uuid>{83e1bb3c-be92-4763-8f5e-ae79e8f07907}</uuid>
431 <visible>true</visible>
432 <midichan>0</midichan>
433 <midicc>0</midicc>
434 <type>value</type>
435 <pressedValue>1.00000000</pressedValue>
436 <stringvalue>Seashore.wav</stringvalue>
437 <text>Browse Audio File</text>
438 <image>/</image>
439 <eventLine/>
440 <latch>false</latch>
441 <latched>false</latched>
442 </bsbObject>
443 <bsbObject version="2" type="BSBDisplay">
444 <objectName>Output_Amplitude_Scaling</objectName>
445 <x>448</x>
446 <y>138</y>
447 <width>60</width>
448 <height>30</height>
449 <uuid>{4de7125b-4cc8-4769-ac1b-083ee6357f6a}</uuid>
450 <visible>true</visible>
451 <midichan>0</midichan>
452 <midicc>0</midicc>
453 <label>0.336</label>
454 <alignment>right</alignment>
455 <font>Arial</font>
456 <fontsize>9</fontsize>
457 <precision>3</precision>
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 <bordermode>noborder</bordermode>
469 <borderradius>1</borderradius>
470 <borderwidth>1</borderwidth>
471 </bsbObject>
472 <bsbObject version="2" type="BSBHSlider">
473 <objectName>Output_Amplitude_Scaling</objectName>
474 <x>8</x>
475 <y>121</y>
476 <width>500</width>
477 <height>27</height>
478 <uuid>{3fc19561-9f06-4437-8dce-93fe562391d0}</uuid>
479 <visible>true</visible>
480 <midichan>0</midichan>
481 <midicc>0</midicc>
482 <minimum>0.00000000</minimum>
483 <maximum>1.00000000</maximum>
484 <value>0.33600000</value>
485 <mode>lin</mode>
486 <mouseControl act="jump">continuous</mouseControl>
487 <resolution>-1.00000000</resolution>
488 <randomizable group="0">false</randomizable>
489 </bsbObject>
490 <bsbObject version="2" type="BSBLabel">
491 <objectName/>
492 <x>8</x>
493 <y>138</y>
494 <width>160</width>
495 <height>30</height>
496 <uuid>{c3737a58-87dd-4c87-8bea-5dd299c564ed}</uuid>
497 <visible>true</visible>
498 <midichan>0</midichan>
499 <midicc>0</midicc>
500 <label>Output Amplitude Scaling</label>
501 <alignment>left</alignment>
502 <font>Arial</font>
503 <fontsize>10</fontsize>
504 <precision>3</precision>
505 <color>
506 <r>0</r>
507 <g>0</g>
508 <b>0</b>
509 </color>
510 <bgcolor mode="nobackground">
511 <r>255</r>
512 <g>255</g>
513 <b>255</b>
514 </bgcolor>
515 <bordermode>noborder</bordermode>
516 <borderradius>1</borderradius>
517 <borderwidth>1</borderwidth>
518 </bsbObject>
519 <bsbObject version="2" type="BSBButton">
520 <objectName>Initialisation</objectName>
521 <x>380</x>
522 <y>6</y>
523 <width>130</width>
524 <height>30</height>
525 <uuid>{046ac159-d624-4507-b091-0b9e048b0176}</uuid>
526 <visible>true</visible>
527 <midichan>0</midichan>
528 <midicc>0</midicc>
529 <type>event</type>
530 <pressedValue>1.00000000</pressedValue>
531 <stringvalue/>
532 <text> No Initialisation</text>
533 <image>/</image>
534 <eventLine/>
535 <latch>true</latch>
536 <latched>false</latched>
537 </bsbObject>
538 </bsbPanel>
539 <bsbPresets>
540 </bsbPresets>
541 <EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="false" loopStart="0" loopEnd="0"> </EventPanel>