Debian Codegraph @

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

raw
1 ;Written by Iain McCurdy, 2006
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 = 32 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
19 nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
20
21
22 ;TABLE FOR EXP SLIDER
23 giExp1 ftgen 0, 0, 129, -25, 0, 0.001, 128, 1.0
24
25
26 opcode FilePlay2, aa, Skoo ; Credit to Joachim Heintz
27 ;gives stereo output regardless your soundfile is mono or stereo
28 Sfil, kspeed, iskip, iloop xin
29 ichn filenchnls Sfil
30 if ichn == 1 then
31 aL diskin2 Sfil, kspeed, iskip, iloop
32 aR = aL
33 else
34 aL, aR diskin2 Sfil, kspeed, iskip, iloop
35 endif
36 xout aL, aR
37 endop
38
39
40 instr 1 ;GUI
41 ktrig metro 10
42 if (ktrig == 1) then
43 gkpregain invalue "Pregain" ;init 10.0
44 kpostgain invalue "Postgain" ;init .4
45 gkpostgain tablei kpostgain, giExp1, 1
46 outvalue "Postgain_Value", gkpostgain ;init 0.4
47
48 gkshape1 invalue "Shape1" ;init 0
49 gkshape2 invalue "Shape2" ;init 0
50 endif
51 endin
52
53 instr 2
54 Sfile invalue "_Browse1"
55 asigL, asigR FilePlay2 Sfile, 1, 0, 1 ;AUDIO SIGNAL READ FROM DISC
56 adistortL distort1 asigL, gkpregain, gkpostgain, gkshape1, gkshape2 ;CREATE 'distort1' SIGNAL
57 adistortR distort1 asigR, gkpregain, gkpostgain, gkshape1, gkshape2 ;CREATE 'distort1' SIGNAL
58 outs adistortL, adistortR ;SEND AUDIO TO OUTPUTS
59 endin
60 </CsInstruments>
61 <CsScore>
62 ;INSTR | START | DURATION
63 i 1 0 3600 ;GUI
64 </CsScore>
65 </CsoundSynthesizer>
66
67
68
69
70 <bsbPanel>
71 <label>Widgets</label>
72 <objectName/>
73 <x>72</x>
74 <y>179</y>
75 <width>890</width>
76 <height>356</height>
77 <visible>true</visible>
78 <uuid/>
79 <bgcolor mode="background">
80 <r>241</r>
81 <g>226</g>
82 <b>185</b>
83 </bgcolor>
84 <bsbObject type="BSBLabel" version="2">
85 <objectName/>
86 <x>2</x>
87 <y>2</y>
88 <width>515</width>
89 <height>300</height>
90 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
91 <visible>true</visible>
92 <midichan>0</midichan>
93 <midicc>0</midicc>
94 <label>Distort1</label>
95 <alignment>center</alignment>
96 <font>Liberation Sans</font>
97 <fontsize>18</fontsize>
98 <precision>3</precision>
99 <color>
100 <r>0</r>
101 <g>0</g>
102 <b>0</b>
103 </color>
104 <bgcolor mode="background">
105 <r>158</r>
106 <g>220</g>
107 <b>158</b>
108 </bgcolor>
109 <bordermode>border</bordermode>
110 <borderradius>5</borderradius>
111 <borderwidth>2</borderwidth>
112 </bsbObject>
113 <bsbObject type="BSBHSlider" version="2">
114 <objectName>Pregain</objectName>
115 <x>10</x>
116 <y>69</y>
117 <width>500</width>
118 <height>27</height>
119 <uuid>{de47f47d-bcea-4c1c-ab4b-a323452b1f7e}</uuid>
120 <visible>true</visible>
121 <midichan>0</midichan>
122 <midicc>0</midicc>
123 <minimum>0.00000000</minimum>
124 <maximum>100.00000000</maximum>
125 <value>49.80000000</value>
126 <mode>lin</mode>
127 <mouseControl act="jump">continuous</mouseControl>
128 <resolution>-1.00000000</resolution>
129 <randomizable group="0">false</randomizable>
130 </bsbObject>
131 <bsbObject type="BSBLabel" version="2">
132 <objectName/>
133 <x>10</x>
134 <y>86</y>
135 <width>100</width>
136 <height>30</height>
137 <uuid>{0200a063-5db8-4668-bc2d-2d989a083f6e}</uuid>
138 <visible>true</visible>
139 <midichan>0</midichan>
140 <midicc>0</midicc>
141 <label>Pregain</label>
142 <alignment>left</alignment>
143 <font>Arial</font>
144 <fontsize>10</fontsize>
145 <precision>3</precision>
146 <color>
147 <r>0</r>
148 <g>0</g>
149 <b>0</b>
150 </color>
151 <bgcolor mode="nobackground">
152 <r>255</r>
153 <g>255</g>
154 <b>255</b>
155 </bgcolor>
156 <bordermode>noborder</bordermode>
157 <borderradius>1</borderradius>
158 <borderwidth>1</borderwidth>
159 </bsbObject>
160 <bsbObject type="BSBDisplay" version="2">
161 <objectName>Pregain</objectName>
162 <x>450</x>
163 <y>86</y>
164 <width>60</width>
165 <height>30</height>
166 <uuid>{ab191e3a-430d-4f1d-88aa-9840342cd2d3}</uuid>
167 <visible>true</visible>
168 <midichan>0</midichan>
169 <midicc>0</midicc>
170 <label>49.800</label>
171 <alignment>right</alignment>
172 <font>Arial</font>
173 <fontsize>9</fontsize>
174 <precision>3</precision>
175 <color>
176 <r>0</r>
177 <g>0</g>
178 <b>0</b>
179 </color>
180 <bgcolor mode="nobackground">
181 <r>255</r>
182 <g>255</g>
183 <b>255</b>
184 </bgcolor>
185 <bordermode>noborder</bordermode>
186 <borderradius>1</borderradius>
187 <borderwidth>1</borderwidth>
188 </bsbObject>
189 <bsbObject type="BSBLabel" version="2">
190 <objectName/>
191 <x>518</x>
192 <y>2</y>
193 <width>363</width>
194 <height>300</height>
195 <uuid>{74928ed2-b701-4668-9a11-74763d317e9b}</uuid>
196 <visible>true</visible>
197 <midichan>0</midichan>
198 <midicc>0</midicc>
199 <label>Distort1</label>
200 <alignment>center</alignment>
201 <font>Liberation Sans</font>
202 <fontsize>18</fontsize>
203 <precision>3</precision>
204 <color>
205 <r>0</r>
206 <g>0</g>
207 <b>0</b>
208 </color>
209 <bgcolor mode="background">
210 <r>158</r>
211 <g>220</g>
212 <b>158</b>
213 </bgcolor>
214 <bordermode>border</bordermode>
215 <borderradius>5</borderradius>
216 <borderwidth>2</borderwidth>
217 </bsbObject>
218 <bsbObject type="BSBLabel" version="2">
219 <objectName/>
220 <x>522</x>
221 <y>20</y>
222 <width>357</width>
223 <height>277</height>
224 <uuid>{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}</uuid>
225 <visible>true</visible>
226 <midichan>0</midichan>
227 <midicc>0</midicc>
228 <label>-------------------------------------------------------------------------------------
229 Distort1 implements modified hyperbolic tangent distortion. Distort1 can be used to generate wave shaping distortion based on a modification of the tanh function. 'Pregain' determines the amount of gain that is applied to the audio signal before waveshaping. A value of 1 gives a slight distortion. 'Postgain' controls the gain of the signal after waveshaping. Increasing 'pregain' increases the amount of distortion of the signal. High values for 'pregain' may require compensating low values for 'postgain' in order to prevent csound producing samples out of range. 'Shape 1' shapes the positive part of the signal. A value of zero produces flat clipping of the positive part of the signal. Values slightly above zero produce sloped shaping. 'Shape 2' gives similar shaping control of the negative part of the signal.</label>
230 <alignment>left</alignment>
231 <font>Liberation Sans</font>
232 <fontsize>14</fontsize>
233 <precision>3</precision>
234 <color>
235 <r>0</r>
236 <g>0</g>
237 <b>0</b>
238 </color>
239 <bgcolor mode="nobackground">
240 <r>255</r>
241 <g>255</g>
242 <b>255</b>
243 </bgcolor>
244 <bordermode>noborder</bordermode>
245 <borderradius>1</borderradius>
246 <borderwidth>1</borderwidth>
247 </bsbObject>
248 <bsbObject type="BSBLabel" version="2">
249 <objectName/>
250 <x>10</x>
251 <y>126</y>
252 <width>100</width>
253 <height>30</height>
254 <uuid>{6d8d92f5-813d-4e91-867e-f3384b0baf9d}</uuid>
255 <visible>true</visible>
256 <midichan>0</midichan>
257 <midicc>0</midicc>
258 <label>Postgain</label>
259 <alignment>left</alignment>
260 <font>Arial</font>
261 <fontsize>10</fontsize>
262 <precision>3</precision>
263 <color>
264 <r>0</r>
265 <g>0</g>
266 <b>0</b>
267 </color>
268 <bgcolor mode="nobackground">
269 <r>255</r>
270 <g>255</g>
271 <b>255</b>
272 </bgcolor>
273 <bordermode>noborder</bordermode>
274 <borderradius>1</borderradius>
275 <borderwidth>1</borderwidth>
276 </bsbObject>
277 <bsbObject type="BSBHSlider" version="2">
278 <objectName>Postgain</objectName>
279 <x>10</x>
280 <y>109</y>
281 <width>500</width>
282 <height>27</height>
283 <uuid>{8fbaf396-5ad3-4de9-b5fe-cf9991b23868}</uuid>
284 <visible>true</visible>
285 <midichan>0</midichan>
286 <midicc>0</midicc>
287 <minimum>0.00000000</minimum>
288 <maximum>1.00000000</maximum>
289 <value>0.65000000</value>
290 <mode>lin</mode>
291 <mouseControl act="jump">continuous</mouseControl>
292 <resolution>-1.00000000</resolution>
293 <randomizable group="0">false</randomizable>
294 </bsbObject>
295 <bsbObject type="BSBDisplay" version="2">
296 <objectName>Postgain_Value</objectName>
297 <x>450</x>
298 <y>126</y>
299 <width>60</width>
300 <height>30</height>
301 <uuid>{0a5ba1c3-3448-4200-9a48-c116a64fc284}</uuid>
302 <visible>true</visible>
303 <midichan>0</midichan>
304 <midicc>0</midicc>
305 <label>0.089</label>
306 <alignment>right</alignment>
307 <font>Arial</font>
308 <fontsize>9</fontsize>
309 <precision>3</precision>
310 <color>
311 <r>0</r>
312 <g>0</g>
313 <b>0</b>
314 </color>
315 <bgcolor mode="nobackground">
316 <r>255</r>
317 <g>255</g>
318 <b>255</b>
319 </bgcolor>
320 <bordermode>noborder</bordermode>
321 <borderradius>1</borderradius>
322 <borderwidth>1</borderwidth>
323 </bsbObject>
324 <bsbObject type="BSBButton" version="2">
325 <objectName/>
326 <x>8</x>
327 <y>8</y>
328 <width>100</width>
329 <height>29</height>
330 <uuid>{24979132-c53f-4414-ac6b-6b4f503ecfe8}</uuid>
331 <visible>true</visible>
332 <midichan>0</midichan>
333 <midicc>0</midicc>
334 <type>event</type>
335 <pressedValue>1.00000000</pressedValue>
336 <stringvalue/>
337 <text> On / Off</text>
338 <image>/</image>
339 <eventLine>i 2 0 -1</eventLine>
340 <latch>true</latch>
341 <latched>false</latched>
342 </bsbObject>
343 <bsbObject type="BSBDisplay" version="2">
344 <objectName>Shape2</objectName>
345 <x>450</x>
346 <y>208</y>
347 <width>60</width>
348 <height>30</height>
349 <uuid>{d17cef64-754f-4c35-8b5d-8aacd44a67ac}</uuid>
350 <visible>true</visible>
351 <midichan>0</midichan>
352 <midicc>0</midicc>
353 <label>0.656</label>
354 <alignment>right</alignment>
355 <font>Arial</font>
356 <fontsize>9</fontsize>
357 <precision>3</precision>
358 <color>
359 <r>0</r>
360 <g>0</g>
361 <b>0</b>
362 </color>
363 <bgcolor mode="nobackground">
364 <r>255</r>
365 <g>255</g>
366 <b>255</b>
367 </bgcolor>
368 <bordermode>noborder</bordermode>
369 <borderradius>1</borderradius>
370 <borderwidth>1</borderwidth>
371 </bsbObject>
372 <bsbObject type="BSBLabel" version="2">
373 <objectName/>
374 <x>10</x>
375 <y>208</y>
376 <width>120</width>
377 <height>30</height>
378 <uuid>{9deb9ba2-a5d6-4275-95ec-5d611d2d8a3c}</uuid>
379 <visible>true</visible>
380 <midichan>0</midichan>
381 <midicc>0</midicc>
382 <label>Shape 2</label>
383 <alignment>left</alignment>
384 <font>Arial</font>
385 <fontsize>10</fontsize>
386 <precision>3</precision>
387 <color>
388 <r>0</r>
389 <g>0</g>
390 <b>0</b>
391 </color>
392 <bgcolor mode="nobackground">
393 <r>255</r>
394 <g>255</g>
395 <b>255</b>
396 </bgcolor>
397 <bordermode>noborder</bordermode>
398 <borderradius>1</borderradius>
399 <borderwidth>1</borderwidth>
400 </bsbObject>
401 <bsbObject type="BSBHSlider" version="2">
402 <objectName>Shape2</objectName>
403 <x>10</x>
404 <y>191</y>
405 <width>500</width>
406 <height>27</height>
407 <uuid>{1cc8abab-d4c4-4e67-8bb5-ecff7667fe2e}</uuid>
408 <visible>true</visible>
409 <midichan>0</midichan>
410 <midicc>0</midicc>
411 <minimum>0.00000000</minimum>
412 <maximum>1.00000000</maximum>
413 <value>0.65600000</value>
414 <mode>lin</mode>
415 <mouseControl act="jump">continuous</mouseControl>
416 <resolution>-1.00000000</resolution>
417 <randomizable group="0">false</randomizable>
418 </bsbObject>
419 <bsbObject type="BSBHSlider" version="2">
420 <objectName>Shape1</objectName>
421 <x>10</x>
422 <y>150</y>
423 <width>500</width>
424 <height>27</height>
425 <uuid>{70eb07ae-f0d6-4a8b-ab44-ee30cba19126}</uuid>
426 <visible>true</visible>
427 <midichan>0</midichan>
428 <midicc>0</midicc>
429 <minimum>0.00000000</minimum>
430 <maximum>1.00000000</maximum>
431 <value>0.43000000</value>
432 <mode>lin</mode>
433 <mouseControl act="jump">continuous</mouseControl>
434 <resolution>-1.00000000</resolution>
435 <randomizable group="0">false</randomizable>
436 </bsbObject>
437 <bsbObject type="BSBLabel" version="2">
438 <objectName/>
439 <x>10</x>
440 <y>167</y>
441 <width>120</width>
442 <height>30</height>
443 <uuid>{128e3075-bd47-45ae-a3fe-005e5dc3a2df}</uuid>
444 <visible>true</visible>
445 <midichan>0</midichan>
446 <midicc>0</midicc>
447 <label>Shape 1</label>
448 <alignment>left</alignment>
449 <font>Arial</font>
450 <fontsize>10</fontsize>
451 <precision>3</precision>
452 <color>
453 <r>0</r>
454 <g>0</g>
455 <b>0</b>
456 </color>
457 <bgcolor mode="nobackground">
458 <r>255</r>
459 <g>255</g>
460 <b>255</b>
461 </bgcolor>
462 <bordermode>noborder</bordermode>
463 <borderradius>1</borderradius>
464 <borderwidth>1</borderwidth>
465 </bsbObject>
466 <bsbObject type="BSBDisplay" version="2">
467 <objectName>Shape1</objectName>
468 <x>451</x>
469 <y>167</y>
470 <width>59</width>
471 <height>30</height>
472 <uuid>{a4ac66b2-e107-421a-8b74-62ccff69421c}</uuid>
473 <visible>true</visible>
474 <midichan>0</midichan>
475 <midicc>0</midicc>
476 <label>0.430</label>
477 <alignment>right</alignment>
478 <font>Arial</font>
479 <fontsize>9</fontsize>
480 <precision>3</precision>
481 <color>
482 <r>0</r>
483 <g>0</g>
484 <b>0</b>
485 </color>
486 <bgcolor mode="nobackground">
487 <r>255</r>
488 <g>255</g>
489 <b>255</b>
490 </bgcolor>
491 <bordermode>noborder</bordermode>
492 <borderradius>1</borderradius>
493 <borderwidth>1</borderwidth>
494 </bsbObject>
495 <bsbObject type="BSBButton" version="2">
496 <objectName>_Browse1</objectName>
497 <x>10</x>
498 <y>242</y>
499 <width>170</width>
500 <height>30</height>
501 <uuid>{b0100cc5-8ee3-47da-8ddf-65d7b477262b}</uuid>
502 <visible>true</visible>
503 <midichan>0</midichan>
504 <midicc>0</midicc>
505 <type>value</type>
506 <pressedValue>1.00000000</pressedValue>
507 <stringvalue>/media/jh/61b896a3-f371-4f01-8429-8ab6a56dd7a2/home/jh/Joachim/Stuecke/40scp/samples/edge.aif</stringvalue>
508 <text>Browse Audio File</text>
509 <image>/</image>
510 <eventLine/>
511 <latch>false</latch>
512 <latched>false</latched>
513 </bsbObject>
514 <bsbObject type="BSBLineEdit" version="2">
515 <objectName>_Browse1</objectName>
516 <x>181</x>
517 <y>243</y>
518 <width>330</width>
519 <height>28</height>
520 <uuid>{7bb32984-d707-48f1-bed5-b67e32d7373f}</uuid>
521 <visible>true</visible>
522 <midichan>0</midichan>
523 <midicc>0</midicc>
524 <label>/media/jh/61b896a3-f371-4f01-8429-8ab6a56dd7a2/home/jh/Joachim/Stuecke/40scp/samples/edge.aif</label>
525 <alignment>left</alignment>
526 <font>Arial</font>
527 <fontsize>10</fontsize>
528 <precision>3</precision>
529 <color>
530 <r>0</r>
531 <g>0</g>
532 <b>0</b>
533 </color>
534 <bgcolor mode="nobackground">
535 <r>35</r>
536 <g>35</g>
537 <b>35</b>
538 </bgcolor>
539 <background>nobackground</background>
540 </bsbObject>
541 <bsbObject type="BSBLabel" version="2">
542 <objectName/>
543 <x>181</x>
544 <y>271</y>
545 <width>330</width>
546 <height>30</height>
547 <uuid>{a63909ac-6fa4-41c8-a84b-ba08e76132ab}</uuid>
548 <visible>true</visible>
549 <midichan>0</midichan>
550 <midicc>0</midicc>
551 <label>Restart the instrument after changing the audio file.</label>
552 <alignment>left</alignment>
553 <font>Liberation Sans</font>
554 <fontsize>12</fontsize>
555 <precision>3</precision>
556 <color>
557 <r>0</r>
558 <g>0</g>
559 <b>0</b>
560 </color>
561 <bgcolor mode="nobackground">
562 <r>255</r>
563 <g>255</g>
564 <b>255</b>
565 </bgcolor>
566 <bordermode>noborder</bordermode>
567 <borderradius>1</borderradius>
568 <borderwidth>1</borderwidth>
569 </bsbObject>
570 </bsbPanel>
571 <bsbPresets>
572 </bsbPresets>
573 <EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="true" loopStart="0" loopEnd="0"> </EventPanel>