Debian Codegraph @

src/Examples/McCurdy Collection/Filters/lpf18.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
9
10 ;my flags on Ubuntu: -iadc -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=null -m0
11 <CsoundSynthesizer>
12 <CsOptions>
13
14 </CsOptions>
15 <CsInstruments>
16 sr = 44100 ;SAMPLE RATE
17 ksmps = 100 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
18 nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
19 0dbfs = 1 ;MAXIMUM SOUND INTENSITY LEVEL REGARDLESS OF BIT DEPTH
20
21 gisine ftgen 0, 0, 131072, 10, 1 ;SINE WAVE FUNCTION TABLE
22 ;TABLES FOR EXP SLIDER
23 giExp19000 ftgen 0, 0, 129, -25, 0, 20.0, 128, 19000.0
24 giExp20000 ftgen 0, 0, 129, -25, 0, 20.0, 128, 20000.0
25
26
27 instr 1 ;GUI
28 ktrig metro 10
29 if (ktrig == 1) then
30 kfco invalue "Filter_Cutoff"
31 gkfco tablei kfco, giExp19000, 1
32 outvalue "Filter_Cutoff_Value", gkfco
33 gkres invalue "Resonance"
34 gkdist invalue "Distortion"
35 kfrq invalue "Oscillator_Frequency"
36 gkfrq tablei kfrq, giExp20000, 1
37 outvalue "Oscillator_Frequency_Value", gkfrq
38 gkgain invalue "Output_Amplitude_Scaling"
39 endif
40 endin
41
42 instr 2
43 kporttime linseg 0,0.001,0.005,1,0.005 ;CREATE A VARIABLE FUNCTION THAT RAPIDLY RAMPS UP TO A SET VALUE
44 kfrq portk gkfrq, kporttime ;SMOOTH MOVEMENT OF SLIDER VARIABLE
45 kfco portk gkfco, kporttime ;SMOOTH MOVEMENT OF SLIDER VARIABLE
46 asig vco 1, kfrq, 1, 0, gisine ;GENERATE A TRIANGLE WAVE AUDIO SIGNAL (NOTE THAT lpf18 EXPECTS A SIGNAL WITHIN THE RANGE -1 TO 1)
47 ares lpf18 asig, kfco, gkres, gkdist
48 outs ares * gkgain, ares * gkgain ;FILTER OUTPUT IS SENT TO THE AUDIO OUTPUTS AND RESCALED USING gkgain SLIDER VARIABLE
49 endin
50 </CsInstruments>
51 <CsScore>
52 ;INSTR | START | DURATION
53 i 1 0 3600 ;GUI
54 </CsScore>
55 </CsoundSynthesizer>
56 <bsbPanel>
57 <label>Widgets</label>
58 <objectName/>
59 <x>238</x>
60 <y>369</y>
61 <width>906</width>
62 <height>263</height>
63 <visible>true</visible>
64 <uuid/>
65 <bgcolor mode="background">
66 <r>241</r>
67 <g>226</g>
68 <b>185</b>
69 </bgcolor>
70 <bsbObject version="2" type="BSBLabel">
71 <objectName/>
72 <x>2</x>
73 <y>2</y>
74 <width>512</width>
75 <height>260</height>
76 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
77 <visible>true</visible>
78 <midichan>0</midichan>
79 <midicc>0</midicc>
80 <label>lpf18</label>
81 <alignment>center</alignment>
82 <font>Liberation Sans</font>
83 <fontsize>18</fontsize>
84 <precision>3</precision>
85 <color>
86 <r>0</r>
87 <g>0</g>
88 <b>0</b>
89 </color>
90 <bgcolor mode="background">
91 <r>106</r>
92 <g>117</g>
93 <b>150</b>
94 </bgcolor>
95 <bordermode>border</bordermode>
96 <borderradius>5</borderradius>
97 <borderwidth>2</borderwidth>
98 </bsbObject>
99 <bsbObject version="2" type="BSBLabel">
100 <objectName/>
101 <x>516</x>
102 <y>2</y>
103 <width>385</width>
104 <height>260</height>
105 <uuid>{74928ed2-b701-4668-9a11-74763d317e9b}</uuid>
106 <visible>true</visible>
107 <midichan>0</midichan>
108 <midicc>0</midicc>
109 <label>lpf18</label>
110 <alignment>center</alignment>
111 <font>Liberation Sans</font>
112 <fontsize>18</fontsize>
113 <precision>3</precision>
114 <color>
115 <r>0</r>
116 <g>0</g>
117 <b>0</b>
118 </color>
119 <bgcolor mode="background">
120 <r>106</r>
121 <g>117</g>
122 <b>150</b>
123 </bgcolor>
124 <bordermode>border</bordermode>
125 <borderradius>5</borderradius>
126 <borderwidth>2</borderwidth>
127 </bsbObject>
128 <bsbObject version="2" type="BSBLabel">
129 <objectName/>
130 <x>519</x>
131 <y>20</y>
132 <width>381</width>
133 <height>237</height>
134 <uuid>{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}</uuid>
135 <visible>true</visible>
136 <midichan>0</midichan>
137 <midicc>0</midicc>
138 <label>---------------------------------------------------------------------------------------------
139 lpf18 is a implementation of a 3-pole resonant low-pass filter. The '18' refers to the statistic that states that amplitude drops off at 18 decibels per octave beyond the cutoff frequency. The opcode's input arguments include cutoff frequency, resonance and distortion. Use of resonance and distortion can cause an increase in amplitude. To accomodate this phenomenon this example includes a control to scale down the output amplitude. An alternative approach would be to make use of the balance opcode to dynamically control the output signal. The input signal used in this example is a sawtooth waveform, the frequency of which is adjustable using an on-screen slider.</label>
140 <alignment>left</alignment>
141 <font>Arial</font>
142 <fontsize>14</fontsize>
143 <precision>3</precision>
144 <color>
145 <r>0</r>
146 <g>0</g>
147 <b>0</b>
148 </color>
149 <bgcolor mode="nobackground">
150 <r>255</r>
151 <g>255</g>
152 <b>255</b>
153 </bgcolor>
154 <bordermode>noborder</bordermode>
155 <borderradius>1</borderradius>
156 <borderwidth>1</borderwidth>
157 </bsbObject>
158 <bsbObject version="2" type="BSBButton">
159 <objectName/>
160 <x>8</x>
161 <y>6</y>
162 <width>100</width>
163 <height>30</height>
164 <uuid>{24979132-c53f-4414-ac6b-6b4f503ecfe8}</uuid>
165 <visible>true</visible>
166 <midichan>0</midichan>
167 <midicc>0</midicc>
168 <type>event</type>
169 <pressedValue>1.00000000</pressedValue>
170 <stringvalue/>
171 <text> ON / OFF</text>
172 <image>/</image>
173 <eventLine>i 2 0 -1</eventLine>
174 <latch>true</latch>
175 <latched>false</latched>
176 </bsbObject>
177 <bsbObject version="2" type="BSBDisplay">
178 <objectName>Filter_Cutoff_Value</objectName>
179 <x>448</x>
180 <y>63</y>
181 <width>60</width>
182 <height>30</height>
183 <uuid>{745d6bee-b951-4a03-9fe8-9e10d5ae4556}</uuid>
184 <visible>true</visible>
185 <midichan>0</midichan>
186 <midicc>0</midicc>
187 <label>431.710</label>
188 <alignment>right</alignment>
189 <font>Arial</font>
190 <fontsize>9</fontsize>
191 <precision>3</precision>
192 <color>
193 <r>0</r>
194 <g>0</g>
195 <b>0</b>
196 </color>
197 <bgcolor mode="nobackground">
198 <r>255</r>
199 <g>255</g>
200 <b>255</b>
201 </bgcolor>
202 <bordermode>noborder</bordermode>
203 <borderradius>1</borderradius>
204 <borderwidth>1</borderwidth>
205 </bsbObject>
206 <bsbObject version="2" type="BSBHSlider">
207 <objectName>Filter_Cutoff</objectName>
208 <x>8</x>
209 <y>46</y>
210 <width>500</width>
211 <height>27</height>
212 <uuid>{06814721-6151-4baa-84e2-8f39843b07a4}</uuid>
213 <visible>true</visible>
214 <midichan>0</midichan>
215 <midicc>0</midicc>
216 <minimum>0.00000000</minimum>
217 <maximum>1.00000000</maximum>
218 <value>0.44800000</value>
219 <mode>lin</mode>
220 <mouseControl act="jump">continuous</mouseControl>
221 <resolution>-1.00000000</resolution>
222 <randomizable group="0">false</randomizable>
223 </bsbObject>
224 <bsbObject version="2" type="BSBLabel">
225 <objectName/>
226 <x>8</x>
227 <y>63</y>
228 <width>180</width>
229 <height>30</height>
230 <uuid>{c6d7165c-6730-426f-b293-52b411bc73cf}</uuid>
231 <visible>true</visible>
232 <midichan>0</midichan>
233 <midicc>0</midicc>
234 <label>Filter Cutoff</label>
235 <alignment>left</alignment>
236 <font>Arial</font>
237 <fontsize>10</fontsize>
238 <precision>3</precision>
239 <color>
240 <r>0</r>
241 <g>0</g>
242 <b>0</b>
243 </color>
244 <bgcolor mode="nobackground">
245 <r>255</r>
246 <g>255</g>
247 <b>255</b>
248 </bgcolor>
249 <bordermode>noborder</bordermode>
250 <borderradius>1</borderradius>
251 <borderwidth>1</borderwidth>
252 </bsbObject>
253 <bsbObject version="2" type="BSBLabel">
254 <objectName/>
255 <x>8</x>
256 <y>101</y>
257 <width>160</width>
258 <height>30</height>
259 <uuid>{f9f4369b-a39e-45aa-ba99-7457a534535f}</uuid>
260 <visible>true</visible>
261 <midichan>0</midichan>
262 <midicc>0</midicc>
263 <label>Resonance</label>
264 <alignment>left</alignment>
265 <font>Arial</font>
266 <fontsize>10</fontsize>
267 <precision>3</precision>
268 <color>
269 <r>0</r>
270 <g>0</g>
271 <b>0</b>
272 </color>
273 <bgcolor mode="nobackground">
274 <r>255</r>
275 <g>255</g>
276 <b>255</b>
277 </bgcolor>
278 <bordermode>noborder</bordermode>
279 <borderradius>1</borderradius>
280 <borderwidth>1</borderwidth>
281 </bsbObject>
282 <bsbObject version="2" type="BSBHSlider">
283 <objectName>Resonance</objectName>
284 <x>8</x>
285 <y>84</y>
286 <width>500</width>
287 <height>27</height>
288 <uuid>{42fe25e5-e98f-4f00-872c-f791822a1b3e}</uuid>
289 <visible>true</visible>
290 <midichan>0</midichan>
291 <midicc>0</midicc>
292 <minimum>0.00000000</minimum>
293 <maximum>1.00000000</maximum>
294 <value>0.17800000</value>
295 <mode>lin</mode>
296 <mouseControl act="jump">continuous</mouseControl>
297 <resolution>-1.00000000</resolution>
298 <randomizable group="0">false</randomizable>
299 </bsbObject>
300 <bsbObject version="2" type="BSBDisplay">
301 <objectName>Resonance</objectName>
302 <x>448</x>
303 <y>101</y>
304 <width>60</width>
305 <height>30</height>
306 <uuid>{a8f35453-f236-447d-88d9-1a0b135383b6}</uuid>
307 <visible>true</visible>
308 <midichan>0</midichan>
309 <midicc>0</midicc>
310 <label>0.178</label>
311 <alignment>right</alignment>
312 <font>Arial</font>
313 <fontsize>9</fontsize>
314 <precision>3</precision>
315 <color>
316 <r>0</r>
317 <g>0</g>
318 <b>0</b>
319 </color>
320 <bgcolor mode="nobackground">
321 <r>255</r>
322 <g>255</g>
323 <b>255</b>
324 </bgcolor>
325 <bordermode>noborder</bordermode>
326 <borderradius>1</borderradius>
327 <borderwidth>1</borderwidth>
328 </bsbObject>
329 <bsbObject version="2" type="BSBDisplay">
330 <objectName>Distortion</objectName>
331 <x>448</x>
332 <y>138</y>
333 <width>60</width>
334 <height>30</height>
335 <uuid>{4de7125b-4cc8-4769-ac1b-083ee6357f6a}</uuid>
336 <visible>true</visible>
337 <midichan>0</midichan>
338 <midicc>0</midicc>
339 <label>2.860</label>
340 <alignment>right</alignment>
341 <font>Arial</font>
342 <fontsize>9</fontsize>
343 <precision>3</precision>
344 <color>
345 <r>0</r>
346 <g>0</g>
347 <b>0</b>
348 </color>
349 <bgcolor mode="nobackground">
350 <r>255</r>
351 <g>255</g>
352 <b>255</b>
353 </bgcolor>
354 <bordermode>noborder</bordermode>
355 <borderradius>1</borderradius>
356 <borderwidth>1</borderwidth>
357 </bsbObject>
358 <bsbObject version="2" type="BSBHSlider">
359 <objectName>Distortion</objectName>
360 <x>8</x>
361 <y>121</y>
362 <width>500</width>
363 <height>27</height>
364 <uuid>{3fc19561-9f06-4437-8dce-93fe562391d0}</uuid>
365 <visible>true</visible>
366 <midichan>0</midichan>
367 <midicc>0</midicc>
368 <minimum>0.00000000</minimum>
369 <maximum>11.00000000</maximum>
370 <value>2.86000000</value>
371 <mode>lin</mode>
372 <mouseControl act="jump">continuous</mouseControl>
373 <resolution>-1.00000000</resolution>
374 <randomizable group="0">false</randomizable>
375 </bsbObject>
376 <bsbObject version="2" type="BSBLabel">
377 <objectName/>
378 <x>8</x>
379 <y>138</y>
380 <width>160</width>
381 <height>30</height>
382 <uuid>{c3737a58-87dd-4c87-8bea-5dd299c564ed}</uuid>
383 <visible>true</visible>
384 <midichan>0</midichan>
385 <midicc>0</midicc>
386 <label>Distortion</label>
387 <alignment>left</alignment>
388 <font>Arial</font>
389 <fontsize>10</fontsize>
390 <precision>3</precision>
391 <color>
392 <r>0</r>
393 <g>0</g>
394 <b>0</b>
395 </color>
396 <bgcolor mode="nobackground">
397 <r>255</r>
398 <g>255</g>
399 <b>255</b>
400 </bgcolor>
401 <bordermode>noborder</bordermode>
402 <borderradius>1</borderradius>
403 <borderwidth>1</borderwidth>
404 </bsbObject>
405 <bsbObject version="2" type="BSBDisplay">
406 <objectName>Output_Amplitude_Scaling</objectName>
407 <x>448</x>
408 <y>214</y>
409 <width>60</width>
410 <height>30</height>
411 <uuid>{3a0c526f-9ad8-46e1-9556-6e55c4e3329d}</uuid>
412 <visible>true</visible>
413 <midichan>0</midichan>
414 <midicc>0</midicc>
415 <label>0.494</label>
416 <alignment>right</alignment>
417 <font>Arial</font>
418 <fontsize>9</fontsize>
419 <precision>3</precision>
420 <color>
421 <r>0</r>
422 <g>0</g>
423 <b>0</b>
424 </color>
425 <bgcolor mode="nobackground">
426 <r>255</r>
427 <g>255</g>
428 <b>255</b>
429 </bgcolor>
430 <bordermode>noborder</bordermode>
431 <borderradius>1</borderradius>
432 <borderwidth>1</borderwidth>
433 </bsbObject>
434 <bsbObject version="2" type="BSBHSlider">
435 <objectName>Output_Amplitude_Scaling</objectName>
436 <x>8</x>
437 <y>197</y>
438 <width>500</width>
439 <height>27</height>
440 <uuid>{cd3f39f5-b9c6-4aaf-812d-9de179dee5fb}</uuid>
441 <visible>true</visible>
442 <midichan>0</midichan>
443 <midicc>0</midicc>
444 <minimum>0.00000000</minimum>
445 <maximum>1.00000000</maximum>
446 <value>0.49400000</value>
447 <mode>lin</mode>
448 <mouseControl act="jump">continuous</mouseControl>
449 <resolution>-1.00000000</resolution>
450 <randomizable group="0">false</randomizable>
451 </bsbObject>
452 <bsbObject version="2" type="BSBLabel">
453 <objectName/>
454 <x>8</x>
455 <y>214</y>
456 <width>160</width>
457 <height>30</height>
458 <uuid>{08fb4374-a1f1-4588-85b1-6b17ef1a26a6}</uuid>
459 <visible>true</visible>
460 <midichan>0</midichan>
461 <midicc>0</midicc>
462 <label>Output Amplitude Scaling</label>
463 <alignment>left</alignment>
464 <font>Arial</font>
465 <fontsize>10</fontsize>
466 <precision>3</precision>
467 <color>
468 <r>0</r>
469 <g>0</g>
470 <b>0</b>
471 </color>
472 <bgcolor mode="nobackground">
473 <r>255</r>
474 <g>255</g>
475 <b>255</b>
476 </bgcolor>
477 <bordermode>noborder</bordermode>
478 <borderradius>1</borderradius>
479 <borderwidth>1</borderwidth>
480 </bsbObject>
481 <bsbObject version="2" type="BSBLabel">
482 <objectName/>
483 <x>8</x>
484 <y>176</y>
485 <width>180</width>
486 <height>30</height>
487 <uuid>{7a733448-2cdd-434e-8de9-1bd5bcbeae20}</uuid>
488 <visible>true</visible>
489 <midichan>0</midichan>
490 <midicc>0</midicc>
491 <label>Oscillator Frequency</label>
492 <alignment>left</alignment>
493 <font>Arial</font>
494 <fontsize>10</fontsize>
495 <precision>3</precision>
496 <color>
497 <r>0</r>
498 <g>0</g>
499 <b>0</b>
500 </color>
501 <bgcolor mode="nobackground">
502 <r>255</r>
503 <g>255</g>
504 <b>255</b>
505 </bgcolor>
506 <bordermode>noborder</bordermode>
507 <borderradius>1</borderradius>
508 <borderwidth>1</borderwidth>
509 </bsbObject>
510 <bsbObject version="2" type="BSBHSlider">
511 <objectName>Oscillator_Frequency</objectName>
512 <x>8</x>
513 <y>159</y>
514 <width>500</width>
515 <height>27</height>
516 <uuid>{8b24d990-49cf-4bb5-86d4-fa9434ed4d6c}</uuid>
517 <visible>true</visible>
518 <midichan>0</midichan>
519 <midicc>0</midicc>
520 <minimum>0.00000000</minimum>
521 <maximum>1.00000000</maximum>
522 <value>0.36400000</value>
523 <mode>lin</mode>
524 <mouseControl act="jump">continuous</mouseControl>
525 <resolution>-1.00000000</resolution>
526 <randomizable group="0">false</randomizable>
527 </bsbObject>
528 <bsbObject version="2" type="BSBDisplay">
529 <objectName>Oscillator_Frequency_Value</objectName>
530 <x>448</x>
531 <y>176</y>
532 <width>60</width>
533 <height>30</height>
534 <uuid>{0048ec26-d1cd-42a5-9e79-506d6ccfd405}</uuid>
535 <visible>true</visible>
536 <midichan>0</midichan>
537 <midicc>0</midicc>
538 <label>247.276</label>
539 <alignment>right</alignment>
540 <font>Arial</font>
541 <fontsize>9</fontsize>
542 <precision>3</precision>
543 <color>
544 <r>0</r>
545 <g>0</g>
546 <b>0</b>
547 </color>
548 <bgcolor mode="nobackground">
549 <r>255</r>
550 <g>255</g>
551 <b>255</b>
552 </bgcolor>
553 <bordermode>noborder</bordermode>
554 <borderradius>1</borderradius>
555 <borderwidth>1</borderwidth>
556 </bsbObject>
557 </bsbPanel>
558 <bsbPresets>
559 </bsbPresets>
560 <EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="true" loopStart="0" loopEnd="0"> </EventPanel>