Debian Codegraph @

src/Examples/McCurdy Collection/Miscellaneous/waveset.csd

raw
1 ;Written by Iain McCurdy, 2006
2
3 ;Modified for QuteCsound by René, February 2011
4 ;Tested on Ubuntu 10.04 with csound-float 5.13.0 and QuteCsound svn rev 817
5
6
7 ;Notes on modifications from original csd:
8 ; Add Browser for audio file and use of FilePlay2 udo, now accept mono or stereo wav files
9 ; Use reinit
10
11
12 ;my flags on Ubuntu: -dm0 -iadc -odac -+rtaudio=jack -b16 -B4096 -+rtmidi=null
13 <CsoundSynthesizer>
14 <CsOptions>
15 --env:SSDIR+=../../SourceMaterials
16 </CsOptions>
17 <CsInstruments>
18 sr = 44100 ;SAMPLE RATE
19 ksmps = 16 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
20 nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
21
22
23 opcode FilePlay2, aa, Skoo ; Credit to Joachim Heintz
24 ;gives stereo output regardless your soundfile is mono or stereo
25 Sfil, kspeed, iskip, iloop xin
26 ichn filenchnls Sfil
27 if ichn == 1 then
28 aL diskin2 Sfil, kspeed, iskip, iloop
29 aR = aL
30 else
31 aL, aR diskin2 Sfil, kspeed, iskip, iloop
32 endif
33 xout aL, aR
34 endop
35
36
37 instr 1 ;WAVESET
38 ktrig metro 10
39 if (ktrig == 1) then
40 kreset invalue "Reset"
41 krep invalue "Repeats"
42 kgain invalue "Gain"
43 kinput invalue "Input"
44
45 Sfile_new strcpy "" ;INIT TO EMPTY STRING
46 Sfile invalue "_Browse"
47 Sfile_old strcpyk Sfile_new
48 Sfile_new strcpyk Sfile
49 kfile strcmpk Sfile_new, Sfile_old
50 endif
51
52 kSwitch changed kfile, kinput, kreset ;GENERATE A MOMENTARY '1' PULSE IN OUTPUT 'kSwitch' IF ANY OF THE SCANNED INPUT VARIABLES CHANGE. (OUTPUT 'kSwitch' IS NORMALLY ZERO)
53
54 if kSwitch == 1 then ;IF I-RATE VARIABLE CHANGE TRIGGER IS '1'...
55 reinit REINIT ;BEGIN A REINITIALISATION PASS FROM LABEL 'START'
56 endif
57
58 REINIT:
59 if kinput=0 then ;CHECK STATUS OF kinput (GUI BUTTON)
60 asig, aR FilePlay2 Sfile, 1, 0, 1 ;READ IN SOUND FILE FROM DISK
61 else
62 asig, aR ins ;READ THE COMPUTER'S LIVE AUDIO INPUT
63 endif ;END OF if... BRANCHING
64
65 ;OUTPUT OPCODE INPUT | REPEATS | INPUT_DURATION (OPTIONAL)
66 ares waveset asig, krep, 5*60*sr ;PASS THE AUDIO SIGNAL THROUGH waveset OPCODE. Input duration is defined in samples.
67 ;in this example the expression given equats to a 5 minute buffer
68 outs ares * kgain, ares * kgain ;SEND waveset OUTPUT TO THE SPEAKERS
69 endin
70 </CsInstruments>
71 <CsScore>
72 f 0 3600 ;PLAYS FOR ONE HOUR
73 </CsScore>
74 </CsoundSynthesizer>
75
76
77 <bsbPanel>
78 <label>Widgets</label>
79 <objectName/>
80 <x>681</x>
81 <y>285</y>
82 <width>521</width>
83 <height>477</height>
84 <visible>true</visible>
85 <uuid/>
86 <bgcolor mode="background">
87 <r>241</r>
88 <g>226</g>
89 <b>185</b>
90 </bgcolor>
91 <bsbObject version="2" type="BSBLabel">
92 <objectName/>
93 <x>2</x>
94 <y>2</y>
95 <width>515</width>
96 <height>475</height>
97 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
98 <visible>true</visible>
99 <midichan>0</midichan>
100 <midicc>0</midicc>
101 <label>waveset</label>
102 <alignment>center</alignment>
103 <font>Liberation Sans</font>
104 <fontsize>18</fontsize>
105 <precision>3</precision>
106 <color>
107 <r>255</r>
108 <g>255</g>
109 <b>255</b>
110 </color>
111 <bgcolor mode="background">
112 <r>5</r>
113 <g>27</g>
114 <b>150</b>
115 </bgcolor>
116 <bordermode>border</bordermode>
117 <borderradius>5</borderradius>
118 <borderwidth>2</borderwidth>
119 </bsbObject>
120 <bsbObject version="2" type="BSBLabel">
121 <objectName/>
122 <x>9</x>
123 <y>227</y>
124 <width>502</width>
125 <height>248</height>
126 <uuid>{f0bc3e6c-8cfe-4b23-bf59-e0e11834e35f}</uuid>
127 <visible>true</visible>
128 <midichan>0</midichan>
129 <midicc>0</midicc>
130 <label>--------------------------------------------------------------------------------------------------------------------------
131 The opcode waveset performs timestretching by first defining the audio stream as a sequence of 'wavelets' - wavelets being a chunk of audio bounded by every 2nd zero amplitude crossing. These wavelets are then repeated a number of times as defined in this example by the 'repeats' counter. Once a wavelet has been repeated the required number of times, waveset moves onto the next wavelet and repeats the procedure.
132 Waveset obviously has to allocate memory for the proceeding audio stream whilst it is involved in repeating wavelets. The amount of memory allocated at i-time for this purpose defaults to half of p3 but it can optionally be defined explicitly as an opcode input argument. In a real-time situation predicting the memory that will be required becomes a little more difficult. In this example I have given a value of 5 minutes - I assume the user will have become bored with the example by that time.</label>
133 <alignment>left</alignment>
134 <font>Liberation Sans</font>
135 <fontsize>14</fontsize>
136 <precision>3</precision>
137 <color>
138 <r>255</r>
139 <g>255</g>
140 <b>255</b>
141 </color>
142 <bgcolor mode="nobackground">
143 <r>255</r>
144 <g>255</g>
145 <b>255</b>
146 </bgcolor>
147 <bordermode>noborder</bordermode>
148 <borderradius>1</borderradius>
149 <borderwidth>1</borderwidth>
150 </bsbObject>
151 <bsbObject version="2" type="BSBButton">
152 <objectName/>
153 <x>12</x>
154 <y>17</y>
155 <width>100</width>
156 <height>30</height>
157 <uuid>{24979132-c53f-4414-ac6b-6b4f503ecfe8}</uuid>
158 <visible>true</visible>
159 <midichan>0</midichan>
160 <midicc>0</midicc>
161 <type>event</type>
162 <pressedValue>1.00000000</pressedValue>
163 <stringvalue/>
164 <text> ON / OFF</text>
165 <image>/</image>
166 <eventLine>i 1 0 -1</eventLine>
167 <latch>true</latch>
168 <latched>false</latched>
169 </bsbObject>
170 <bsbObject version="2" type="BSBButton">
171 <objectName>_Browse</objectName>
172 <x>9</x>
173 <y>140</y>
174 <width>170</width>
175 <height>30</height>
176 <uuid>{43341095-bc3a-4607-bd0e-01254da7bc67}</uuid>
177 <visible>true</visible>
178 <midichan>0</midichan>
179 <midicc>0</midicc>
180 <type>value</type>
181 <pressedValue>1.00000000</pressedValue>
182 <stringvalue>808loopMono.wav</stringvalue>
183 <text>Browse Audio File</text>
184 <image>/</image>
185 <eventLine/>
186 <latch>false</latch>
187 <latched>false</latched>
188 </bsbObject>
189 <bsbObject version="2" type="BSBLineEdit">
190 <objectName>_Browse</objectName>
191 <x>178</x>
192 <y>141</y>
193 <width>330</width>
194 <height>28</height>
195 <uuid>{b66f3878-dfd0-4290-9b9d-73be88197222}</uuid>
196 <visible>true</visible>
197 <midichan>0</midichan>
198 <midicc>0</midicc>
199 <label>808loopMono.wav</label>
200 <alignment>left</alignment>
201 <font>Arial</font>
202 <fontsize>10</fontsize>
203 <precision>3</precision>
204 <color>
205 <r>0</r>
206 <g>0</g>
207 <b>0</b>
208 </color>
209 <bgcolor mode="nobackground">
210 <r>229</r>
211 <g>229</g>
212 <b>229</b>
213 </bgcolor>
214 <background>nobackground</background>
215 </bsbObject>
216 <bsbObject version="2" type="BSBLabel">
217 <objectName/>
218 <x>9</x>
219 <y>118</y>
220 <width>160</width>
221 <height>30</height>
222 <uuid>{7e1e7af4-88dd-4046-a781-fa2dc828b980}</uuid>
223 <visible>true</visible>
224 <midichan>0</midichan>
225 <midicc>0</midicc>
226 <label>File Input</label>
227 <alignment>left</alignment>
228 <font>Liberation Sans</font>
229 <fontsize>10</fontsize>
230 <precision>3</precision>
231 <color>
232 <r>255</r>
233 <g>255</g>
234 <b>255</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="BSBLabel">
246 <objectName/>
247 <x>9</x>
248 <y>204</y>
249 <width>120</width>
250 <height>30</height>
251 <uuid>{55b6e232-c48e-4f7d-a9c2-bb5845a86be6}</uuid>
252 <visible>true</visible>
253 <midichan>0</midichan>
254 <midicc>0</midicc>
255 <label>Output Gain</label>
256 <alignment>left</alignment>
257 <font>Liberation Sans</font>
258 <fontsize>10</fontsize>
259 <precision>3</precision>
260 <color>
261 <r>255</r>
262 <g>255</g>
263 <b>255</b>
264 </color>
265 <bgcolor mode="nobackground">
266 <r>255</r>
267 <g>255</g>
268 <b>255</b>
269 </bgcolor>
270 <bordermode>noborder</bordermode>
271 <borderradius>1</borderradius>
272 <borderwidth>1</borderwidth>
273 </bsbObject>
274 <bsbObject version="2" type="BSBDisplay">
275 <objectName>Gain</objectName>
276 <x>449</x>
277 <y>204</y>
278 <width>60</width>
279 <height>30</height>
280 <uuid>{8af638cf-01fd-481b-a760-f46fa98f7a33}</uuid>
281 <visible>true</visible>
282 <midichan>0</midichan>
283 <midicc>0</midicc>
284 <label>0.556</label>
285 <alignment>right</alignment>
286 <font>Liberation Sans</font>
287 <fontsize>9</fontsize>
288 <precision>3</precision>
289 <color>
290 <r>255</r>
291 <g>255</g>
292 <b>255</b>
293 </color>
294 <bgcolor mode="nobackground">
295 <r>255</r>
296 <g>255</g>
297 <b>255</b>
298 </bgcolor>
299 <bordermode>noborder</bordermode>
300 <borderradius>1</borderradius>
301 <borderwidth>1</borderwidth>
302 </bsbObject>
303 <bsbObject version="2" type="BSBHSlider">
304 <objectName>Gain</objectName>
305 <x>9</x>
306 <y>187</y>
307 <width>500</width>
308 <height>27</height>
309 <uuid>{cd0d0266-1e5e-4e06-a2fa-65c41c86ba54}</uuid>
310 <visible>true</visible>
311 <midichan>0</midichan>
312 <midicc>0</midicc>
313 <minimum>0.00000000</minimum>
314 <maximum>2.00000000</maximum>
315 <value>0.55600000</value>
316 <mode>lin</mode>
317 <mouseControl act="jump">continuous</mouseControl>
318 <resolution>-1.00000000</resolution>
319 <randomizable group="0">false</randomizable>
320 </bsbObject>
321 <bsbObject version="2" type="BSBButton">
322 <objectName>Reset</objectName>
323 <x>275</x>
324 <y>75</y>
325 <width>100</width>
326 <height>30</height>
327 <uuid>{2e9eedf9-d2af-4854-8070-0fa69cfc304b}</uuid>
328 <visible>true</visible>
329 <midichan>0</midichan>
330 <midicc>0</midicc>
331 <type>value</type>
332 <pressedValue>1.00000000</pressedValue>
333 <stringvalue/>
334 <text>Reset Buffer</text>
335 <image>/</image>
336 <eventLine/>
337 <latch>false</latch>
338 <latched>false</latched>
339 </bsbObject>
340 <bsbObject version="2" type="BSBLabel">
341 <objectName/>
342 <x>366</x>
343 <y>79</y>
344 <width>80</width>
345 <height>30</height>
346 <uuid>{46a90d04-2a9c-44c8-8226-f59029a93d85}</uuid>
347 <visible>true</visible>
348 <midichan>0</midichan>
349 <midicc>0</midicc>
350 <label>Repeats</label>
351 <alignment>right</alignment>
352 <font>Liberation Sans</font>
353 <fontsize>10</fontsize>
354 <precision>3</precision>
355 <color>
356 <r>255</r>
357 <g>255</g>
358 <b>255</b>
359 </color>
360 <bgcolor mode="nobackground">
361 <r>255</r>
362 <g>255</g>
363 <b>255</b>
364 </bgcolor>
365 <bordermode>noborder</bordermode>
366 <borderradius>1</borderradius>
367 <borderwidth>1</borderwidth>
368 </bsbObject>
369 <bsbObject version="2" type="BSBSpinBox">
370 <objectName>Repeats</objectName>
371 <x>447</x>
372 <y>75</y>
373 <width>60</width>
374 <height>30</height>
375 <uuid>{4146a063-10a5-4b33-81c4-480f7cc672f9}</uuid>
376 <visible>true</visible>
377 <midichan>0</midichan>
378 <midicc>0</midicc>
379 <alignment>center</alignment>
380 <font>Liberation Sans</font>
381 <fontsize>12</fontsize>
382 <color>
383 <r>0</r>
384 <g>0</g>
385 <b>0</b>
386 </color>
387 <bgcolor mode="nobackground">
388 <r>255</r>
389 <g>255</g>
390 <b>255</b>
391 </bgcolor>
392 <resolution>1.00000000</resolution>
393 <minimum>1</minimum>
394 <maximum>1000</maximum>
395 <randomizable group="0">false</randomizable>
396 <value>1</value>
397 </bsbObject>
398 <bsbObject version="2" type="BSBDropdown">
399 <objectName>Input</objectName>
400 <x>98</x>
401 <y>75</y>
402 <width>105</width>
403 <height>30</height>
404 <uuid>{147e2dad-491b-4b04-9916-19a59215c6ba}</uuid>
405 <visible>true</visible>
406 <midichan>0</midichan>
407 <midicc>0</midicc>
408 <bsbDropdownItemList>
409 <bsbDropdownItem>
410 <name>Audio File</name>
411 <value>0</value>
412 <stringvalue/>
413 </bsbDropdownItem>
414 <bsbDropdownItem>
415 <name>Live Input</name>
416 <value>1</value>
417 <stringvalue/>
418 </bsbDropdownItem>
419 </bsbDropdownItemList>
420 <selectedIndex>0</selectedIndex>
421 <randomizable group="0">false</randomizable>
422 </bsbObject>
423 <bsbObject version="2" type="BSBLabel">
424 <objectName/>
425 <x>17</x>
426 <y>78</y>
427 <width>80</width>
428 <height>30</height>
429 <uuid>{a7e531bc-3959-4d58-9a6a-4b4b96852cef}</uuid>
430 <visible>true</visible>
431 <midichan>0</midichan>
432 <midicc>0</midicc>
433 <label>Input</label>
434 <alignment>right</alignment>
435 <font>Liberation Sans</font>
436 <fontsize>10</fontsize>
437 <precision>3</precision>
438 <color>
439 <r>255</r>
440 <g>255</g>
441 <b>255</b>
442 </color>
443 <bgcolor mode="nobackground">
444 <r>255</r>
445 <g>255</g>
446 <b>255</b>
447 </bgcolor>
448 <bordermode>noborder</bordermode>
449 <borderradius>1</borderradius>
450 <borderwidth>1</borderwidth>
451 </bsbObject>
452 </bsbPanel>
453 <bsbPresets>
454 </bsbPresets>
455 <EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="true" loopStart="0" loopEnd="0"> </EventPanel>