Debian Codegraph @

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

raw
1 ;Written by Iain McCurdy, 2009
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 ; 'Filter_Cutoff' limited to 10000 Hz to avoid inf values for high 'Resonance' values
10
11
12 ;my flags on Ubuntu: -iadc -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=null -m0
13 <CsoundSynthesizer>
14 <CsOptions>
15 --env:SSDIR+=../../SourceMaterials
16 </CsOptions>
17 <CsInstruments>
18 sr = 44100 ;SAMPLE RATE
19 ksmps = 100 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
20 nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
21
22
23 giExp10000 ftgen 0, 0, 129, -25, 0, 20.0, 128, 10000.0 ;TABLE FOR EXP SLIDER
24
25
26 opcode FilePlay2, aa, Skoo ; Credit to Joachim Heintz
27 ;gives stereo output regardless your soundfile is mono or stereo
28 Sfil, kspeed, iskip, iloop xin
29 ichn filenchnls Sfil
30 if ichn == 1 then
31 aL diskin2 Sfil, kspeed, iskip, iloop
32 aR = aL
33 else
34 aL, aR diskin2 Sfil, kspeed, iskip, iloop
35 endif
36 xout aL, aR
37 endop
38
39
40 instr 1 ;GUI
41 ktrig metro 10
42 if (ktrig == 1) then
43
44 Sfile_new strcpy "" ;INIT TO EMPTY STRING
45
46 kfco invalue "Filter_Cutoff"
47 gkfco tablei kfco, giExp10000, 1
48 outvalue "Filter_Cutoff_Value", gkfco
49
50 gkres invalue "Resonance"
51 gkamp invalue "Amplitude"
52
53 gkmode invalue "Type"
54 gkskip invalue "Initialisation"
55
56 gSfile invalue "_Browse"
57 Sfile_old strcpyk Sfile_new
58 Sfile_new strcpyk gSfile
59 gkfile strcmpk Sfile_new, Sfile_old
60 endif
61 endin
62
63 instr 2
64 kporttime linseg 0,0.001,0.005,1,0.005 ;CREATE A VARIABLE FUNCTION THAT RAPIDLY RAMPS UP TO A SET VALUE
65 kfco portk gkfco, kporttime ;SMOOTH MOVEMENT OF SLIDER VARIABLE
66
67 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)
68 if kNew_file=1 then ;IF I-RATE VARIABLE CHANGE TRIGGER IS '1'...
69 reinit NEW_FILE ;BEGIN A REINITIALISATION PASS FROM LABEL 'START'
70 endif
71 NEW_FILE:
72 ;OUTPUTS OPCODE FILE | SPEED | INSKIP | LOOPING (0=OFF 1=ON)
73 asigL, asigR FilePlay2 gSfile, 1, 0, 1 ;GENERATE 2 AUDIO SIGNALS FROM A STEREO SOUND FILE
74 rireturn ;RETURN FROM REINITIALISATION PASS TO PERFORMANCE TIME PASSES
75
76 kSwitch changed gkmode, gkskip ;GENERATE A MOMENTARY '1' PULSE IN OUTPUT 'kSwitch' IF ANY OF THE SCANNED INPUT VARIABLES CHANGE. (OUTPUT 'kSwitch' IS NORMALLY ZERO)
77 if kSwitch=1 then ;IF I-RATE VARIABLE CHANGE TRIGGER IS '1'...
78 reinit START ;BEGIN A REINITIALISATION PASS FROM LABEL 'START'
79 endif
80 START:
81 aresL rezzy asigL, kfco, gkres , i(gkmode), i(gkskip)
82 aresR rezzy asigR, kfco, gkres , i(gkmode), i(gkskip)
83 rireturn
84 outs aresL * gkamp, aresR * gkamp ;SEND FILTER OUTPUT TO THE AUDIO OUTPUTS AND SCALE USING THE FLTK SLIDER DERIVED VARIABLE gkamp ;RETURN FROM REINITIALISATION PASS TO PERFORMANCE TIME PASSES
85 endin
86 </CsInstruments>
87 <CsScore>
88 ;INSTR | START | DURATION
89 i 1 0 3600 ;GUI
90 </CsScore>
91 </CsoundSynthesizer>
92
93 <bsbPanel>
94 <label>Widgets</label>
95 <objectName/>
96 <x>280</x>
97 <y>289</y>
98 <width>815</width>
99 <height>305</height>
100 <visible>true</visible>
101 <uuid/>
102 <bgcolor mode="background">
103 <r>241</r>
104 <g>226</g>
105 <b>185</b>
106 </bgcolor>
107 <bsbObject version="2" type="BSBLabel">
108 <objectName/>
109 <x>2</x>
110 <y>2</y>
111 <width>512</width>
112 <height>300</height>
113 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
114 <visible>true</visible>
115 <midichan>0</midichan>
116 <midicc>0</midicc>
117 <label>rezzy</label>
118 <alignment>center</alignment>
119 <font>Liberation Sans</font>
120 <fontsize>18</fontsize>
121 <precision>3</precision>
122 <color>
123 <r>0</r>
124 <g>0</g>
125 <b>0</b>
126 </color>
127 <bgcolor mode="background">
128 <r>106</r>
129 <g>117</g>
130 <b>150</b>
131 </bgcolor>
132 <bordermode>border</bordermode>
133 <borderradius>5</borderradius>
134 <borderwidth>2</borderwidth>
135 </bsbObject>
136 <bsbObject version="2" type="BSBLabel">
137 <objectName/>
138 <x>515</x>
139 <y>2</y>
140 <width>292</width>
141 <height>299</height>
142 <uuid>{74928ed2-b701-4668-9a11-74763d317e9b}</uuid>
143 <visible>true</visible>
144 <midichan>0</midichan>
145 <midicc>0</midicc>
146 <label>rezzy</label>
147 <alignment>center</alignment>
148 <font>Liberation Sans</font>
149 <fontsize>18</fontsize>
150 <precision>3</precision>
151 <color>
152 <r>0</r>
153 <g>0</g>
154 <b>0</b>
155 </color>
156 <bgcolor mode="background">
157 <r>106</r>
158 <g>117</g>
159 <b>150</b>
160 </bgcolor>
161 <bordermode>border</bordermode>
162 <borderradius>5</borderradius>
163 <borderwidth>2</borderwidth>
164 </bsbObject>
165 <bsbObject version="2" type="BSBLabel">
166 <objectName/>
167 <x>520</x>
168 <y>28</y>
169 <width>285</width>
170 <height>271</height>
171 <uuid>{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}</uuid>
172 <visible>true</visible>
173 <midichan>0</midichan>
174 <midicc>0</midicc>
175 <label>--------------------------------------------------------------------
176 rezzy is an implementation of a resonant low or high-pass filter. Its input arguments are for filter cutoff frequency, amount of resonance, a two-way switch selecting filter mode 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. Use of resonance can create large increases in amplitude in the output signal. In may be necessary, therefore, to rescale the amplitude of the output signal. In this example a slider has been provided to achieve this.</label>
177 <alignment>left</alignment>
178 <font>Arial</font>
179 <fontsize>14</fontsize>
180 <precision>3</precision>
181 <color>
182 <r>0</r>
183 <g>0</g>
184 <b>0</b>
185 </color>
186 <bgcolor mode="nobackground">
187 <r>255</r>
188 <g>255</g>
189 <b>255</b>
190 </bgcolor>
191 <bordermode>noborder</bordermode>
192 <borderradius>1</borderradius>
193 <borderwidth>1</borderwidth>
194 </bsbObject>
195 <bsbObject version="2" type="BSBButton">
196 <objectName/>
197 <x>8</x>
198 <y>6</y>
199 <width>100</width>
200 <height>30</height>
201 <uuid>{24979132-c53f-4414-ac6b-6b4f503ecfe8}</uuid>
202 <visible>true</visible>
203 <midichan>0</midichan>
204 <midicc>0</midicc>
205 <type>event</type>
206 <pressedValue>1.00000000</pressedValue>
207 <stringvalue/>
208 <text> ON / OFF</text>
209 <image>/</image>
210 <eventLine>i 2 0 -1</eventLine>
211 <latch>true</latch>
212 <latched>false</latched>
213 </bsbObject>
214 <bsbObject version="2" type="BSBDisplay">
215 <objectName>Filter_Cutoff_Value</objectName>
216 <x>448</x>
217 <y>63</y>
218 <width>60</width>
219 <height>30</height>
220 <uuid>{745d6bee-b951-4a03-9fe8-9e10d5ae4556}</uuid>
221 <visible>true</visible>
222 <midichan>0</midichan>
223 <midicc>0</midicc>
224 <label>2114.752</label>
225 <alignment>right</alignment>
226 <font>Arial</font>
227 <fontsize>9</fontsize>
228 <precision>3</precision>
229 <color>
230 <r>0</r>
231 <g>0</g>
232 <b>0</b>
233 </color>
234 <bgcolor mode="nobackground">
235 <r>255</r>
236 <g>255</g>
237 <b>255</b>
238 </bgcolor>
239 <bordermode>noborder</bordermode>
240 <borderradius>1</borderradius>
241 <borderwidth>1</borderwidth>
242 </bsbObject>
243 <bsbObject version="2" type="BSBHSlider">
244 <objectName>Filter_Cutoff</objectName>
245 <x>8</x>
246 <y>46</y>
247 <width>500</width>
248 <height>27</height>
249 <uuid>{06814721-6151-4baa-84e2-8f39843b07a4}</uuid>
250 <visible>true</visible>
251 <midichan>0</midichan>
252 <midicc>0</midicc>
253 <minimum>0.00000000</minimum>
254 <maximum>1.00000000</maximum>
255 <value>0.75000000</value>
256 <mode>lin</mode>
257 <mouseControl act="jump">continuous</mouseControl>
258 <resolution>-1.00000000</resolution>
259 <randomizable group="0">false</randomizable>
260 </bsbObject>
261 <bsbObject version="2" type="BSBLabel">
262 <objectName/>
263 <x>8</x>
264 <y>63</y>
265 <width>180</width>
266 <height>30</height>
267 <uuid>{c6d7165c-6730-426f-b293-52b411bc73cf}</uuid>
268 <visible>true</visible>
269 <midichan>0</midichan>
270 <midicc>0</midicc>
271 <label>Filter Cutoff</label>
272 <alignment>left</alignment>
273 <font>Arial</font>
274 <fontsize>10</fontsize>
275 <precision>3</precision>
276 <color>
277 <r>0</r>
278 <g>0</g>
279 <b>0</b>
280 </color>
281 <bgcolor mode="nobackground">
282 <r>255</r>
283 <g>255</g>
284 <b>255</b>
285 </bgcolor>
286 <bordermode>noborder</bordermode>
287 <borderradius>1</borderradius>
288 <borderwidth>1</borderwidth>
289 </bsbObject>
290 <bsbObject version="2" type="BSBHSlider">
291 <objectName>Resonance</objectName>
292 <x>8</x>
293 <y>84</y>
294 <width>500</width>
295 <height>27</height>
296 <uuid>{42fe25e5-e98f-4f00-872c-f791822a1b3e}</uuid>
297 <visible>true</visible>
298 <midichan>0</midichan>
299 <midicc>0</midicc>
300 <minimum>1.00000000</minimum>
301 <maximum>100.00000000</maximum>
302 <value>42.58000000</value>
303 <mode>lin</mode>
304 <mouseControl act="jump">continuous</mouseControl>
305 <resolution>-1.00000000</resolution>
306 <randomizable group="0">false</randomizable>
307 </bsbObject>
308 <bsbObject version="2" type="BSBDisplay">
309 <objectName>Resonance</objectName>
310 <x>448</x>
311 <y>101</y>
312 <width>60</width>
313 <height>30</height>
314 <uuid>{a8f35453-f236-447d-88d9-1a0b135383b6}</uuid>
315 <visible>true</visible>
316 <midichan>0</midichan>
317 <midicc>0</midicc>
318 <label>42.580</label>
319 <alignment>right</alignment>
320 <font>Arial</font>
321 <fontsize>9</fontsize>
322 <precision>3</precision>
323 <color>
324 <r>0</r>
325 <g>0</g>
326 <b>0</b>
327 </color>
328 <bgcolor mode="nobackground">
329 <r>255</r>
330 <g>255</g>
331 <b>255</b>
332 </bgcolor>
333 <bordermode>noborder</bordermode>
334 <borderradius>1</borderradius>
335 <borderwidth>1</borderwidth>
336 </bsbObject>
337 <bsbObject version="2" type="BSBButton">
338 <objectName>Initialisation</objectName>
339 <x>380</x>
340 <y>6</y>
341 <width>130</width>
342 <height>30</height>
343 <uuid>{88395e38-ecab-4818-bef3-1a18b504f914}</uuid>
344 <visible>true</visible>
345 <midichan>0</midichan>
346 <midicc>0</midicc>
347 <type>value</type>
348 <pressedValue>1.00000000</pressedValue>
349 <stringvalue/>
350 <text> No Initialisation</text>
351 <image>/</image>
352 <eventLine/>
353 <latch>true</latch>
354 <latched>false</latched>
355 </bsbObject>
356 <bsbObject version="2" type="BSBButton">
357 <objectName>_Browse</objectName>
358 <x>8</x>
359 <y>266</y>
360 <width>170</width>
361 <height>30</height>
362 <uuid>{43341095-bc3a-4607-bd0e-01254da7bc67}</uuid>
363 <visible>true</visible>
364 <midichan>0</midichan>
365 <midicc>0</midicc>
366 <type>value</type>
367 <pressedValue>1.00000000</pressedValue>
368 <stringvalue>Seashore.wav</stringvalue>
369 <text>Browse Audio File</text>
370 <image>/</image>
371 <eventLine/>
372 <latch>false</latch>
373 <latched>false</latched>
374 </bsbObject>
375 <bsbObject version="2" type="BSBLineEdit">
376 <objectName>_Browse</objectName>
377 <x>177</x>
378 <y>267</y>
379 <width>330</width>
380 <height>28</height>
381 <uuid>{b66f3878-dfd0-4290-9b9d-73be88197222}</uuid>
382 <visible>true</visible>
383 <midichan>0</midichan>
384 <midicc>0</midicc>
385 <label>Seashore.wav</label>
386 <alignment>left</alignment>
387 <font>Arial</font>
388 <fontsize>10</fontsize>
389 <precision>3</precision>
390 <color>
391 <r>0</r>
392 <g>0</g>
393 <b>0</b>
394 </color>
395 <bgcolor mode="nobackground">
396 <r>229</r>
397 <g>229</g>
398 <b>229</b>
399 </bgcolor>
400 <background>nobackground</background>
401 </bsbObject>
402 <bsbObject version="2" type="BSBLabel">
403 <objectName/>
404 <x>8</x>
405 <y>244</y>
406 <width>160</width>
407 <height>30</height>
408 <uuid>{7e1e7af4-88dd-4046-a781-fa2dc828b980}</uuid>
409 <visible>true</visible>
410 <midichan>0</midichan>
411 <midicc>0</midicc>
412 <label>File Input</label>
413 <alignment>left</alignment>
414 <font>Arial</font>
415 <fontsize>10</fontsize>
416 <precision>3</precision>
417 <color>
418 <r>0</r>
419 <g>0</g>
420 <b>0</b>
421 </color>
422 <bgcolor mode="nobackground">
423 <r>255</r>
424 <g>255</g>
425 <b>255</b>
426 </bgcolor>
427 <bordermode>noborder</bordermode>
428 <borderradius>1</borderradius>
429 <borderwidth>1</borderwidth>
430 </bsbObject>
431 <bsbObject version="2" type="BSBLabel">
432 <objectName/>
433 <x>8</x>
434 <y>214</y>
435 <width>160</width>
436 <height>30</height>
437 <uuid>{84df1cbe-b2a7-4a3c-bb4c-91bd48efb2ea}</uuid>
438 <visible>true</visible>
439 <midichan>0</midichan>
440 <midicc>0</midicc>
441 <label>Amplitude Rescaling</label>
442 <alignment>left</alignment>
443 <font>Arial</font>
444 <fontsize>10</fontsize>
445 <precision>3</precision>
446 <color>
447 <r>0</r>
448 <g>0</g>
449 <b>0</b>
450 </color>
451 <bgcolor mode="nobackground">
452 <r>255</r>
453 <g>255</g>
454 <b>255</b>
455 </bgcolor>
456 <bordermode>noborder</bordermode>
457 <borderradius>1</borderradius>
458 <borderwidth>1</borderwidth>
459 </bsbObject>
460 <bsbObject version="2" type="BSBHSlider">
461 <objectName>Amplitude</objectName>
462 <x>8</x>
463 <y>197</y>
464 <width>500</width>
465 <height>27</height>
466 <uuid>{f4302743-9d62-480e-823e-48caef584b70}</uuid>
467 <visible>true</visible>
468 <midichan>0</midichan>
469 <midicc>0</midicc>
470 <minimum>0.00000000</minimum>
471 <maximum>1.00000000</maximum>
472 <value>0.67000000</value>
473 <mode>lin</mode>
474 <mouseControl act="jump">continuous</mouseControl>
475 <resolution>-1.00000000</resolution>
476 <randomizable group="0">false</randomizable>
477 </bsbObject>
478 <bsbObject version="2" type="BSBDisplay">
479 <objectName>Amplitude</objectName>
480 <x>448</x>
481 <y>214</y>
482 <width>60</width>
483 <height>30</height>
484 <uuid>{64e46c55-ba7a-4cc6-9b81-55365860a8f1}</uuid>
485 <visible>true</visible>
486 <midichan>0</midichan>
487 <midicc>0</midicc>
488 <label>0.670</label>
489 <alignment>right</alignment>
490 <font>Arial</font>
491 <fontsize>9</fontsize>
492 <precision>3</precision>
493 <color>
494 <r>0</r>
495 <g>0</g>
496 <b>0</b>
497 </color>
498 <bgcolor mode="nobackground">
499 <r>255</r>
500 <g>255</g>
501 <b>255</b>
502 </bgcolor>
503 <bordermode>noborder</bordermode>
504 <borderradius>1</borderradius>
505 <borderwidth>1</borderwidth>
506 </bsbObject>
507 <bsbObject version="2" type="BSBLabel">
508 <objectName/>
509 <x>8</x>
510 <y>101</y>
511 <width>180</width>
512 <height>30</height>
513 <uuid>{027163fb-bbfe-488e-9351-1c1cd9a9d626}</uuid>
514 <visible>true</visible>
515 <midichan>0</midichan>
516 <midicc>0</midicc>
517 <label>Resonance</label>
518 <alignment>left</alignment>
519 <font>Arial</font>
520 <fontsize>10</fontsize>
521 <precision>3</precision>
522 <color>
523 <r>0</r>
524 <g>0</g>
525 <b>0</b>
526 </color>
527 <bgcolor mode="nobackground">
528 <r>255</r>
529 <g>255</g>
530 <b>255</b>
531 </bgcolor>
532 <bordermode>noborder</bordermode>
533 <borderradius>1</borderradius>
534 <borderwidth>1</borderwidth>
535 </bsbObject>
536 <bsbObject version="2" type="BSBDropdown">
537 <objectName>Type</objectName>
538 <x>385</x>
539 <y>142</y>
540 <width>120</width>
541 <height>30</height>
542 <uuid>{edca663b-aea2-4040-a052-1423ca8e65f3}</uuid>
543 <visible>true</visible>
544 <midichan>0</midichan>
545 <midicc>0</midicc>
546 <bsbDropdownItemList>
547 <bsbDropdownItem>
548 <name>Low Pass</name>
549 <value>0</value>
550 <stringvalue/>
551 </bsbDropdownItem>
552 <bsbDropdownItem>
553 <name>High Pass</name>
554 <value>1</value>
555 <stringvalue/>
556 </bsbDropdownItem>
557 </bsbDropdownItemList>
558 <selectedIndex>0</selectedIndex>
559 <randomizable group="0">false</randomizable>
560 </bsbObject>
561 <bsbObject version="2" type="BSBLabel">
562 <objectName/>
563 <x>265</x>
564 <y>142</y>
565 <width>120</width>
566 <height>30</height>
567 <uuid>{085c151c-ba9a-438e-9df9-6dcdd371e566}</uuid>
568 <visible>true</visible>
569 <midichan>0</midichan>
570 <midicc>0</midicc>
571 <label>Type</label>
572 <alignment>right</alignment>
573 <font>Arial</font>
574 <fontsize>10</fontsize>
575 <precision>3</precision>
576 <color>
577 <r>0</r>
578 <g>0</g>
579 <b>0</b>
580 </color>
581 <bgcolor mode="nobackground">
582 <r>255</r>
583 <g>255</g>
584 <b>255</b>
585 </bgcolor>
586 <bordermode>noborder</bordermode>
587 <borderradius>1</borderradius>
588 <borderwidth>1</borderwidth>
589 </bsbObject>
590 </bsbPanel>
591 <bsbPresets>
592 </bsbPresets>
593 <EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="true" loopStart="0" loopEnd="0"> </EventPanel>