Debian Codegraph @

src/Examples/McCurdy Collection/Distortion/powershape.csd

raw
1 ;Written by Iain McCurdy, 2009
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>
17 sr = 44100 ;SAMPLE RATE
18 ksmps = 1 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
19 nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
20 0dbfs = 1 ;MAXIMUM SOUND INTENSITY LEVEL REGARDLESS OF BIT DEPTH
21
22
23 ;TABLE FOR EXP SLIDER
24 giExp50 ftgen 0, 0, 129, -25, 0, 0.0001, 128, 50.0
25
26
27 opcode 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
38 endop
39
40
41 instr 1 ;GUI
42 ktrig metro 10
43 if (ktrig == 1) then
44 gkShapeAmount invalue "Waveshaping_Amount" ;init 1.0
45 kOutputGain invalue "Output_Gain"
46 gkOutputGain tablei kOutputGain, giExp50, 1
47 outvalue "Output_Gain_Value", gkOutputGain ;init 1.0
48 endif
49 endin
50
51 instr 2
52 Sfile invalue "_Browse1"
53 ain, asigR FilePlay2 Sfile, 1, 0, 1
54 ifullscale = 1 ;DEFINE FULLSCALE AMPLITUDE VALUE
55 aout powershape ain, gkShapeAmount , ifullscale ;CREATE POWERSHAPED SIGNAL
56 outs aout * gkOutputGain, aout * gkOutputGain ;SEND AUDIO TO OUTPUTS AND RESCALE USING gkOutputGain SLIDER VARIABLE
57 endin
58 </CsInstruments>
59 <CsScore>
60 ;INSTR | START | DURATION
61 i 1 0 3600 ;GUI
62 </CsScore>
63 </CsoundSynthesizer>
64
65
66 <bsbPanel>
67 <label>Widgets</label>
68 <objectName/>
69 <x>475</x>
70 <y>527</y>
71 <width>863</width>
72 <height>235</height>
73 <visible>true</visible>
74 <uuid/>
75 <bgcolor mode="background">
76 <r>241</r>
77 <g>226</g>
78 <b>185</b>
79 </bgcolor>
80 <bsbObject version="2" type="BSBLabel">
81 <objectName/>
82 <x>2</x>
83 <y>2</y>
84 <width>515</width>
85 <height>230</height>
86 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
87 <visible>true</visible>
88 <midichan>0</midichan>
89 <midicc>0</midicc>
90 <label>Powershape</label>
91 <alignment>center</alignment>
92 <font>Liberation Sans</font>
93 <fontsize>18</fontsize>
94 <precision>3</precision>
95 <color>
96 <r>0</r>
97 <g>0</g>
98 <b>0</b>
99 </color>
100 <bgcolor mode="background">
101 <r>158</r>
102 <g>220</g>
103 <b>158</b>
104 </bgcolor>
105 <bordermode>border</bordermode>
106 <borderradius>5</borderradius>
107 <borderwidth>2</borderwidth>
108 </bsbObject>
109 <bsbObject version="2" type="BSBHSlider">
110 <objectName>Waveshaping_Amount</objectName>
111 <x>10</x>
112 <y>69</y>
113 <width>500</width>
114 <height>27</height>
115 <uuid>{de47f47d-bcea-4c1c-ab4b-a323452b1f7e}</uuid>
116 <visible>true</visible>
117 <midichan>0</midichan>
118 <midicc>0</midicc>
119 <minimum>0.00000000</minimum>
120 <maximum>2.00000000</maximum>
121 <value>0.80800000</value>
122 <mode>lin</mode>
123 <mouseControl act="jump">continuous</mouseControl>
124 <resolution>-1.00000000</resolution>
125 <randomizable group="0">false</randomizable>
126 </bsbObject>
127 <bsbObject version="2" type="BSBLabel">
128 <objectName/>
129 <x>10</x>
130 <y>86</y>
131 <width>160</width>
132 <height>30</height>
133 <uuid>{0200a063-5db8-4668-bc2d-2d989a083f6e}</uuid>
134 <visible>true</visible>
135 <midichan>0</midichan>
136 <midicc>0</midicc>
137 <label>Waveshaping Amount</label>
138 <alignment>left</alignment>
139 <font>Arial</font>
140 <fontsize>10</fontsize>
141 <precision>3</precision>
142 <color>
143 <r>0</r>
144 <g>0</g>
145 <b>0</b>
146 </color>
147 <bgcolor mode="nobackground">
148 <r>255</r>
149 <g>255</g>
150 <b>255</b>
151 </bgcolor>
152 <bordermode>noborder</bordermode>
153 <borderradius>1</borderradius>
154 <borderwidth>1</borderwidth>
155 </bsbObject>
156 <bsbObject version="2" type="BSBDisplay">
157 <objectName>Waveshaping_Amount</objectName>
158 <x>450</x>
159 <y>86</y>
160 <width>60</width>
161 <height>30</height>
162 <uuid>{ab191e3a-430d-4f1d-88aa-9840342cd2d3}</uuid>
163 <visible>true</visible>
164 <midichan>0</midichan>
165 <midicc>0</midicc>
166 <label>0.808</label>
167 <alignment>right</alignment>
168 <font>Arial</font>
169 <fontsize>9</fontsize>
170 <precision>3</precision>
171 <color>
172 <r>0</r>
173 <g>0</g>
174 <b>0</b>
175 </color>
176 <bgcolor mode="nobackground">
177 <r>255</r>
178 <g>255</g>
179 <b>255</b>
180 </bgcolor>
181 <bordermode>noborder</bordermode>
182 <borderradius>1</borderradius>
183 <borderwidth>1</borderwidth>
184 </bsbObject>
185 <bsbObject version="2" type="BSBLabel">
186 <objectName/>
187 <x>518</x>
188 <y>2</y>
189 <width>342</width>
190 <height>230</height>
191 <uuid>{74928ed2-b701-4668-9a11-74763d317e9b}</uuid>
192 <visible>true</visible>
193 <midichan>0</midichan>
194 <midicc>0</midicc>
195 <label>Powershape</label>
196 <alignment>center</alignment>
197 <font>Liberation Sans</font>
198 <fontsize>18</fontsize>
199 <precision>3</precision>
200 <color>
201 <r>0</r>
202 <g>0</g>
203 <b>0</b>
204 </color>
205 <bgcolor mode="background">
206 <r>158</r>
207 <g>220</g>
208 <b>158</b>
209 </bgcolor>
210 <bordermode>border</bordermode>
211 <borderradius>5</borderradius>
212 <borderwidth>2</borderwidth>
213 </bsbObject>
214 <bsbObject version="2" type="BSBLabel">
215 <objectName/>
216 <x>521</x>
217 <y>19</y>
218 <width>337</width>
219 <height>189</height>
220 <uuid>{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}</uuid>
221 <visible>true</visible>
222 <midichan>0</midichan>
223 <midicc>0</midicc>
224 <label>----------------------------------------------------------------------------------
225 'powershape' waveshapes an audio signal by raising it to a variable exponent ('Waveshaping Amount').
226 The opcode is given a value for the maximum expected amplitude of the input signal. Using this it normalises the input signal before processing and then expands the output to the original amplitude range.
227 An output gain control is added to allow for compensating for gain increase or decrease depending on waveshaping amount.</label>
228 <alignment>left</alignment>
229 <font>Arial</font>
230 <fontsize>14</fontsize>
231 <precision>3</precision>
232 <color>
233 <r>0</r>
234 <g>0</g>
235 <b>0</b>
236 </color>
237 <bgcolor mode="nobackground">
238 <r>255</r>
239 <g>255</g>
240 <b>255</b>
241 </bgcolor>
242 <bordermode>noborder</bordermode>
243 <borderradius>1</borderradius>
244 <borderwidth>1</borderwidth>
245 </bsbObject>
246 <bsbObject version="2" type="BSBLabel">
247 <objectName/>
248 <x>10</x>
249 <y>126</y>
250 <width>160</width>
251 <height>30</height>
252 <uuid>{6d8d92f5-813d-4e91-867e-f3384b0baf9d}</uuid>
253 <visible>true</visible>
254 <midichan>0</midichan>
255 <midicc>0</midicc>
256 <label>Output Gain</label>
257 <alignment>left</alignment>
258 <font>Arial</font>
259 <fontsize>10</fontsize>
260 <precision>3</precision>
261 <color>
262 <r>0</r>
263 <g>0</g>
264 <b>0</b>
265 </color>
266 <bgcolor mode="nobackground">
267 <r>255</r>
268 <g>255</g>
269 <b>255</b>
270 </bgcolor>
271 <bordermode>noborder</bordermode>
272 <borderradius>1</borderradius>
273 <borderwidth>1</borderwidth>
274 </bsbObject>
275 <bsbObject version="2" type="BSBHSlider">
276 <objectName>Output_Gain</objectName>
277 <x>10</x>
278 <y>109</y>
279 <width>500</width>
280 <height>27</height>
281 <uuid>{8fbaf396-5ad3-4de9-b5fe-cf9991b23868}</uuid>
282 <visible>true</visible>
283 <midichan>0</midichan>
284 <midicc>0</midicc>
285 <minimum>0.00000000</minimum>
286 <maximum>1.00000000</maximum>
287 <value>0.69200000</value>
288 <mode>lin</mode>
289 <mouseControl act="jump">continuous</mouseControl>
290 <resolution>-1.00000000</resolution>
291 <randomizable group="0">false</randomizable>
292 </bsbObject>
293 <bsbObject version="2" type="BSBDisplay">
294 <objectName>Output_Gain_Value</objectName>
295 <x>450</x>
296 <y>126</y>
297 <width>60</width>
298 <height>30</height>
299 <uuid>{0a5ba1c3-3448-4200-9a48-c116a64fc284}</uuid>
300 <visible>true</visible>
301 <midichan>0</midichan>
302 <midicc>0</midicc>
303 <label>0.880</label>
304 <alignment>right</alignment>
305 <font>Arial</font>
306 <fontsize>9</fontsize>
307 <precision>3</precision>
308 <color>
309 <r>0</r>
310 <g>0</g>
311 <b>0</b>
312 </color>
313 <bgcolor mode="nobackground">
314 <r>255</r>
315 <g>255</g>
316 <b>255</b>
317 </bgcolor>
318 <bordermode>noborder</bordermode>
319 <borderradius>1</borderradius>
320 <borderwidth>1</borderwidth>
321 </bsbObject>
322 <bsbObject version="2" type="BSBButton">
323 <objectName/>
324 <x>8</x>
325 <y>8</y>
326 <width>100</width>
327 <height>29</height>
328 <uuid>{24979132-c53f-4414-ac6b-6b4f503ecfe8}</uuid>
329 <visible>true</visible>
330 <midichan>0</midichan>
331 <midicc>0</midicc>
332 <type>event</type>
333 <pressedValue>1.00000000</pressedValue>
334 <stringvalue/>
335 <text> On / Off</text>
336 <image>/</image>
337 <eventLine>i 2 0 -1</eventLine>
338 <latch>true</latch>
339 <latched>false</latched>
340 </bsbObject>
341 <bsbObject version="2" type="BSBButton">
342 <objectName>_Browse1</objectName>
343 <x>8</x>
344 <y>168</y>
345 <width>170</width>
346 <height>30</height>
347 <uuid>{e78a3579-e2a0-4349-9609-5c3e05e712ec}</uuid>
348 <visible>true</visible>
349 <midichan>0</midichan>
350 <midicc>0</midicc>
351 <type>value</type>
352 <pressedValue>1.00000000</pressedValue>
353 <stringvalue>808loopMono.wav</stringvalue>
354 <text>Browse Audio File</text>
355 <image>/</image>
356 <eventLine/>
357 <latch>false</latch>
358 <latched>false</latched>
359 </bsbObject>
360 <bsbObject version="2" type="BSBLineEdit">
361 <objectName>_Browse1</objectName>
362 <x>180</x>
363 <y>169</y>
364 <width>330</width>
365 <height>28</height>
366 <uuid>{f7ef2bdf-a81b-46b5-a4ad-4be2119d61e2}</uuid>
367 <visible>true</visible>
368 <midichan>0</midichan>
369 <midicc>0</midicc>
370 <label>808loopMono.wav</label>
371 <alignment>left</alignment>
372 <font>Arial</font>
373 <fontsize>10</fontsize>
374 <precision>3</precision>
375 <color>
376 <r>0</r>
377 <g>0</g>
378 <b>0</b>
379 </color>
380 <bgcolor mode="nobackground">
381 <r>229</r>
382 <g>229</g>
383 <b>229</b>
384 </bgcolor>
385 <background>nobackground</background>
386 </bsbObject>
387 <bsbObject version="2" type="BSBLabel">
388 <objectName/>
389 <x>180</x>
390 <y>197</y>
391 <width>330</width>
392 <height>30</height>
393 <uuid>{a63909ac-6fa4-41c8-a84b-ba08e76132ab}</uuid>
394 <visible>true</visible>
395 <midichan>0</midichan>
396 <midicc>0</midicc>
397 <label>Restart the instrument after changing the audio file.</label>
398 <alignment>left</alignment>
399 <font>Liberation Sans</font>
400 <fontsize>12</fontsize>
401 <precision>3</precision>
402 <color>
403 <r>0</r>
404 <g>0</g>
405 <b>0</b>
406 </color>
407 <bgcolor mode="nobackground">
408 <r>255</r>
409 <g>255</g>
410 <b>255</b>
411 </bgcolor>
412 <bordermode>noborder</bordermode>
413 <borderradius>1</borderradius>
414 <borderwidth>1</borderwidth>
415 </bsbObject>
416 </bsbPanel>
417 <bsbPresets>
418 </bsbPresets>
419 <EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="false" loopStart="0" loopEnd="0"> </EventPanel>