1;Written by Iain McCurdy
2
3;Modified for QuteCsound by René, September 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>
17sr 		= 44100	;SAMPLE RATE
18ksmps 	= 1		;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
19nchnls 	= 2		;NUMBER OF CHANNELS (2=STEREO)
200dbfs	= 1		;MAXIMUM SOUND INTENSITY LEVEL REGARDLESS OF BIT DEPTH
21
22
23;TABLE FOR EXP SLIDER
24giExp1024		ftgen	0, 0, 129, -25, 0, 1.0, 128, 1024.0
25
26
27opcode FilePlay2, aa, Skoo		; Credit to Joachim Heintz
28	;gives stereo output regardless your soundfile is mono or stereo
29	Sfil, kspeed, iskip, iloop	xin
30	ichn		filenchnls	Sfil
31	if ichn == 1 then
32		aL		diskin2	Sfil, kspeed, iskip, iloop
33		aR		=		aL
34	else
35		aL, aR	diskin2	Sfil, kspeed, iskip, iloop
36	endif
37		xout		aL, aR
38endop
39
40
41instr	1	;GUI
42	ktrig	metro	10
43	if (ktrig == 1)	then
44		kincr	invalue	"Foldover"
45		gkincr	tablei	kincr, giExp1024, 1
46				outvalue	"Foldover_Value", gkincr		;init 1.0
47		gkgain	invalue 	"Output_Gain"				;init 1.0
48		gkinput	invalue	"Input"
49	endif
50endin
51
52instr 2
53	if	gkinput=0	then										;CHECK STATUS OF gkinput
54		Sfile1	invalue	"_Browse1"
55		asig, asigR	FilePlay2	Sfile1, 1, 0, 1				;READ IN SOUND FILE FROM DISK
56	elseif		gkinput=1	then								;CHECK STATUS OF gkinput
57		Sfile2	invalue	"_Browse2"
58		asig, asigR	FilePlay2	Sfile2, 1, 0, 1				;READ IN SOUND FILE FROM DISK
59	elseif		gkinput=2	then								;CHECK STATUS OF gkinput
60		asig		inch		1								;READ THE COMPUTER'S LIVE AUDIO INPUT
61	endif												;END OF if... BRANCHING
62	afold 	fold 	asig, gkincr							;APPLY SAMPLING RATE FOLDOVER
63			outs		afold * gkgain, afold * gkgain			;SEND AUDIO TO OUTPUTS AND RESCALE USING gkgain SLIDER VARIABLE
64endin
65</CsInstruments>
66<CsScore>
67;INSTR | START | DURATION
68i 1		0	   3600	;GUI
69</CsScore>
70</CsoundSynthesizer>
71
72
73<bsbPanel>
74 <label>Widgets</label>
75 <objectName/>
76 <x>569</x>
77 <y>470</y>
78 <width>777</width>
79 <height>292</height>
80 <visible>true</visible>
81 <uuid/>
82 <bgcolor mode="background">
83  <r>241</r>
84  <g>226</g>
85  <b>185</b>
86 </bgcolor>
87 <bsbObject version="2" type="BSBLabel">
88  <objectName/>
89  <x>2</x>
90  <y>2</y>
91  <width>514</width>
92  <height>290</height>
93  <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
94  <visible>true</visible>
95  <midichan>0</midichan>
96  <midicc>0</midicc>
97  <label>Fold</label>
98  <alignment>center</alignment>
99  <font>Liberation Sans</font>
100  <fontsize>18</fontsize>
101  <precision>3</precision>
102  <color>
103   <r>0</r>
104   <g>0</g>
105   <b>0</b>
106  </color>
107  <bgcolor mode="background">
108   <r>158</r>
109   <g>220</g>
110   <b>158</b>
111  </bgcolor>
112  <bordermode>border</bordermode>
113  <borderradius>5</borderradius>
114  <borderwidth>2</borderwidth>
115 </bsbObject>
116 <bsbObject version="2" type="BSBHSlider">
117  <objectName>Foldover</objectName>
118  <x>8</x>
119  <y>47</y>
120  <width>500</width>
121  <height>27</height>
122  <uuid>{de47f47d-bcea-4c1c-ab4b-a323452b1f7e}</uuid>
123  <visible>true</visible>
124  <midichan>0</midichan>
125  <midicc>0</midicc>
126  <minimum>0.00000000</minimum>
127  <maximum>1.00000000</maximum>
128  <value>0.24000000</value>
129  <mode>lin</mode>
130  <mouseControl act="jump">continuous</mouseControl>
131  <resolution>-1.00000000</resolution>
132  <randomizable group="0">false</randomizable>
133 </bsbObject>
134 <bsbObject version="2" type="BSBLabel">
135  <objectName/>
136  <x>8</x>
137  <y>64</y>
138  <width>120</width>
139  <height>30</height>
140  <uuid>{0200a063-5db8-4668-bc2d-2d989a083f6e}</uuid>
141  <visible>true</visible>
142  <midichan>0</midichan>
143  <midicc>0</midicc>
144  <label>Foldover</label>
145  <alignment>left</alignment>
146  <font>Arial</font>
147  <fontsize>10</fontsize>
148  <precision>3</precision>
149  <color>
150   <r>0</r>
151   <g>0</g>
152   <b>0</b>
153  </color>
154  <bgcolor mode="nobackground">
155   <r>255</r>
156   <g>255</g>
157   <b>255</b>
158  </bgcolor>
159  <bordermode>noborder</bordermode>
160  <borderradius>1</borderradius>
161  <borderwidth>1</borderwidth>
162 </bsbObject>
163 <bsbObject version="2" type="BSBDisplay">
164  <objectName>Foldover_Value</objectName>
165  <x>448</x>
166  <y>64</y>
167  <width>60</width>
168  <height>30</height>
169  <uuid>{ab191e3a-430d-4f1d-88aa-9840342cd2d3}</uuid>
170  <visible>true</visible>
171  <midichan>0</midichan>
172  <midicc>0</midicc>
173  <label>5.280</label>
174  <alignment>right</alignment>
175  <font>Arial</font>
176  <fontsize>9</fontsize>
177  <precision>3</precision>
178  <color>
179   <r>0</r>
180   <g>0</g>
181   <b>0</b>
182  </color>
183  <bgcolor mode="nobackground">
184   <r>255</r>
185   <g>255</g>
186   <b>255</b>
187  </bgcolor>
188  <bordermode>noborder</bordermode>
189  <borderradius>1</borderradius>
190  <borderwidth>1</borderwidth>
191 </bsbObject>
192 <bsbObject version="2" type="BSBLabel">
193  <objectName/>
194  <x>518</x>
195  <y>2</y>
196  <width>259</width>
197  <height>290</height>
198  <uuid>{74928ed2-b701-4668-9a11-74763d317e9b}</uuid>
199  <visible>true</visible>
200  <midichan>0</midichan>
201  <midicc>0</midicc>
202  <label>Fold</label>
203  <alignment>center</alignment>
204  <font>Liberation Sans</font>
205  <fontsize>18</fontsize>
206  <precision>3</precision>
207  <color>
208   <r>0</r>
209   <g>0</g>
210   <b>0</b>
211  </color>
212  <bgcolor mode="background">
213   <r>158</r>
214   <g>220</g>
215   <b>158</b>
216  </bgcolor>
217  <bordermode>border</bordermode>
218  <borderradius>5</borderradius>
219  <borderwidth>2</borderwidth>
220 </bsbObject>
221 <bsbObject version="2" type="BSBLabel">
222  <objectName/>
223  <x>521</x>
224  <y>19</y>
225  <width>254</width>
226  <height>256</height>
227  <uuid>{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}</uuid>
228  <visible>true</visible>
229  <midichan>0</midichan>
230  <midicc>0</midicc>
231  <label>------------------------------------------------------------
232The opcode 'fold' adds artificial foldover to an audio signal. This gives the effect of downsampling the audio signal to a lower sampling rate. Without interpolating between audio samples this produces a distinctive degrading of of the signal.
233The amount of foldover is expressed as a multiple of the sampling rate therefore a value of 1 will produce no foldover, avalue of 2 will produce the effect of downsampling to 22050Hz (from 44100), a value of 4 will produce the effect of downsampling to 11025 and so on.</label>
234  <alignment>left</alignment>
235  <font>Liberation Sans</font>
236  <fontsize>14</fontsize>
237  <precision>3</precision>
238  <color>
239   <r>0</r>
240   <g>0</g>
241   <b>0</b>
242  </color>
243  <bgcolor mode="nobackground">
244   <r>255</r>
245   <g>255</g>
246   <b>255</b>
247  </bgcolor>
248  <bordermode>noborder</bordermode>
249  <borderradius>1</borderradius>
250  <borderwidth>1</borderwidth>
251 </bsbObject>
252 <bsbObject version="2" type="BSBLabel">
253  <objectName/>
254  <x>8</x>
255  <y>106</y>
256  <width>120</width>
257  <height>30</height>
258  <uuid>{6d8d92f5-813d-4e91-867e-f3384b0baf9d}</uuid>
259  <visible>true</visible>
260  <midichan>0</midichan>
261  <midicc>0</midicc>
262  <label>Output Gain</label>
263  <alignment>left</alignment>
264  <font>Arial</font>
265  <fontsize>10</fontsize>
266  <precision>3</precision>
267  <color>
268   <r>0</r>
269   <g>0</g>
270   <b>0</b>
271  </color>
272  <bgcolor mode="nobackground">
273   <r>255</r>
274   <g>255</g>
275   <b>255</b>
276  </bgcolor>
277  <bordermode>noborder</bordermode>
278  <borderradius>1</borderradius>
279  <borderwidth>1</borderwidth>
280 </bsbObject>
281 <bsbObject version="2" type="BSBHSlider">
282  <objectName>Output_Gain</objectName>
283  <x>8</x>
284  <y>87</y>
285  <width>500</width>
286  <height>27</height>
287  <uuid>{8fbaf396-5ad3-4de9-b5fe-cf9991b23868}</uuid>
288  <visible>true</visible>
289  <midichan>0</midichan>
290  <midicc>0</midicc>
291  <minimum>0.00000000</minimum>
292  <maximum>2.00000000</maximum>
293  <value>0.62000000</value>
294  <mode>lin</mode>
295  <mouseControl act="jump">continuous</mouseControl>
296  <resolution>-1.00000000</resolution>
297  <randomizable group="0">false</randomizable>
298 </bsbObject>
299 <bsbObject version="2" type="BSBDisplay">
300  <objectName>Output_Gain</objectName>
301  <x>448</x>
302  <y>104</y>
303  <width>60</width>
304  <height>30</height>
305  <uuid>{0a5ba1c3-3448-4200-9a48-c116a64fc284}</uuid>
306  <visible>true</visible>
307  <midichan>0</midichan>
308  <midicc>0</midicc>
309  <label>0.620</label>
310  <alignment>right</alignment>
311  <font>Arial</font>
312  <fontsize>9</fontsize>
313  <precision>3</precision>
314  <color>
315   <r>0</r>
316   <g>0</g>
317   <b>0</b>
318  </color>
319  <bgcolor mode="nobackground">
320   <r>255</r>
321   <g>255</g>
322   <b>255</b>
323  </bgcolor>
324  <bordermode>noborder</bordermode>
325  <borderradius>1</borderradius>
326  <borderwidth>1</borderwidth>
327 </bsbObject>
328 <bsbObject version="2" type="BSBButton">
329  <objectName/>
330  <x>8</x>
331  <y>8</y>
332  <width>100</width>
333  <height>29</height>
334  <uuid>{24979132-c53f-4414-ac6b-6b4f503ecfe8}</uuid>
335  <visible>true</visible>
336  <midichan>0</midichan>
337  <midicc>0</midicc>
338  <type>event</type>
339  <pressedValue>1.00000000</pressedValue>
340  <stringvalue/>
341  <text>   On / Off</text>
342  <image>/</image>
343  <eventLine>i 2 0 -1</eventLine>
344  <latch>true</latch>
345  <latched>false</latched>
346 </bsbObject>
347 <bsbObject version="2" type="BSBDropdown">
348  <objectName>Input</objectName>
349  <x>231</x>
350  <y>131</y>
351  <width>100</width>
352  <height>30</height>
353  <uuid>{97bfdd5d-a6c2-4606-83c9-22dfe1c9f751}</uuid>
354  <visible>true</visible>
355  <midichan>0</midichan>
356  <midicc>0</midicc>
357  <bsbDropdownItemList>
358   <bsbDropdownItem>
359    <name>Voice</name>
360    <value>0</value>
361    <stringvalue/>
362   </bsbDropdownItem>
363   <bsbDropdownItem>
364    <name>Drums</name>
365    <value>1</value>
366    <stringvalue/>
367   </bsbDropdownItem>
368   <bsbDropdownItem>
369    <name>Live Input</name>
370    <value>2</value>
371    <stringvalue/>
372   </bsbDropdownItem>
373  </bsbDropdownItemList>
374  <selectedIndex>1</selectedIndex>
375  <randomizable group="0">false</randomizable>
376 </bsbObject>
377 <bsbObject version="2" type="BSBLabel">
378  <objectName/>
379  <x>170</x>
380  <y>131</y>
381  <width>60</width>
382  <height>30</height>
383  <uuid>{1ee229f8-de85-4323-a7dc-c390e0bbce97}</uuid>
384  <visible>true</visible>
385  <midichan>0</midichan>
386  <midicc>0</midicc>
387  <label>Input</label>
388  <alignment>right</alignment>
389  <font>Arial</font>
390  <fontsize>10</fontsize>
391  <precision>3</precision>
392  <color>
393   <r>0</r>
394   <g>0</g>
395   <b>0</b>
396  </color>
397  <bgcolor mode="nobackground">
398   <r>255</r>
399   <g>255</g>
400   <b>255</b>
401  </bgcolor>
402  <bordermode>noborder</bordermode>
403  <borderradius>1</borderradius>
404  <borderwidth>1</borderwidth>
405 </bsbObject>
406 <bsbObject version="2" type="BSBButton">
407  <objectName>_Browse1</objectName>
408  <x>8</x>
409  <y>177</y>
410  <width>170</width>
411  <height>30</height>
412  <uuid>{b411f2ac-0923-448a-8775-80459ac1e64b}</uuid>
413  <visible>true</visible>
414  <midichan>0</midichan>
415  <midicc>0</midicc>
416  <type>value</type>
417  <pressedValue>1.00000000</pressedValue>
418  <stringvalue>AndItsAll.wav</stringvalue>
419  <text>Browse Audio File</text>
420  <image>/</image>
421  <eventLine/>
422  <latch>false</latch>
423  <latched>false</latched>
424 </bsbObject>
425 <bsbObject version="2" type="BSBLineEdit">
426  <objectName>_Browse1</objectName>
427  <x>180</x>
428  <y>178</y>
429  <width>330</width>
430  <height>28</height>
431  <uuid>{9553cd40-5661-4712-b84a-1ba4f1e47771}</uuid>
432  <visible>true</visible>
433  <midichan>0</midichan>
434  <midicc>0</midicc>
435  <label>AndItsAll.wav</label>
436  <alignment>left</alignment>
437  <font>Arial</font>
438  <fontsize>10</fontsize>
439  <precision>3</precision>
440  <color>
441   <r>0</r>
442   <g>0</g>
443   <b>0</b>
444  </color>
445  <bgcolor mode="nobackground">
446   <r>229</r>
447   <g>229</g>
448   <b>229</b>
449  </bgcolor>
450  <background>nobackground</background>
451 </bsbObject>
452 <bsbObject version="2" type="BSBLabel">
453  <objectName/>
454  <x>8</x>
455  <y>155</y>
456  <width>120</width>
457  <height>30</height>
458  <uuid>{3fa334fa-0646-437a-89d1-e6b53bd7c1ee}</uuid>
459  <visible>true</visible>
460  <midichan>0</midichan>
461  <midicc>0</midicc>
462  <label>Voice File select</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>213</y>
485  <width>120</width>
486  <height>30</height>
487  <uuid>{cd4dde52-3326-4f78-b905-f389aac73a9f}</uuid>
488  <visible>true</visible>
489  <midichan>0</midichan>
490  <midicc>0</midicc>
491  <label>Drums File select</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="BSBLineEdit">
511  <objectName>_Browse2</objectName>
512  <x>180</x>
513  <y>236</y>
514  <width>330</width>
515  <height>28</height>
516  <uuid>{d0c73426-7504-4397-856f-20649aa7a5c8}</uuid>
517  <visible>true</visible>
518  <midichan>0</midichan>
519  <midicc>0</midicc>
520  <label>808loopMono.wav</label>
521  <alignment>left</alignment>
522  <font>Arial</font>
523  <fontsize>10</fontsize>
524  <precision>3</precision>
525  <color>
526   <r>0</r>
527   <g>0</g>
528   <b>0</b>
529  </color>
530  <bgcolor mode="nobackground">
531   <r>229</r>
532   <g>229</g>
533   <b>229</b>
534  </bgcolor>
535  <background>nobackground</background>
536 </bsbObject>
537 <bsbObject version="2" type="BSBButton">
538  <objectName>_Browse2</objectName>
539  <x>8</x>
540  <y>235</y>
541  <width>170</width>
542  <height>30</height>
543  <uuid>{064f423b-4026-4573-8baf-76f3460def13}</uuid>
544  <visible>true</visible>
545  <midichan>0</midichan>
546  <midicc>0</midicc>
547  <type>value</type>
548  <pressedValue>1.00000000</pressedValue>
549  <stringvalue>808loopMono.wav</stringvalue>
550  <text>Browse Audio File</text>
551  <image>/</image>
552  <eventLine/>
553  <latch>false</latch>
554  <latched>false</latched>
555 </bsbObject>
556 <bsbObject version="2" type="BSBLabel">
557  <objectName/>
558  <x>180</x>
559  <y>262</y>
560  <width>330</width>
561  <height>30</height>
562  <uuid>{a63909ac-6fa4-41c8-a84b-ba08e76132ab}</uuid>
563  <visible>true</visible>
564  <midichan>0</midichan>
565  <midicc>0</midicc>
566  <label>Restart the instrument after changing the audio file.</label>
567  <alignment>left</alignment>
568  <font>Liberation Sans</font>
569  <fontsize>12</fontsize>
570  <precision>3</precision>
571  <color>
572   <r>0</r>
573   <g>0</g>
574   <b>0</b>
575  </color>
576  <bgcolor mode="nobackground">
577   <r>255</r>
578   <g>255</g>
579   <b>255</b>
580  </bgcolor>
581  <bordermode>noborder</bordermode>
582  <borderradius>1</borderradius>
583  <borderwidth>1</borderwidth>
584 </bsbObject>
585 <bsbObject version="2" type="BSBLabel">
586  <objectName/>
587  <x>180</x>
588  <y>206</y>
589  <width>330</width>
590  <height>30</height>
591  <uuid>{36ba8ef2-ab45-4273-a97b-52d1eb1034b3}</uuid>
592  <visible>true</visible>
593  <midichan>0</midichan>
594  <midicc>0</midicc>
595  <label>Restart the instrument after changing the audio file.</label>
596  <alignment>left</alignment>
597  <font>Liberation Sans</font>
598  <fontsize>12</fontsize>
599  <precision>3</precision>
600  <color>
601   <r>0</r>
602   <g>0</g>
603   <b>0</b>
604  </color>
605  <bgcolor mode="nobackground">
606   <r>255</r>
607   <g>255</g>
608   <b>255</b>
609  </bgcolor>
610  <bordermode>noborder</bordermode>
611  <borderradius>1</borderradius>
612  <borderwidth>1</borderwidth>
613 </bsbObject>
614</bsbPanel>
615<bsbPresets>
616</bsbPresets>
617<EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="false" loopStart="0" loopEnd="0">    </EventPanel>
618