Debian Codegraph @

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

raw
1 ;Written by Iain McCurdy, 2006
2
3 ;MAKE ADJUSTMENTS CAUTIOUSLY - VERY UNPLEASANT SOUNDS ARE POSSIBLE WITH THIS OPCODE - PROTECT YOUR EARS!
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 giExp1 ftgen 0, 0, 129, -25, 0, 0.001, 128, 1.0
26 giExp500 ftgen 0, 0, 129, -25, 0, 0.001, 128, 500.0
27 giExp5000 ftgen 0, 0, 129, -25, 0, 1.0, 128, 5000.0
28
29
30 opcode FilePlay2, aa, Skoo ; Credit to Joachim Heintz
31 ;gives stereo output regardless your soundfile is mono or stereo
32 Sfil, kspeed, iskip, iloop xin
33 ichn filenchnls Sfil
34 if ichn == 1 then
35 aL diskin2 Sfil, kspeed, iskip, iloop
36 aR = aL
37 else
38 aL, aR diskin2 Sfil, kspeed, iskip, iloop
39 endif
40 xout aL, aR
41 endop
42
43
44 instr 1 ;GUI
45
46 Sfile_new strcpy "" ;INIT TO EMPTY STRING
47
48 ktrig metro 10
49 if (ktrig == 1) then
50 kcutoff invalue "Filter_Cutoff"
51 gkcutoff tablei kcutoff, giExp5000, 1
52 outvalue "Filter_Cutoff_Value", gkcutoff
53 kresonance invalue "Resonance"
54 gkresonance tablei kresonance, giExp500, 1
55 outvalue "Resonance_Value", gkresonance
56 kamp invalue "Output_Amplitude_Scaling"
57 gkamp tablei kamp, giExp1, 1
58 outvalue "Output_Amplitude_Scaling_Value", gkamp
59
60 gknumlayer invalue "Layers"
61 gkskip invalue "Initialisation"
62
63 gSfile invalue "_Browse"
64 Sfile_old strcpyk Sfile_new
65 Sfile_new strcpyk gSfile
66 gkfile strcmpk Sfile_new, Sfile_old
67 endif
68 endin
69
70 instr 2
71 kporttime linseg 0,0.001,0.005,1,0.005 ;CREATE A VARIABLE FUNCTION THAT RAPIDLY RAMPS UP TO A SET VALUE
72 kcutoff portk gkcutoff, kporttime ;SMOOTH MOVEMENT OF SLIDER VARIABLE
73
74 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)
75 if kNew_file=1 then ;IF I-RATE VARIABLE CHANGE TRIGGER IS '1'...
76 reinit NEW_FILE ;BEGIN A REINITIALISATION PASS FROM LABEL 'START'
77 endif
78 NEW_FILE:
79 ;OUTPUTS OPCODE FILE | SPEED | INSKIP | LOOPING (0=OFF 1=ON)
80 asigL, asigR FilePlay2 gSfile, 1, 0, 1 ;GENERATE 2 AUDIO SIGNALS FROM A STEREO SOUND FILE
81 rireturn ;RETURN FROM REINITIALISATION PASS TO PERFORMANCE TIME PASSES
82
83 kSwitch changed gkskip, gknumlayer ;GENERATE A MOMENTARY '1' PULSE IN OUTPUT 'kSwitch' IF ANY OF THE SCANNED INPUT VARIABLES CHANGE. (OUTPUT 'kSwitch' IS NORMALLY ZERO)
84 if kSwitch=1 then ;IF I-RATE VARIABLE CHANGE TRIGGER IS '1'...
85 reinit START ;BEGIN A REINITIALISATION PASS FROM LABEL 'START'
86 endif
87 START:
88 aresL lowresx asigL, kcutoff, gkresonance, i(gknumlayer), i(gkskip) ;FILTER EACH CHANNEL SEPARATELY
89 aresR lowresx asigR, kcutoff, gkresonance, i(gknumlayer), i(gkskip) ;FILTER EACH CHANNEL SEPARATELY
90
91 rireturn ;RETURN FROM REINITIALISATION PASS TO PERFORMANCE TIME PASSES
92 outs aresL * gkamp, aresR * gkamp ;SEND FILTER OUTPUT TO THE AUDIO OUTPUTS AND SCALE USING THE FLTK SLIDER VARIABLE gkamp
93 endin
94 </CsInstruments>
95 <CsScore>
96 ;INSTR | START | DURATION
97 i 1 0 3600 ;GUI
98 </CsScore>
99 </CsoundSynthesizer>
100
101 <bsbPanel>
102 <label>Widgets</label>
103 <objectName/>
104 <x>422</x>
105 <y>337</y>
106 <width>943</width>
107 <height>305</height>
108 <visible>true</visible>
109 <uuid/>
110 <bgcolor mode="background">
111 <r>241</r>
112 <g>226</g>
113 <b>185</b>
114 </bgcolor>
115 <bsbObject version="2" type="BSBLabel">
116 <objectName/>
117 <x>2</x>
118 <y>2</y>
119 <width>513</width>
120 <height>300</height>
121 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
122 <visible>true</visible>
123 <midichan>0</midichan>
124 <midicc>0</midicc>
125 <label>lowresx</label>
126 <alignment>center</alignment>
127 <font>Liberation Sans</font>
128 <fontsize>18</fontsize>
129 <precision>3</precision>
130 <color>
131 <r>0</r>
132 <g>0</g>
133 <b>0</b>
134 </color>
135 <bgcolor mode="background">
136 <r>106</r>
137 <g>117</g>
138 <b>150</b>
139 </bgcolor>
140 <bordermode>border</bordermode>
141 <borderradius>5</borderradius>
142 <borderwidth>2</borderwidth>
143 </bsbObject>
144 <bsbObject version="2" type="BSBLabel">
145 <objectName/>
146 <x>516</x>
147 <y>2</y>
148 <width>420</width>
149 <height>300</height>
150 <uuid>{74928ed2-b701-4668-9a11-74763d317e9b}</uuid>
151 <visible>true</visible>
152 <midichan>0</midichan>
153 <midicc>0</midicc>
154 <label>lowresx</label>
155 <alignment>center</alignment>
156 <font>Liberation Sans</font>
157 <fontsize>18</fontsize>
158 <precision>3</precision>
159 <color>
160 <r>0</r>
161 <g>0</g>
162 <b>0</b>
163 </color>
164 <bgcolor mode="background">
165 <r>106</r>
166 <g>117</g>
167 <b>150</b>
168 </bgcolor>
169 <bordermode>border</bordermode>
170 <borderradius>5</borderradius>
171 <borderwidth>2</borderwidth>
172 </bsbObject>
173 <bsbObject version="2" type="BSBLabel">
174 <objectName/>
175 <x>518</x>
176 <y>15</y>
177 <width>416</width>
178 <height>288</height>
179 <uuid>{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}</uuid>
180 <visible>true</visible>
181 <midichan>0</midichan>
182 <midicc>0</midicc>
183 <label>------------------------------------------------------------------------------------------------------
184 lowresx is an implementation of a resonant low-pass filter. Its input arguments are for filter cutoff frequency, resonance, number of iterations of the filter (optional, default=4) 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). lowresx is equivalent to multiple iterations of the lowres opcode connected in series. Extremely loud and piercing tones are possible with this opcode so use with care and protect your ears and speakers!</label>
185 <alignment>left</alignment>
186 <font>Arial</font>
187 <fontsize>14</fontsize>
188 <precision>3</precision>
189 <color>
190 <r>0</r>
191 <g>0</g>
192 <b>0</b>
193 </color>
194 <bgcolor mode="nobackground">
195 <r>255</r>
196 <g>255</g>
197 <b>255</b>
198 </bgcolor>
199 <bordermode>noborder</bordermode>
200 <borderradius>1</borderradius>
201 <borderwidth>1</borderwidth>
202 </bsbObject>
203 <bsbObject version="2" type="BSBButton">
204 <objectName/>
205 <x>8</x>
206 <y>6</y>
207 <width>100</width>
208 <height>30</height>
209 <uuid>{24979132-c53f-4414-ac6b-6b4f503ecfe8}</uuid>
210 <visible>true</visible>
211 <midichan>0</midichan>
212 <midicc>0</midicc>
213 <type>event</type>
214 <pressedValue>1.00000000</pressedValue>
215 <stringvalue/>
216 <text> ON / OFF</text>
217 <image>/</image>
218 <eventLine>i 2 0 -1</eventLine>
219 <latch>true</latch>
220 <latched>false</latched>
221 </bsbObject>
222 <bsbObject version="2" type="BSBDisplay">
223 <objectName>Filter_Cutoff_Value</objectName>
224 <x>448</x>
225 <y>63</y>
226 <width>60</width>
227 <height>30</height>
228 <uuid>{745d6bee-b951-4a03-9fe8-9e10d5ae4556}</uuid>
229 <visible>true</visible>
230 <midichan>0</midichan>
231 <midicc>0</midicc>
232 <label>96.134</label>
233 <alignment>right</alignment>
234 <font>Arial</font>
235 <fontsize>9</fontsize>
236 <precision>3</precision>
237 <color>
238 <r>0</r>
239 <g>0</g>
240 <b>0</b>
241 </color>
242 <bgcolor mode="nobackground">
243 <r>255</r>
244 <g>255</g>
245 <b>255</b>
246 </bgcolor>
247 <bordermode>noborder</bordermode>
248 <borderradius>1</borderradius>
249 <borderwidth>1</borderwidth>
250 </bsbObject>
251 <bsbObject version="2" type="BSBHSlider">
252 <objectName>Filter_Cutoff</objectName>
253 <x>8</x>
254 <y>46</y>
255 <width>500</width>
256 <height>27</height>
257 <uuid>{06814721-6151-4baa-84e2-8f39843b07a4}</uuid>
258 <visible>true</visible>
259 <midichan>0</midichan>
260 <midicc>0</midicc>
261 <minimum>0.00000000</minimum>
262 <maximum>1.00000000</maximum>
263 <value>0.53600000</value>
264 <mode>lin</mode>
265 <mouseControl act="jump">continuous</mouseControl>
266 <resolution>-1.00000000</resolution>
267 <randomizable group="0">false</randomizable>
268 </bsbObject>
269 <bsbObject version="2" type="BSBLabel">
270 <objectName/>
271 <x>8</x>
272 <y>63</y>
273 <width>180</width>
274 <height>30</height>
275 <uuid>{c6d7165c-6730-426f-b293-52b411bc73cf}</uuid>
276 <visible>true</visible>
277 <midichan>0</midichan>
278 <midicc>0</midicc>
279 <label>Filter Cutoff (Not in Hertz!)</label>
280 <alignment>left</alignment>
281 <font>Arial</font>
282 <fontsize>10</fontsize>
283 <precision>3</precision>
284 <color>
285 <r>0</r>
286 <g>0</g>
287 <b>0</b>
288 </color>
289 <bgcolor mode="nobackground">
290 <r>255</r>
291 <g>255</g>
292 <b>255</b>
293 </bgcolor>
294 <bordermode>noborder</bordermode>
295 <borderradius>1</borderradius>
296 <borderwidth>1</borderwidth>
297 </bsbObject>
298 <bsbObject version="2" type="BSBLabel">
299 <objectName/>
300 <x>8</x>
301 <y>101</y>
302 <width>160</width>
303 <height>30</height>
304 <uuid>{f9f4369b-a39e-45aa-ba99-7457a534535f}</uuid>
305 <visible>true</visible>
306 <midichan>0</midichan>
307 <midicc>0</midicc>
308 <label>Resonance</label>
309 <alignment>left</alignment>
310 <font>Arial</font>
311 <fontsize>10</fontsize>
312 <precision>3</precision>
313 <color>
314 <r>0</r>
315 <g>0</g>
316 <b>0</b>
317 </color>
318 <bgcolor mode="nobackground">
319 <r>255</r>
320 <g>255</g>
321 <b>255</b>
322 </bgcolor>
323 <bordermode>noborder</bordermode>
324 <borderradius>1</borderradius>
325 <borderwidth>1</borderwidth>
326 </bsbObject>
327 <bsbObject version="2" type="BSBHSlider">
328 <objectName>Resonance</objectName>
329 <x>8</x>
330 <y>84</y>
331 <width>500</width>
332 <height>27</height>
333 <uuid>{42fe25e5-e98f-4f00-872c-f791822a1b3e}</uuid>
334 <visible>true</visible>
335 <midichan>0</midichan>
336 <midicc>0</midicc>
337 <minimum>0.00000000</minimum>
338 <maximum>1.00000000</maximum>
339 <value>0.51200000</value>
340 <mode>lin</mode>
341 <mouseControl act="jump">continuous</mouseControl>
342 <resolution>-1.00000000</resolution>
343 <randomizable group="0">false</randomizable>
344 </bsbObject>
345 <bsbObject version="2" type="BSBDisplay">
346 <objectName>Resonance_Value</objectName>
347 <x>448</x>
348 <y>101</y>
349 <width>60</width>
350 <height>30</height>
351 <uuid>{a8f35453-f236-447d-88d9-1a0b135383b6}</uuid>
352 <visible>true</visible>
353 <midichan>0</midichan>
354 <midicc>0</midicc>
355 <label>0.829</label>
356 <alignment>right</alignment>
357 <font>Arial</font>
358 <fontsize>9</fontsize>
359 <precision>3</precision>
360 <color>
361 <r>0</r>
362 <g>0</g>
363 <b>0</b>
364 </color>
365 <bgcolor mode="nobackground">
366 <r>255</r>
367 <g>255</g>
368 <b>255</b>
369 </bgcolor>
370 <bordermode>noborder</bordermode>
371 <borderradius>1</borderradius>
372 <borderwidth>1</borderwidth>
373 </bsbObject>
374 <bsbObject version="2" type="BSBLabel">
375 <objectName/>
376 <x>9</x>
377 <y>227</y>
378 <width>150</width>
379 <height>30</height>
380 <uuid>{daf8bc52-99b9-4fd2-bafd-29657d0894b8}</uuid>
381 <visible>true</visible>
382 <midichan>0</midichan>
383 <midicc>0</midicc>
384 <label>Audio File</label>
385 <alignment>left</alignment>
386 <font>Arial</font>
387 <fontsize>10</fontsize>
388 <precision>3</precision>
389 <color>
390 <r>0</r>
391 <g>0</g>
392 <b>0</b>
393 </color>
394 <bgcolor mode="nobackground">
395 <r>255</r>
396 <g>255</g>
397 <b>255</b>
398 </bgcolor>
399 <bordermode>noborder</bordermode>
400 <borderradius>1</borderradius>
401 <borderwidth>1</borderwidth>
402 </bsbObject>
403 <bsbObject version="2" type="BSBLineEdit">
404 <objectName>_Browse</objectName>
405 <x>180</x>
406 <y>249</y>
407 <width>328</width>
408 <height>28</height>
409 <uuid>{639e5abc-1c93-41c5-9b24-69c6ba420300}</uuid>
410 <visible>true</visible>
411 <midichan>0</midichan>
412 <midicc>0</midicc>
413 <label>808loop.wav</label>
414 <alignment>left</alignment>
415 <font>Arial</font>
416 <fontsize>10</fontsize>
417 <precision>3</precision>
418 <color>
419 <r>0</r>
420 <g>0</g>
421 <b>0</b>
422 </color>
423 <bgcolor mode="nobackground">
424 <r>229</r>
425 <g>229</g>
426 <b>229</b>
427 </bgcolor>
428 <background>nobackground</background>
429 </bsbObject>
430 <bsbObject version="2" type="BSBButton">
431 <objectName>_Browse</objectName>
432 <x>9</x>
433 <y>248</y>
434 <width>170</width>
435 <height>30</height>
436 <uuid>{83e1bb3c-be92-4763-8f5e-ae79e8f07907}</uuid>
437 <visible>true</visible>
438 <midichan>0</midichan>
439 <midicc>0</midicc>
440 <type>value</type>
441 <pressedValue>1.00000000</pressedValue>
442 <stringvalue>808loop.wav</stringvalue>
443 <text>Browse Audio File</text>
444 <image>/</image>
445 <eventLine/>
446 <latch>false</latch>
447 <latched>false</latched>
448 </bsbObject>
449 <bsbObject version="2" type="BSBDisplay">
450 <objectName>Output_Amplitude_Scaling_Value</objectName>
451 <x>448</x>
452 <y>138</y>
453 <width>60</width>
454 <height>30</height>
455 <uuid>{4de7125b-4cc8-4769-ac1b-083ee6357f6a}</uuid>
456 <visible>true</visible>
457 <midichan>0</midichan>
458 <midicc>0</midicc>
459 <label>0.039</label>
460 <alignment>right</alignment>
461 <font>Arial</font>
462 <fontsize>9</fontsize>
463 <precision>3</precision>
464 <color>
465 <r>0</r>
466 <g>0</g>
467 <b>0</b>
468 </color>
469 <bgcolor mode="nobackground">
470 <r>255</r>
471 <g>255</g>
472 <b>255</b>
473 </bgcolor>
474 <bordermode>noborder</bordermode>
475 <borderradius>1</borderradius>
476 <borderwidth>1</borderwidth>
477 </bsbObject>
478 <bsbObject version="2" type="BSBHSlider">
479 <objectName>Output_Amplitude_Scaling</objectName>
480 <x>8</x>
481 <y>121</y>
482 <width>500</width>
483 <height>27</height>
484 <uuid>{3fc19561-9f06-4437-8dce-93fe562391d0}</uuid>
485 <visible>true</visible>
486 <midichan>0</midichan>
487 <midicc>0</midicc>
488 <minimum>0.00000000</minimum>
489 <maximum>1.00000000</maximum>
490 <value>0.53200000</value>
491 <mode>lin</mode>
492 <mouseControl act="jump">continuous</mouseControl>
493 <resolution>-1.00000000</resolution>
494 <randomizable group="0">false</randomizable>
495 </bsbObject>
496 <bsbObject version="2" type="BSBLabel">
497 <objectName/>
498 <x>8</x>
499 <y>138</y>
500 <width>160</width>
501 <height>30</height>
502 <uuid>{c3737a58-87dd-4c87-8bea-5dd299c564ed}</uuid>
503 <visible>true</visible>
504 <midichan>0</midichan>
505 <midicc>0</midicc>
506 <label>Output Amplitude Scaling</label>
507 <alignment>left</alignment>
508 <font>Arial</font>
509 <fontsize>10</fontsize>
510 <precision>3</precision>
511 <color>
512 <r>0</r>
513 <g>0</g>
514 <b>0</b>
515 </color>
516 <bgcolor mode="nobackground">
517 <r>255</r>
518 <g>255</g>
519 <b>255</b>
520 </bgcolor>
521 <bordermode>noborder</bordermode>
522 <borderradius>1</borderradius>
523 <borderwidth>1</borderwidth>
524 </bsbObject>
525 <bsbObject version="2" type="BSBButton">
526 <objectName>Initialisation</objectName>
527 <x>338</x>
528 <y>184</y>
529 <width>130</width>
530 <height>30</height>
531 <uuid>{046ac159-d624-4507-b091-0b9e048b0176}</uuid>
532 <visible>true</visible>
533 <midichan>0</midichan>
534 <midicc>0</midicc>
535 <type>event</type>
536 <pressedValue>1.00000000</pressedValue>
537 <stringvalue/>
538 <text> No Initialisation</text>
539 <image>/</image>
540 <eventLine/>
541 <latch>true</latch>
542 <latched>false</latched>
543 </bsbObject>
544 <bsbObject version="2" type="BSBLabel">
545 <objectName/>
546 <x>103</x>
547 <y>184</y>
548 <width>120</width>
549 <height>30</height>
550 <uuid>{1050377b-ba71-4def-bbfa-ec602db3bfea}</uuid>
551 <visible>true</visible>
552 <midichan>0</midichan>
553 <midicc>0</midicc>
554 <label>Number of Layers</label>
555 <alignment>right</alignment>
556 <font>Arial</font>
557 <fontsize>10</fontsize>
558 <precision>3</precision>
559 <color>
560 <r>0</r>
561 <g>0</g>
562 <b>0</b>
563 </color>
564 <bgcolor mode="nobackground">
565 <r>255</r>
566 <g>255</g>
567 <b>255</b>
568 </bgcolor>
569 <bordermode>noborder</bordermode>
570 <borderradius>1</borderradius>
571 <borderwidth>1</borderwidth>
572 </bsbObject>
573 <bsbObject version="2" type="BSBSpinBox">
574 <objectName>Layers</objectName>
575 <x>223</x>
576 <y>184</y>
577 <width>40</width>
578 <height>30</height>
579 <uuid>{d1cfbe91-87be-4d2c-94ce-ca3d5e1df547}</uuid>
580 <visible>true</visible>
581 <midichan>0</midichan>
582 <midicc>0</midicc>
583 <alignment>left</alignment>
584 <font>Arial</font>
585 <fontsize>14</fontsize>
586 <color>
587 <r>0</r>
588 <g>0</g>
589 <b>0</b>
590 </color>
591 <bgcolor mode="nobackground">
592 <r>255</r>
593 <g>255</g>
594 <b>255</b>
595 </bgcolor>
596 <resolution>1.00000000</resolution>
597 <minimum>1</minimum>
598 <maximum>10</maximum>
599 <randomizable group="0">false</randomizable>
600 <value>4</value>
601 </bsbObject>
602 </bsbPanel>
603 <bsbPresets>
604 </bsbPresets>
605 <EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="true" loopStart="0" loopEnd="0"> </EventPanel>