Debian Codegraph @

src/Examples/McCurdy Collection/Filters/tonex.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 giExp20000 ftgen 0, 0, 129, -25, 0, 20.0, 128, 20000.0 ;TABLE FOR EXP SLIDER
23
24
25 opcode FilePlay2, aa, Skoo ; Credit to Joachim Heintz
26 ;gives stereo output regardless your soundfile is mono or stereo
27 Sfil, kspeed, iskip, iloop xin
28 ichn filenchnls Sfil
29 if ichn == 1 then
30 aL diskin2 Sfil, kspeed, iskip, iloop
31 aR = aL
32 else
33 aL, aR diskin2 Sfil, kspeed, iskip, iloop
34 endif
35 xout aL, aR
36 endop
37
38
39 instr 1 ;GUI
40 ktrig metro 10
41 if (ktrig == 1) then
42
43 Sfile_new strcpy "" ;INIT TO EMPTY STRING
44
45 kfco invalue "Filter_Cutoff"
46 gkfco tablei kfco, giExp20000, 1
47 outvalue "Filter_Cutoff_Value", gkfco
48 gkgain invalue "Amplitude"
49
50 gknumlayer invalue "Layers"
51 gkskip invalue "Initialisation"
52
53 gSfile invalue "_Browse"
54 Sfile_old strcpyk Sfile_new
55 Sfile_new strcpyk gSfile
56 gkfile strcmpk Sfile_new, Sfile_old
57 endif
58 endin
59
60 instr 2
61 kporttime linseg 0,0.001,0.005,1,0.005 ;CREATE A VARIABLE FUNCTION THAT RAPIDLY RAMPS UP TO A SET VALUE
62 kfco portk gkfco, kporttime ;SMOOTH MOVEMENT OF SLIDER VARIABLE
63
64 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)
65 if kNew_file=1 then ;IF I-RATE VARIABLE CHANGE TRIGGER IS '1'...
66 reinit NEW_FILE ;BEGIN A REINITIALISATION PASS FROM LABEL 'START'
67 endif
68 NEW_FILE:
69 ;OUTPUTS OPCODE FILE | SPEED | INSKIP | LOOPING (0=OFF 1=ON)
70 asigL, asigR FilePlay2 gSfile, 1, 0, 1 ;GENERATE 2 AUDIO SIGNALS FROM A STEREO SOUND FILE
71 rireturn ;RETURN FROM REINITIALISATION PASS TO PERFORMANCE TIME PASSES
72
73 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)
74 if kSwitch=1 then ;IF I-RATE VARIABLE CHANGE TRIGGER IS '1'...
75 reinit START ;BEGIN A REINITIALISATION PASS FROM LABEL 'START'
76 endif
77 START:
78 aresL tonex asigL, kfco , i(gknumlayer), i(gkskip) ;FILTER BOTH CHANNELS SEPARATELY
79 aresR tonex asigR, kfco , i(gknumlayer), i(gkskip) ;FILTER BOTH CHANNELS SEPARATELY
80 rireturn ;RETURN FROM REINITIALISATION PASS TO PERFORMANCE TIME PASSES
81 outs aresL * gkgain, aresR * gkgain ;SEND FILTER OUTPUT TO THE AUDIO OUTPUTS, RESCALE USING SLIDER VARIABLE gkgain
82 endin
83 </CsInstruments>
84 <CsScore>
85 ;INSTR | START | DURATION
86 i 1 0 3600 ;GUI
87 </CsScore>
88 </CsoundSynthesizer>
89
90
91
92 <bsbPanel>
93 <label>Widgets</label>
94 <objectName/>
95 <x>428</x>
96 <y>316</y>
97 <width>937</width>
98 <height>193</height>
99 <visible>true</visible>
100 <uuid/>
101 <bgcolor mode="background">
102 <r>241</r>
103 <g>226</g>
104 <b>185</b>
105 </bgcolor>
106 <bsbObject version="2" type="BSBLabel">
107 <objectName/>
108 <x>2</x>
109 <y>2</y>
110 <width>512</width>
111 <height>190</height>
112 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
113 <visible>true</visible>
114 <midichan>0</midichan>
115 <midicc>0</midicc>
116 <label>tonex</label>
117 <alignment>center</alignment>
118 <font>Liberation Sans</font>
119 <fontsize>18</fontsize>
120 <precision>3</precision>
121 <color>
122 <r>0</r>
123 <g>0</g>
124 <b>0</b>
125 </color>
126 <bgcolor mode="background">
127 <r>106</r>
128 <g>117</g>
129 <b>150</b>
130 </bgcolor>
131 <bordermode>border</bordermode>
132 <borderradius>5</borderradius>
133 <borderwidth>2</borderwidth>
134 </bsbObject>
135 <bsbObject version="2" type="BSBLabel">
136 <objectName/>
137 <x>515</x>
138 <y>2</y>
139 <width>418</width>
140 <height>190</height>
141 <uuid>{74928ed2-b701-4668-9a11-74763d317e9b}</uuid>
142 <visible>true</visible>
143 <midichan>0</midichan>
144 <midicc>0</midicc>
145 <label>tonex</label>
146 <alignment>center</alignment>
147 <font>Liberation Sans</font>
148 <fontsize>18</fontsize>
149 <precision>3</precision>
150 <color>
151 <r>0</r>
152 <g>0</g>
153 <b>0</b>
154 </color>
155 <bgcolor mode="background">
156 <r>106</r>
157 <g>117</g>
158 <b>150</b>
159 </bgcolor>
160 <bordermode>border</bordermode>
161 <borderradius>5</borderradius>
162 <borderwidth>2</borderwidth>
163 </bsbObject>
164 <bsbObject version="2" type="BSBLabel">
165 <objectName/>
166 <x>519</x>
167 <y>19</y>
168 <width>414</width>
169 <height>173</height>
170 <uuid>{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}</uuid>
171 <visible>true</visible>
172 <midichan>0</midichan>
173 <midicc>0</midicc>
174 <label>----------------------------------------------------------------------------------------------------
175 tonex is an implementation of a second-order low-pass filter. Its input arguments are for cutoff frequency (half-power point) and a counter selecting the number of series iterations of the low-pass filter it implements. The effect of this is the same as the effect of multiple serially connected tone filters. However, use of the tonex opcode will be computationally much more efficient.</label>
176 <alignment>left</alignment>
177 <font>Arial</font>
178 <fontsize>14</fontsize>
179 <precision>3</precision>
180 <color>
181 <r>0</r>
182 <g>0</g>
183 <b>0</b>
184 </color>
185 <bgcolor mode="nobackground">
186 <r>255</r>
187 <g>255</g>
188 <b>255</b>
189 </bgcolor>
190 <bordermode>noborder</bordermode>
191 <borderradius>1</borderradius>
192 <borderwidth>1</borderwidth>
193 </bsbObject>
194 <bsbObject version="2" type="BSBButton">
195 <objectName/>
196 <x>8</x>
197 <y>6</y>
198 <width>100</width>
199 <height>30</height>
200 <uuid>{24979132-c53f-4414-ac6b-6b4f503ecfe8}</uuid>
201 <visible>true</visible>
202 <midichan>0</midichan>
203 <midicc>0</midicc>
204 <type>event</type>
205 <pressedValue>1.00000000</pressedValue>
206 <stringvalue/>
207 <text> ON / OFF</text>
208 <image>/</image>
209 <eventLine>i 2 0 -1</eventLine>
210 <latch>true</latch>
211 <latched>false</latched>
212 </bsbObject>
213 <bsbObject version="2" type="BSBDisplay">
214 <objectName>Filter_Cutoff_Value</objectName>
215 <x>448</x>
216 <y>63</y>
217 <width>60</width>
218 <height>30</height>
219 <uuid>{745d6bee-b951-4a03-9fe8-9e10d5ae4556}</uuid>
220 <visible>true</visible>
221 <midichan>0</midichan>
222 <midicc>0</midicc>
223 <label>845.628</label>
224 <alignment>right</alignment>
225 <font>Arial</font>
226 <fontsize>9</fontsize>
227 <precision>3</precision>
228 <color>
229 <r>0</r>
230 <g>0</g>
231 <b>0</b>
232 </color>
233 <bgcolor mode="nobackground">
234 <r>255</r>
235 <g>255</g>
236 <b>255</b>
237 </bgcolor>
238 <bordermode>noborder</bordermode>
239 <borderradius>1</borderradius>
240 <borderwidth>1</borderwidth>
241 </bsbObject>
242 <bsbObject version="2" type="BSBHSlider">
243 <objectName>Filter_Cutoff</objectName>
244 <x>8</x>
245 <y>46</y>
246 <width>500</width>
247 <height>27</height>
248 <uuid>{06814721-6151-4baa-84e2-8f39843b07a4}</uuid>
249 <visible>true</visible>
250 <midichan>0</midichan>
251 <midicc>0</midicc>
252 <minimum>0.00000000</minimum>
253 <maximum>1.00000000</maximum>
254 <value>0.54200000</value>
255 <mode>lin</mode>
256 <mouseControl act="jump">continuous</mouseControl>
257 <resolution>-1.00000000</resolution>
258 <randomizable group="0">false</randomizable>
259 </bsbObject>
260 <bsbObject version="2" type="BSBLabel">
261 <objectName/>
262 <x>8</x>
263 <y>63</y>
264 <width>180</width>
265 <height>30</height>
266 <uuid>{c6d7165c-6730-426f-b293-52b411bc73cf}</uuid>
267 <visible>true</visible>
268 <midichan>0</midichan>
269 <midicc>0</midicc>
270 <label>Filter Cutoff</label>
271 <alignment>left</alignment>
272 <font>Arial</font>
273 <fontsize>10</fontsize>
274 <precision>3</precision>
275 <color>
276 <r>0</r>
277 <g>0</g>
278 <b>0</b>
279 </color>
280 <bgcolor mode="nobackground">
281 <r>255</r>
282 <g>255</g>
283 <b>255</b>
284 </bgcolor>
285 <bordermode>noborder</bordermode>
286 <borderradius>1</borderradius>
287 <borderwidth>1</borderwidth>
288 </bsbObject>
289 <bsbObject version="2" type="BSBHSlider">
290 <objectName>Amplitude</objectName>
291 <x>8</x>
292 <y>84</y>
293 <width>500</width>
294 <height>27</height>
295 <uuid>{42fe25e5-e98f-4f00-872c-f791822a1b3e}</uuid>
296 <visible>true</visible>
297 <midichan>0</midichan>
298 <midicc>0</midicc>
299 <minimum>0.00000000</minimum>
300 <maximum>2.00000000</maximum>
301 <value>0.58400000</value>
302 <mode>lin</mode>
303 <mouseControl act="jump">continuous</mouseControl>
304 <resolution>-1.00000000</resolution>
305 <randomizable group="0">false</randomizable>
306 </bsbObject>
307 <bsbObject version="2" type="BSBDisplay">
308 <objectName>Amplitude</objectName>
309 <x>448</x>
310 <y>101</y>
311 <width>60</width>
312 <height>30</height>
313 <uuid>{a8f35453-f236-447d-88d9-1a0b135383b6}</uuid>
314 <visible>true</visible>
315 <midichan>0</midichan>
316 <midicc>0</midicc>
317 <label>0.584</label>
318 <alignment>right</alignment>
319 <font>Arial</font>
320 <fontsize>9</fontsize>
321 <precision>3</precision>
322 <color>
323 <r>0</r>
324 <g>0</g>
325 <b>0</b>
326 </color>
327 <bgcolor mode="nobackground">
328 <r>255</r>
329 <g>255</g>
330 <b>255</b>
331 </bgcolor>
332 <bordermode>noborder</bordermode>
333 <borderradius>1</borderradius>
334 <borderwidth>1</borderwidth>
335 </bsbObject>
336 <bsbObject version="2" type="BSBButton">
337 <objectName>Initialisation</objectName>
338 <x>380</x>
339 <y>6</y>
340 <width>130</width>
341 <height>30</height>
342 <uuid>{88395e38-ecab-4818-bef3-1a18b504f914}</uuid>
343 <visible>true</visible>
344 <midichan>0</midichan>
345 <midicc>0</midicc>
346 <type>value</type>
347 <pressedValue>1.00000000</pressedValue>
348 <stringvalue/>
349 <text> No Initialisation</text>
350 <image>/</image>
351 <eventLine/>
352 <latch>true</latch>
353 <latched>false</latched>
354 </bsbObject>
355 <bsbObject version="2" type="BSBButton">
356 <objectName>_Browse</objectName>
357 <x>8</x>
358 <y>153</y>
359 <width>170</width>
360 <height>30</height>
361 <uuid>{43341095-bc3a-4607-bd0e-01254da7bc67}</uuid>
362 <visible>true</visible>
363 <midichan>0</midichan>
364 <midicc>0</midicc>
365 <type>value</type>
366 <pressedValue>1.00000000</pressedValue>
367 <stringvalue>Seashore.wav</stringvalue>
368 <text>Browse Audio File</text>
369 <image>/</image>
370 <eventLine/>
371 <latch>false</latch>
372 <latched>false</latched>
373 </bsbObject>
374 <bsbObject version="2" type="BSBLineEdit">
375 <objectName>_Browse</objectName>
376 <x>177</x>
377 <y>154</y>
378 <width>330</width>
379 <height>28</height>
380 <uuid>{b66f3878-dfd0-4290-9b9d-73be88197222}</uuid>
381 <visible>true</visible>
382 <midichan>0</midichan>
383 <midicc>0</midicc>
384 <label>Seashore.wav</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>229</r>
396 <g>229</g>
397 <b>229</b>
398 </bgcolor>
399 <background>nobackground</background>
400 </bsbObject>
401 <bsbObject version="2" type="BSBLabel">
402 <objectName/>
403 <x>8</x>
404 <y>131</y>
405 <width>160</width>
406 <height>30</height>
407 <uuid>{7e1e7af4-88dd-4046-a781-fa2dc828b980}</uuid>
408 <visible>true</visible>
409 <midichan>0</midichan>
410 <midicc>0</midicc>
411 <label>File Input</label>
412 <alignment>left</alignment>
413 <font>Arial</font>
414 <fontsize>10</fontsize>
415 <precision>3</precision>
416 <color>
417 <r>0</r>
418 <g>0</g>
419 <b>0</b>
420 </color>
421 <bgcolor mode="nobackground">
422 <r>255</r>
423 <g>255</g>
424 <b>255</b>
425 </bgcolor>
426 <bordermode>noborder</bordermode>
427 <borderradius>1</borderradius>
428 <borderwidth>1</borderwidth>
429 </bsbObject>
430 <bsbObject version="2" type="BSBLabel">
431 <objectName/>
432 <x>8</x>
433 <y>101</y>
434 <width>180</width>
435 <height>30</height>
436 <uuid>{027163fb-bbfe-488e-9351-1c1cd9a9d626}</uuid>
437 <visible>true</visible>
438 <midichan>0</midichan>
439 <midicc>0</midicc>
440 <label>Output Amplitude Scaling</label>
441 <alignment>left</alignment>
442 <font>Arial</font>
443 <fontsize>10</fontsize>
444 <precision>3</precision>
445 <color>
446 <r>0</r>
447 <g>0</g>
448 <b>0</b>
449 </color>
450 <bgcolor mode="nobackground">
451 <r>255</r>
452 <g>255</g>
453 <b>255</b>
454 </bgcolor>
455 <bordermode>noborder</bordermode>
456 <borderradius>1</borderradius>
457 <borderwidth>1</borderwidth>
458 </bsbObject>
459 <bsbObject version="2" type="BSBSpinBox">
460 <objectName>Layers</objectName>
461 <x>452</x>
462 <y>121</y>
463 <width>55</width>
464 <height>28</height>
465 <uuid>{67d31697-f639-4f22-8bb2-0c487a2d6bc9}</uuid>
466 <visible>true</visible>
467 <midichan>0</midichan>
468 <midicc>0</midicc>
469 <alignment>left</alignment>
470 <font>Arial</font>
471 <fontsize>14</fontsize>
472 <color>
473 <r>0</r>
474 <g>0</g>
475 <b>0</b>
476 </color>
477 <bgcolor mode="nobackground">
478 <r>255</r>
479 <g>255</g>
480 <b>255</b>
481 </bgcolor>
482 <resolution>1.00000000</resolution>
483 <minimum>1</minimum>
484 <maximum>500</maximum>
485 <randomizable group="0">false</randomizable>
486 <value>1</value>
487 </bsbObject>
488 <bsbObject version="2" type="BSBLabel">
489 <objectName/>
490 <x>332</x>
491 <y>120</y>
492 <width>120</width>
493 <height>30</height>
494 <uuid>{96faebf3-f79f-45ef-b54d-a1fc14b35497}</uuid>
495 <visible>true</visible>
496 <midichan>0</midichan>
497 <midicc>0</midicc>
498 <label>Number of Layers</label>
499 <alignment>right</alignment>
500 <font>Arial</font>
501 <fontsize>10</fontsize>
502 <precision>3</precision>
503 <color>
504 <r>0</r>
505 <g>0</g>
506 <b>0</b>
507 </color>
508 <bgcolor mode="nobackground">
509 <r>255</r>
510 <g>255</g>
511 <b>255</b>
512 </bgcolor>
513 <bordermode>noborder</bordermode>
514 <borderradius>1</borderradius>
515 <borderwidth>1</borderwidth>
516 </bsbObject>
517 </bsbPanel>
518 <bsbPresets>
519 </bsbPresets>
520 <EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="false" loopStart="0" loopEnd="0"> </EventPanel>