Debian Codegraph @

src/Examples/McCurdy Collection/SoundGenerators/gbuzz.csd

raw
1 ;Written by Iain McCurdy, 2006
2
3
4 ;Modified for QuteCsound by René, April 2011
5 ;Tested on Ubuntu 10.04 with csound-float 5.13.0 and QuteCsound svn rev 817
6
7 ;Notes on modifications from original csd:
8 ; Add table(s) for exp slider
9 ; Removed subinstr call to instrument 2 from instrument 1
10 ; Use QuteCsound internal midi interface for Amplitude Multiplier (Channel 1, CC#1)
11
12
13 ;my flags on Ubuntu: -iadc -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=alsa -Ma -m0
14 <CsoundSynthesizer>
15 <CsOptions>
16
17 </CsOptions>
18 <CsInstruments>
19 sr = 44100 ;SAMPLE RATE
20 ksmps = 16 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
21 nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
22 0dbfs = 1 ;MAXIMUM SOUND INTENSITY LEVEL REGARDLESS OF BIT DEPTH
23
24
25 gicos ftgen 0, 0, 65536, 9, 1, 1, 90 ;FUNCTION TABLE THAT STORES A SINGLE CYCLE OF A COSINE WAVE
26 giExp1 ftgen 0, 0, 129, -25, 0, 1.0, 128, 2000.0 ;TABLE FOR EXP SLIDER
27
28
29 instr 10 ;GUI
30 gkamp invalue "Amplitude"
31 kfreq invalue "Frequency"
32 gkfreq tablei kfreq, giExp1, 1
33 outvalue "Frequency_Value", gkfreq
34 gkmul invalue "AmpMult"
35 gklh invalue "LowestHarm"
36 gkharm invalue "Harmonics"
37 endin
38
39 instr 1 ;MIDI INPUT INSTRUMENT
40 icps cpsmidi ;READ CYCLES PER SECOND VALUE FROM MIDI INPUT
41 iamp ampmidi 1 ;READ IN A NOTE VELOCITY VALUE FROM THE MIDI INPUT
42 kamp = iamp * gkamp
43
44 ;PITCH BEND===========================================================================================================================================================
45 iSemitoneBendRange= 2 ;PITCH BEND RANGE IN SEMITONES
46 imin = 0 ;EQUILIBRIUM POSITION
47 imax = iSemitoneBendRange * .0833333 ;MAX PITCH DISPLACEMENT (IN oct FORMAT)
48 kbend pchbend imin, imax ;PITCH BEND VARIABLE (IN oct FORMAT)
49 koct = octcps(icps)
50 kfreq = cpsoct(koct + kbend)
51 ;=====================================================================================================================================================================
52
53 iporttime = 0.05 ;PORTAMENTO TIME VARIABLE
54 kporttime linseg 0,0.001,iporttime,1,iporttime ;CREATE A RAMPING UP FUNCTION TO REPRESENT PORTAMENTO TIME
55 kmulp portk gkmul, kporttime ;APPLY PORTAMENTO SMOOTHING
56
57 ;OUTPUT OPCODE AMPLITUDE | FREQUENCY | NO.OF_HARMONICS | LOWEST_HARMONIC | POWER | FUNCTION_TABLE
58 asig gbuzz kamp, kfreq, gkharm, gklh, kmulp, gicos
59 aenv linsegr 0,0.01,1,0.01,0 ;ANTI-CLICK ENVELOPE
60 outs asig * aenv, asig * aenv ;SEND AUDIO OUTPUT TO THE SPEAKERS
61 endin
62
63 instr 2 ;GUZZ INSTRUMENT
64 iporttime = 0.05 ;PORTAMENTO TIME VARIABLE
65 kporttime linseg 0,0.001,iporttime,1,iporttime ;CREATE A RAMPING UP FUNCTION TO REPRESENT PORTAMENTO TIME
66 kmul portk gkmul, kporttime ;APPLY PORTAMENTO SMOOTHING
67
68 ;OUTPUT OPCODE AMPLITUDE | FREQUENCY | NO.OF_HARMONICS | LOWEST_HARMONIC | POWER | FUNCTION_TABLE
69 asig gbuzz gkamp, gkfreq, gkharm, gklh, kmul, gicos
70 aenv linsegr 0,0.01,1,0.01,0 ;ANTI-CLICK ENVELOPE
71 outs asig * aenv, asig * aenv ;SEND AUDIO OUTPUT TO THE SPEAKERS
72 endin
73 </CsInstruments>
74 <CsScore>
75 ;INSTR | START | DURATION
76 i 10 0.0 3600 ;GUI
77 </CsScore>
78 </CsoundSynthesizer>
79 <bsbPanel>
80 <label>Widgets</label>
81 <objectName/>
82 <x>615</x>
83 <y>326</y>
84 <width>1036</width>
85 <height>256</height>
86 <visible>true</visible>
87 <uuid/>
88 <bgcolor mode="background">
89 <r>241</r>
90 <g>226</g>
91 <b>185</b>
92 </bgcolor>
93 <bsbObject version="2" type="BSBLabel">
94 <objectName/>
95 <x>2</x>
96 <y>2</y>
97 <width>512</width>
98 <height>254</height>
99 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
100 <visible>true</visible>
101 <midichan>0</midichan>
102 <midicc>0</midicc>
103 <label>gbuzz</label>
104 <alignment>center</alignment>
105 <font>Liberation Sans</font>
106 <fontsize>18</fontsize>
107 <precision>3</precision>
108 <color>
109 <r>255</r>
110 <g>255</g>
111 <b>0</b>
112 </color>
113 <bgcolor mode="background">
114 <r>106</r>
115 <g>117</g>
116 <b>150</b>
117 </bgcolor>
118 <bordermode>border</bordermode>
119 <borderradius>5</borderradius>
120 <borderwidth>2</borderwidth>
121 </bsbObject>
122 <bsbObject version="2" type="BSBButton">
123 <objectName/>
124 <x>8</x>
125 <y>10</y>
126 <width>124</width>
127 <height>30</height>
128 <uuid>{487d5181-d838-4cce-9628-317fefc350cb}</uuid>
129 <visible>true</visible>
130 <midichan>0</midichan>
131 <midicc>0</midicc>
132 <type>event</type>
133 <pressedValue>1.00000000</pressedValue>
134 <stringvalue/>
135 <text> ON / OFF (MIDI)</text>
136 <image>/</image>
137 <eventLine>i 2 0 -1</eventLine>
138 <latch>true</latch>
139 <latched>false</latched>
140 </bsbObject>
141 <bsbObject version="2" type="BSBLabel">
142 <objectName/>
143 <x>8</x>
144 <y>138</y>
145 <width>150</width>
146 <height>30</height>
147 <uuid>{0200a063-5db8-4668-bc2d-2d989a083f6e}</uuid>
148 <visible>true</visible>
149 <midichan>0</midichan>
150 <midicc>0</midicc>
151 <label>Amplitude</label>
152 <alignment>left</alignment>
153 <font>Liberation Sans</font>
154 <fontsize>10</fontsize>
155 <precision>3</precision>
156 <color>
157 <r>255</r>
158 <g>255</g>
159 <b>0</b>
160 </color>
161 <bgcolor mode="nobackground">
162 <r>255</r>
163 <g>255</g>
164 <b>255</b>
165 </bgcolor>
166 <bordermode>noborder</bordermode>
167 <borderradius>1</borderradius>
168 <borderwidth>1</borderwidth>
169 </bsbObject>
170 <bsbObject version="2" type="BSBDisplay">
171 <objectName>Amplitude</objectName>
172 <x>448</x>
173 <y>138</y>
174 <width>60</width>
175 <height>30</height>
176 <uuid>{ab191e3a-430d-4f1d-88aa-9840342cd2d3}</uuid>
177 <visible>true</visible>
178 <midichan>0</midichan>
179 <midicc>0</midicc>
180 <label>0.284</label>
181 <alignment>right</alignment>
182 <font>Liberation Sans</font>
183 <fontsize>9</fontsize>
184 <precision>3</precision>
185 <color>
186 <r>255</r>
187 <g>255</g>
188 <b>0</b>
189 </color>
190 <bgcolor mode="nobackground">
191 <r>255</r>
192 <g>255</g>
193 <b>255</b>
194 </bgcolor>
195 <bordermode>noborder</bordermode>
196 <borderradius>1</borderradius>
197 <borderwidth>1</borderwidth>
198 </bsbObject>
199 <bsbObject version="2" type="BSBLabel">
200 <objectName/>
201 <x>516</x>
202 <y>2</y>
203 <width>520</width>
204 <height>254</height>
205 <uuid>{74928ed2-b701-4668-9a11-74763d317e9b}</uuid>
206 <visible>true</visible>
207 <midichan>0</midichan>
208 <midicc>0</midicc>
209 <label>gbuzz</label>
210 <alignment>center</alignment>
211 <font>Liberation Sans</font>
212 <fontsize>18</fontsize>
213 <precision>3</precision>
214 <color>
215 <r>255</r>
216 <g>255</g>
217 <b>0</b>
218 </color>
219 <bgcolor mode="background">
220 <r>106</r>
221 <g>117</g>
222 <b>150</b>
223 </bgcolor>
224 <bordermode>border</bordermode>
225 <borderradius>5</borderradius>
226 <borderwidth>2</borderwidth>
227 </bsbObject>
228 <bsbObject version="2" type="BSBLabel">
229 <objectName/>
230 <x>520</x>
231 <y>17</y>
232 <width>512</width>
233 <height>237</height>
234 <uuid>{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}</uuid>
235 <visible>true</visible>
236 <midichan>0</midichan>
237 <midicc>0</midicc>
238 <label>------------------------------------------------------------------------------------------------------------------------------
239 Gbuzz creates similar sounds to the buzz opcode by stacking harmonically relates cosine waves but gbuzz offers some additional possibilities. In addition to allowing us to choose the number partials above the fundemental that will be present gbuzz allows us to choose what the lowest partial present will be. The 'Amplitude Multiplier' control allows us to scale the amplitudes of the sequence of partials. With a value of 1 all amplitudes are equal, with values less than one the amplitudes of higher partials are increasingly attenuated, and with values greater than 1 the lower partials are increasingly attenuated. Gbuzz requires us to supply it with a cosine wave function table. This is done using GEN 09. Gbuzz provides a useful source for subtractive synthesis. This example can also be played from an external MIDI keyboard. Pitch, note velocity and pitch bend and represented appropriately. MIDI controller 1 (the modulation wheel) can be used to modulate 'Amplitude Multiplier'.</label>
240 <alignment>left</alignment>
241 <font>Liberation Sans</font>
242 <fontsize>14</fontsize>
243 <precision>3</precision>
244 <color>
245 <r>255</r>
246 <g>255</g>
247 <b>0</b>
248 </color>
249 <bgcolor mode="nobackground">
250 <r>255</r>
251 <g>255</g>
252 <b>255</b>
253 </bgcolor>
254 <bordermode>noborder</bordermode>
255 <borderradius>1</borderradius>
256 <borderwidth>1</borderwidth>
257 </bsbObject>
258 <bsbObject version="2" type="BSBHSlider">
259 <objectName>Amplitude</objectName>
260 <x>8</x>
261 <y>122</y>
262 <width>500</width>
263 <height>27</height>
264 <uuid>{2a8dc6e2-12f4-443d-af9b-59e4373cc24b}</uuid>
265 <visible>true</visible>
266 <midichan>0</midichan>
267 <midicc>0</midicc>
268 <minimum>0.00000000</minimum>
269 <maximum>1.00000000</maximum>
270 <value>0.28400000</value>
271 <mode>lin</mode>
272 <mouseControl act="jump">continuous</mouseControl>
273 <resolution>-1.00000000</resolution>
274 <randomizable group="0">false</randomizable>
275 </bsbObject>
276 <bsbObject version="2" type="BSBLabel">
277 <objectName/>
278 <x>8</x>
279 <y>176</y>
280 <width>150</width>
281 <height>30</height>
282 <uuid>{4fa545c6-e2f1-4387-8c9f-4a9dd388bb42}</uuid>
283 <visible>true</visible>
284 <midichan>0</midichan>
285 <midicc>0</midicc>
286 <label>Amplitude Multiplier CC#1</label>
287 <alignment>left</alignment>
288 <font>Liberation Sans</font>
289 <fontsize>10</fontsize>
290 <precision>3</precision>
291 <color>
292 <r>255</r>
293 <g>255</g>
294 <b>0</b>
295 </color>
296 <bgcolor mode="nobackground">
297 <r>255</r>
298 <g>255</g>
299 <b>255</b>
300 </bgcolor>
301 <bordermode>noborder</bordermode>
302 <borderradius>1</borderradius>
303 <borderwidth>1</borderwidth>
304 </bsbObject>
305 <bsbObject version="2" type="BSBDisplay">
306 <objectName>AmpMult</objectName>
307 <x>448</x>
308 <y>176</y>
309 <width>60</width>
310 <height>30</height>
311 <uuid>{b0ad1916-b43e-44c2-be40-bca29f5cb1f4}</uuid>
312 <visible>true</visible>
313 <midichan>0</midichan>
314 <midicc>0</midicc>
315 <label>0.768</label>
316 <alignment>right</alignment>
317 <font>Liberation Sans</font>
318 <fontsize>9</fontsize>
319 <precision>3</precision>
320 <color>
321 <r>255</r>
322 <g>255</g>
323 <b>0</b>
324 </color>
325 <bgcolor mode="nobackground">
326 <r>255</r>
327 <g>255</g>
328 <b>255</b>
329 </bgcolor>
330 <bordermode>noborder</bordermode>
331 <borderradius>1</borderradius>
332 <borderwidth>1</borderwidth>
333 </bsbObject>
334 <bsbObject version="2" type="BSBHSlider">
335 <objectName>AmpMult</objectName>
336 <x>8</x>
337 <y>160</y>
338 <width>500</width>
339 <height>27</height>
340 <uuid>{9069e547-5638-4568-896f-980087c61de0}</uuid>
341 <visible>true</visible>
342 <midichan>1</midichan>
343 <midicc>1</midicc>
344 <minimum>0.00000000</minimum>
345 <maximum>2.00000000</maximum>
346 <value>0.00000000</value>
347 <mode>lin</mode>
348 <mouseControl act="jump">continuous</mouseControl>
349 <resolution>-1.00000000</resolution>
350 <randomizable group="0">false</randomizable>
351 </bsbObject>
352 <bsbObject version="2" type="BSBLabel">
353 <objectName/>
354 <x>8</x>
355 <y>72</y>
356 <width>160</width>
357 <height>31</height>
358 <uuid>{ada34c8d-83fe-4eae-b207-ac7e38c5251f}</uuid>
359 <visible>true</visible>
360 <midichan>0</midichan>
361 <midicc>0</midicc>
362 <label>Lowest Harmonic :</label>
363 <alignment>right</alignment>
364 <font>Liberation Sans</font>
365 <fontsize>10</fontsize>
366 <precision>3</precision>
367 <color>
368 <r>255</r>
369 <g>255</g>
370 <b>0</b>
371 </color>
372 <bgcolor mode="nobackground">
373 <r>255</r>
374 <g>255</g>
375 <b>255</b>
376 </bgcolor>
377 <bordermode>noborder</bordermode>
378 <borderradius>1</borderradius>
379 <borderwidth>1</borderwidth>
380 </bsbObject>
381 <bsbObject version="2" type="BSBSpinBox">
382 <objectName>LowestHarm</objectName>
383 <x>168</x>
384 <y>68</y>
385 <width>50</width>
386 <height>30</height>
387 <uuid>{c37974b7-7a24-481d-8f02-a116324085e3}</uuid>
388 <visible>true</visible>
389 <midichan>0</midichan>
390 <midicc>0</midicc>
391 <alignment>right</alignment>
392 <font>Liberation Sans</font>
393 <fontsize>16</fontsize>
394 <color>
395 <r>0</r>
396 <g>0</g>
397 <b>0</b>
398 </color>
399 <bgcolor mode="nobackground">
400 <r>255</r>
401 <g>255</g>
402 <b>255</b>
403 </bgcolor>
404 <resolution>1.00000000</resolution>
405 <minimum>1</minimum>
406 <maximum>100</maximum>
407 <randomizable group="0">false</randomizable>
408 <value>5</value>
409 </bsbObject>
410 <bsbObject version="2" type="BSBLabel">
411 <objectName/>
412 <x>8</x>
413 <y>215</y>
414 <width>150</width>
415 <height>30</height>
416 <uuid>{966524ae-5827-4175-82d9-9212ab4b66e9}</uuid>
417 <visible>true</visible>
418 <midichan>0</midichan>
419 <midicc>0</midicc>
420 <label>Oscillator Frequency</label>
421 <alignment>left</alignment>
422 <font>Liberation Sans</font>
423 <fontsize>10</fontsize>
424 <precision>3</precision>
425 <color>
426 <r>255</r>
427 <g>255</g>
428 <b>0</b>
429 </color>
430 <bgcolor mode="nobackground">
431 <r>255</r>
432 <g>255</g>
433 <b>255</b>
434 </bgcolor>
435 <bordermode>noborder</bordermode>
436 <borderradius>1</borderradius>
437 <borderwidth>1</borderwidth>
438 </bsbObject>
439 <bsbObject version="2" type="BSBDisplay">
440 <objectName>Frequency_Value</objectName>
441 <x>448</x>
442 <y>215</y>
443 <width>60</width>
444 <height>30</height>
445 <uuid>{07a3fec3-8a5d-40bb-b2a7-863f17767251}</uuid>
446 <visible>true</visible>
447 <midichan>0</midichan>
448 <midicc>0</midicc>
449 <label>48.270</label>
450 <alignment>right</alignment>
451 <font>Liberation Sans</font>
452 <fontsize>9</fontsize>
453 <precision>3</precision>
454 <color>
455 <r>255</r>
456 <g>255</g>
457 <b>0</b>
458 </color>
459 <bgcolor mode="nobackground">
460 <r>255</r>
461 <g>255</g>
462 <b>255</b>
463 </bgcolor>
464 <bordermode>noborder</bordermode>
465 <borderradius>1</borderradius>
466 <borderwidth>1</borderwidth>
467 </bsbObject>
468 <bsbObject version="2" type="BSBHSlider">
469 <objectName>Frequency</objectName>
470 <x>8</x>
471 <y>199</y>
472 <width>500</width>
473 <height>27</height>
474 <uuid>{322ba409-f459-425b-9d12-651408eaf242}</uuid>
475 <visible>true</visible>
476 <midichan>0</midichan>
477 <midicc>0</midicc>
478 <minimum>0.00000000</minimum>
479 <maximum>1.00000000</maximum>
480 <value>0.51000000</value>
481 <mode>lin</mode>
482 <mouseControl act="jump">continuous</mouseControl>
483 <resolution>-1.00000000</resolution>
484 <randomizable group="0">false</randomizable>
485 </bsbObject>
486 <bsbObject version="2" type="BSBLabel">
487 <objectName/>
488 <x>230</x>
489 <y>72</y>
490 <width>160</width>
491 <height>31</height>
492 <uuid>{a0babd77-65f9-4bbb-88fa-01e5eca23b44}</uuid>
493 <visible>true</visible>
494 <midichan>0</midichan>
495 <midicc>0</midicc>
496 <label>No. of Harmonics :</label>
497 <alignment>right</alignment>
498 <font>Liberation Sans</font>
499 <fontsize>10</fontsize>
500 <precision>3</precision>
501 <color>
502 <r>255</r>
503 <g>255</g>
504 <b>0</b>
505 </color>
506 <bgcolor mode="nobackground">
507 <r>255</r>
508 <g>255</g>
509 <b>255</b>
510 </bgcolor>
511 <bordermode>noborder</bordermode>
512 <borderradius>1</borderradius>
513 <borderwidth>1</borderwidth>
514 </bsbObject>
515 <bsbObject version="2" type="BSBSpinBox">
516 <objectName>Harmonics</objectName>
517 <x>390</x>
518 <y>68</y>
519 <width>50</width>
520 <height>30</height>
521 <uuid>{5a22e9c0-9ed9-4e19-b649-34c1efab9bf7}</uuid>
522 <visible>true</visible>
523 <midichan>0</midichan>
524 <midicc>0</midicc>
525 <alignment>right</alignment>
526 <font>Liberation Sans</font>
527 <fontsize>16</fontsize>
528 <color>
529 <r>0</r>
530 <g>0</g>
531 <b>0</b>
532 </color>
533 <bgcolor mode="nobackground">
534 <r>255</r>
535 <g>255</g>
536 <b>255</b>
537 </bgcolor>
538 <resolution>1.00000000</resolution>
539 <minimum>1</minimum>
540 <maximum>100</maximum>
541 <randomizable group="0">false</randomizable>
542 <value>9</value>
543 </bsbObject>
544 </bsbPanel>
545 <bsbPresets>
546 </bsbPresets>