Debian Codegraph @

src/Examples/McCurdy Collection/PhysicalModels/shaker.csd

raw
1 ;Written by Iain McCurdy, 2009
2
3 ;Modified for QuteCsound by René, March 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 tables for exp slider
8 ; INIT instrument added
9
10
11 ;my flags on Ubuntu: -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=null -m0
12 <CsoundSynthesizer>
13 <CsOptions>
14
15 </CsOptions>
16 <CsInstruments>
17 sr = 44100 ;SAMPLE RATE
18 ksmps = 100 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL
19 nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
20 0dbfs = 1 ;MAXIMUM AMPLITUDE REGARDLESS OF BIT DEPTH
21
22
23 giExp1 ftgen 0, 0, 129, -25, 0, 0.5, 128, 20000.0 ;TABLE FOR EXP SLIDER
24
25
26 instr 10 ;GUI
27 ktrig metro 10
28 if (ktrig == 1) then
29 gkamp invalue "Amplitude"
30 kfreq invalue "Frequency"
31 gkfreq tablei kfreq, giExp1, 1
32 outvalue "Frequency_Value", gkfreq
33 gkbeans invalue "NbBeans"
34 gkdamp invalue "Damping"
35 gkdecay invalue "Decay"
36 gkoutgain invalue "OutGain"
37 gktimes invalue "NbShakes"
38 endif
39 endin
40
41 instr 1
42 kSwitch changed gkdecay ;GENERATE A MOMENTARY '1' PULSE IN OUTPUT 'kSwitch' IF ANY OF THE SCANNED INPUT VARIABLES CHANGE. (OUTPUT 'kSwitch' IS NORMALLY ZERO)
43 if kSwitch=1 then
44 reinit BEGIN
45 endif
46 BEGIN:
47 ashaker shaker gkamp, gkfreq, gkbeans, gkdamp, gktimes , i(gkdecay)
48 rireturn
49 outs ashaker * gkoutgain, ashaker * gkoutgain
50 endin
51
52 instr 2 ;INIT
53 outvalue "Amplitude" , 0.2
54 outvalue "Frequency" , 0.0653
55 outvalue "NbBeans" , 30
56 outvalue "Damping" , 0.99
57 outvalue "NbShakes" , 5
58 outvalue "Decay" , 0
59 outvalue "OutGain" , 0.5
60 endin
61 </CsInstruments>
62 <CsScore>
63 ;INSTR | START | DURATION
64 i 10 0 3600 ;GUI
65
66 i 2 0 0.1 ;INIT
67 </CsScore>
68 </CsoundSynthesizer>
69 <bsbPanel>
70 <label>Widgets</label>
71 <objectName/>
72 <x>801</x>
73 <y>282</y>
74 <width>518</width>
75 <height>557</height>
76 <visible>true</visible>
77 <uuid/>
78 <bgcolor mode="background">
79 <r>241</r>
80 <g>226</g>
81 <b>185</b>
82 </bgcolor>
83 <bsbObject version="2" type="BSBLabel">
84 <objectName/>
85 <x>2</x>
86 <y>2</y>
87 <width>512</width>
88 <height>553</height>
89 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
90 <visible>true</visible>
91 <midichan>0</midichan>
92 <midicc>0</midicc>
93 <label>shaker</label>
94 <alignment>center</alignment>
95 <font>Liberation Sans</font>
96 <fontsize>18</fontsize>
97 <precision>3</precision>
98 <color>
99 <r>0</r>
100 <g>0</g>
101 <b>0</b>
102 </color>
103 <bgcolor mode="background">
104 <r>147</r>
105 <g>154</g>
106 <b>255</b>
107 </bgcolor>
108 <bordermode>border</bordermode>
109 <borderradius>5</borderradius>
110 <borderwidth>2</borderwidth>
111 </bsbObject>
112 <bsbObject version="2" type="BSBLabel">
113 <objectName/>
114 <x>8</x>
115 <y>69</y>
116 <width>220</width>
117 <height>30</height>
118 <uuid>{640b50b7-7200-4f81-8394-89d9843ae939}</uuid>
119 <visible>true</visible>
120 <midichan>0</midichan>
121 <midicc>0</midicc>
122 <label>Amplitude</label>
123 <alignment>left</alignment>
124 <font>Liberation Sans</font>
125 <fontsize>10</fontsize>
126 <precision>3</precision>
127 <color>
128 <r>0</r>
129 <g>0</g>
130 <b>0</b>
131 </color>
132 <bgcolor mode="nobackground">
133 <r>255</r>
134 <g>255</g>
135 <b>255</b>
136 </bgcolor>
137 <bordermode>noborder</bordermode>
138 <borderradius>1</borderradius>
139 <borderwidth>1</borderwidth>
140 </bsbObject>
141 <bsbObject version="2" type="BSBHSlider">
142 <objectName>Amplitude</objectName>
143 <x>8</x>
144 <y>48</y>
145 <width>500</width>
146 <height>27</height>
147 <uuid>{5585fa6f-0f63-4ac3-bf1b-809c2b1d9134}</uuid>
148 <visible>true</visible>
149 <midichan>0</midichan>
150 <midicc>0</midicc>
151 <minimum>0.00000000</minimum>
152 <maximum>1.00000000</maximum>
153 <value>0.20000000</value>
154 <mode>lin</mode>
155 <mouseControl act="jump">continuous</mouseControl>
156 <resolution>-1.00000000</resolution>
157 <randomizable group="0">false</randomizable>
158 </bsbObject>
159 <bsbObject version="2" type="BSBDisplay">
160 <objectName>Amplitude</objectName>
161 <x>448</x>
162 <y>69</y>
163 <width>60</width>
164 <height>30</height>
165 <uuid>{b731b52e-e14a-476a-a583-f3b2bd885539}</uuid>
166 <visible>true</visible>
167 <midichan>0</midichan>
168 <midicc>0</midicc>
169 <label>0.200</label>
170 <alignment>right</alignment>
171 <font>Liberation Sans</font>
172 <fontsize>9</fontsize>
173 <precision>3</precision>
174 <color>
175 <r>0</r>
176 <g>0</g>
177 <b>0</b>
178 </color>
179 <bgcolor mode="nobackground">
180 <r>255</r>
181 <g>255</g>
182 <b>255</b>
183 </bgcolor>
184 <bordermode>noborder</bordermode>
185 <borderradius>1</borderradius>
186 <borderwidth>1</borderwidth>
187 </bsbObject>
188 <bsbObject version="2" type="BSBButton">
189 <objectName/>
190 <x>8</x>
191 <y>8</y>
192 <width>120</width>
193 <height>30</height>
194 <uuid>{04d44ebe-12eb-4bb0-a3f5-9e4fd3e7830e}</uuid>
195 <visible>true</visible>
196 <midichan>0</midichan>
197 <midicc>0</midicc>
198 <type>event</type>
199 <pressedValue>1.00000000</pressedValue>
200 <stringvalue/>
201 <text>Shake !</text>
202 <image>/</image>
203 <eventLine>i 1 0 -1</eventLine>
204 <latch>false</latch>
205 <latched>false</latched>
206 </bsbObject>
207 <bsbObject version="2" type="BSBLabel">
208 <objectName/>
209 <x>8</x>
210 <y>115</y>
211 <width>220</width>
212 <height>30</height>
213 <uuid>{1fee3c20-99d2-4c60-baa7-669d23492f06}</uuid>
214 <visible>true</visible>
215 <midichan>0</midichan>
216 <midicc>0</midicc>
217 <label>Frequency</label>
218 <alignment>left</alignment>
219 <font>Liberation Sans</font>
220 <fontsize>10</fontsize>
221 <precision>3</precision>
222 <color>
223 <r>0</r>
224 <g>0</g>
225 <b>0</b>
226 </color>
227 <bgcolor mode="nobackground">
228 <r>255</r>
229 <g>255</g>
230 <b>255</b>
231 </bgcolor>
232 <bordermode>noborder</bordermode>
233 <borderradius>1</borderradius>
234 <borderwidth>1</borderwidth>
235 </bsbObject>
236 <bsbObject version="2" type="BSBHSlider">
237 <objectName>Frequency</objectName>
238 <x>8</x>
239 <y>94</y>
240 <width>500</width>
241 <height>27</height>
242 <uuid>{f5ebacc2-9a31-48e3-adb0-3cb090aec444}</uuid>
243 <visible>true</visible>
244 <midichan>0</midichan>
245 <midicc>0</midicc>
246 <minimum>0.00000000</minimum>
247 <maximum>1.00000000</maximum>
248 <value>0.77000000</value>
249 <mode>lin</mode>
250 <mouseControl act="jump">continuous</mouseControl>
251 <resolution>-1.00000000</resolution>
252 <randomizable group="0">false</randomizable>
253 </bsbObject>
254 <bsbObject version="2" type="BSBDisplay">
255 <objectName>Frequency_Value</objectName>
256 <x>448</x>
257 <y>115</y>
258 <width>60</width>
259 <height>30</height>
260 <uuid>{221d17eb-f6ee-4286-a97f-e6bc5c0a1749}</uuid>
261 <visible>true</visible>
262 <midichan>0</midichan>
263 <midicc>0</midicc>
264 <label>1749.532</label>
265 <alignment>right</alignment>
266 <font>Liberation Sans</font>
267 <fontsize>9</fontsize>
268 <precision>3</precision>
269 <color>
270 <r>0</r>
271 <g>0</g>
272 <b>0</b>
273 </color>
274 <bgcolor mode="nobackground">
275 <r>255</r>
276 <g>255</g>
277 <b>255</b>
278 </bgcolor>
279 <bordermode>noborder</bordermode>
280 <borderradius>1</borderradius>
281 <borderwidth>1</borderwidth>
282 </bsbObject>
283 <bsbObject version="2" type="BSBLabel">
284 <objectName/>
285 <x>8</x>
286 <y>161</y>
287 <width>220</width>
288 <height>30</height>
289 <uuid>{bce7cccd-a303-4a57-af94-fd50cf914991}</uuid>
290 <visible>true</visible>
291 <midichan>0</midichan>
292 <midicc>0</midicc>
293 <label>Number of Beans</label>
294 <alignment>left</alignment>
295 <font>Liberation Sans</font>
296 <fontsize>10</fontsize>
297 <precision>3</precision>
298 <color>
299 <r>0</r>
300 <g>0</g>
301 <b>0</b>
302 </color>
303 <bgcolor mode="nobackground">
304 <r>255</r>
305 <g>255</g>
306 <b>255</b>
307 </bgcolor>
308 <bordermode>noborder</bordermode>
309 <borderradius>1</borderradius>
310 <borderwidth>1</borderwidth>
311 </bsbObject>
312 <bsbObject version="2" type="BSBHSlider">
313 <objectName>NbBeans</objectName>
314 <x>8</x>
315 <y>140</y>
316 <width>500</width>
317 <height>27</height>
318 <uuid>{aaf82558-9229-4d61-8190-0286f3764e87}</uuid>
319 <visible>true</visible>
320 <midichan>0</midichan>
321 <midicc>0</midicc>
322 <minimum>1.00000000</minimum>
323 <maximum>500.00000000</maximum>
324 <value>177.64600000</value>
325 <mode>lin</mode>
326 <mouseControl act="jump">continuous</mouseControl>
327 <resolution>-1.00000000</resolution>
328 <randomizable group="0">false</randomizable>
329 </bsbObject>
330 <bsbObject version="2" type="BSBDisplay">
331 <objectName>NbBeans</objectName>
332 <x>448</x>
333 <y>161</y>
334 <width>60</width>
335 <height>30</height>
336 <uuid>{1cd1723d-bcd9-44df-9f08-9d8191f03601}</uuid>
337 <visible>true</visible>
338 <midichan>0</midichan>
339 <midicc>0</midicc>
340 <label>177.646</label>
341 <alignment>right</alignment>
342 <font>Liberation Sans</font>
343 <fontsize>9</fontsize>
344 <precision>3</precision>
345 <color>
346 <r>0</r>
347 <g>0</g>
348 <b>0</b>
349 </color>
350 <bgcolor mode="nobackground">
351 <r>255</r>
352 <g>255</g>
353 <b>255</b>
354 </bgcolor>
355 <bordermode>noborder</bordermode>
356 <borderradius>1</borderradius>
357 <borderwidth>1</borderwidth>
358 </bsbObject>
359 <bsbObject version="2" type="BSBLabel">
360 <objectName/>
361 <x>8</x>
362 <y>207</y>
363 <width>220</width>
364 <height>30</height>
365 <uuid>{0f0e06ef-104c-459c-8a8b-3bf531321341}</uuid>
366 <visible>true</visible>
367 <midichan>0</midichan>
368 <midicc>0</midicc>
369 <label>Damping</label>
370 <alignment>left</alignment>
371 <font>Liberation Sans</font>
372 <fontsize>10</fontsize>
373 <precision>3</precision>
374 <color>
375 <r>0</r>
376 <g>0</g>
377 <b>0</b>
378 </color>
379 <bgcolor mode="nobackground">
380 <r>255</r>
381 <g>255</g>
382 <b>255</b>
383 </bgcolor>
384 <bordermode>noborder</bordermode>
385 <borderradius>1</borderradius>
386 <borderwidth>1</borderwidth>
387 </bsbObject>
388 <bsbObject version="2" type="BSBHSlider">
389 <objectName>Damping</objectName>
390 <x>8</x>
391 <y>186</y>
392 <width>500</width>
393 <height>27</height>
394 <uuid>{4a2f399c-8a7b-40cf-84ab-839e1d7012f5}</uuid>
395 <visible>true</visible>
396 <midichan>0</midichan>
397 <midicc>0</midicc>
398 <minimum>0.98000000</minimum>
399 <maximum>1.00000000</maximum>
400 <value>0.98000000</value>
401 <mode>lin</mode>
402 <mouseControl act="jump">continuous</mouseControl>
403 <resolution>-1.00000000</resolution>
404 <randomizable group="0">false</randomizable>
405 </bsbObject>
406 <bsbObject version="2" type="BSBDisplay">
407 <objectName>Damping</objectName>
408 <x>448</x>
409 <y>207</y>
410 <width>60</width>
411 <height>30</height>
412 <uuid>{62bd5b38-121f-4382-8c01-02c75edf2237}</uuid>
413 <visible>true</visible>
414 <midichan>0</midichan>
415 <midicc>0</midicc>
416 <label>0.980</label>
417 <alignment>right</alignment>
418 <font>Liberation Sans</font>
419 <fontsize>9</fontsize>
420 <precision>3</precision>
421 <color>
422 <r>0</r>
423 <g>0</g>
424 <b>0</b>
425 </color>
426 <bgcolor mode="nobackground">
427 <r>255</r>
428 <g>255</g>
429 <b>255</b>
430 </bgcolor>
431 <bordermode>noborder</bordermode>
432 <borderradius>1</borderradius>
433 <borderwidth>1</borderwidth>
434 </bsbObject>
435 <bsbObject version="2" type="BSBLabel">
436 <objectName/>
437 <x>8</x>
438 <y>253</y>
439 <width>220</width>
440 <height>30</height>
441 <uuid>{3967c371-a6b0-46ca-a51c-5a44bcad618d}</uuid>
442 <visible>true</visible>
443 <midichan>0</midichan>
444 <midicc>0</midicc>
445 <label>Decay Time (i-rate)</label>
446 <alignment>left</alignment>
447 <font>Liberation Sans</font>
448 <fontsize>10</fontsize>
449 <precision>3</precision>
450 <color>
451 <r>0</r>
452 <g>0</g>
453 <b>0</b>
454 </color>
455 <bgcolor mode="nobackground">
456 <r>255</r>
457 <g>255</g>
458 <b>255</b>
459 </bgcolor>
460 <bordermode>noborder</bordermode>
461 <borderradius>1</borderradius>
462 <borderwidth>1</borderwidth>
463 </bsbObject>
464 <bsbObject version="2" type="BSBHSlider">
465 <objectName>Decay</objectName>
466 <x>8</x>
467 <y>232</y>
468 <width>500</width>
469 <height>27</height>
470 <uuid>{fa94c4bb-3469-4fbf-9096-f6f7c115eb69}</uuid>
471 <visible>true</visible>
472 <midichan>0</midichan>
473 <midicc>0</midicc>
474 <minimum>0.00000000</minimum>
475 <maximum>1.00000000</maximum>
476 <value>0.00000000</value>
477 <mode>lin</mode>
478 <mouseControl act="jump">continuous</mouseControl>
479 <resolution>-1.00000000</resolution>
480 <randomizable group="0">false</randomizable>
481 </bsbObject>
482 <bsbObject version="2" type="BSBDisplay">
483 <objectName>Decay</objectName>
484 <x>448</x>
485 <y>253</y>
486 <width>60</width>
487 <height>30</height>
488 <uuid>{1f01b045-b441-4f44-8dfe-884fb64aba2a}</uuid>
489 <visible>true</visible>
490 <midichan>0</midichan>
491 <midicc>0</midicc>
492 <label>0.000</label>
493 <alignment>right</alignment>
494 <font>Liberation Sans</font>
495 <fontsize>9</fontsize>
496 <precision>3</precision>
497 <color>
498 <r>0</r>
499 <g>0</g>
500 <b>0</b>
501 </color>
502 <bgcolor mode="nobackground">
503 <r>255</r>
504 <g>255</g>
505 <b>255</b>
506 </bgcolor>
507 <bordermode>noborder</bordermode>
508 <borderradius>1</borderradius>
509 <borderwidth>1</borderwidth>
510 </bsbObject>
511 <bsbObject version="2" type="BSBLabel">
512 <objectName/>
513 <x>5</x>
514 <y>355</y>
515 <width>507</width>
516 <height>196</height>
517 <uuid>{4dd9a56f-89f0-4d88-aacf-1fcb6f6145fd}</uuid>
518 <visible>true</visible>
519 <midichan>0</midichan>
520 <midicc>0</midicc>
521 <label>----------------------------------------------------------------------------------------------------------------------------
522 'shaker' is a semi-physical model of the sound of a maraca being shaken. 'Frequency' controls the resonance of the maraca. 'Number of Beans' seems to offer inverse control of the number of beans in the shaker. High values here result in a shaker containing fewer beans. 'Damping' simulates the internal mechanical damping of the shaker. Higher values closer to 1 result in less damping. 'Amplitude' controls the speed of shaking as well as the amplitude. For this reason a separate output gain is provided. 'Number of Shakes' works as expected except that one extra shake is given for the number indicated, e.g. given a value zero, one shake will result. 'Decay Time' appears to have no effect.</label>
523 <alignment>left</alignment>
524 <font>Liberation Sans</font>
525 <fontsize>14</fontsize>
526 <precision>3</precision>
527 <color>
528 <r>0</r>
529 <g>0</g>
530 <b>0</b>
531 </color>
532 <bgcolor mode="nobackground">
533 <r>255</r>
534 <g>255</g>
535 <b>255</b>
536 </bgcolor>
537 <bordermode>noborder</bordermode>
538 <borderradius>1</borderradius>
539 <borderwidth>1</borderwidth>
540 </bsbObject>
541 <bsbObject version="2" type="BSBSpinBox">
542 <objectName>NbShakes</objectName>
543 <x>278</x>
544 <y>274</y>
545 <width>50</width>
546 <height>30</height>
547 <uuid>{73b6e3dd-b842-4f01-9d9b-5a8f495a4dca}</uuid>
548 <visible>true</visible>
549 <midichan>0</midichan>
550 <midicc>0</midicc>
551 <alignment>right</alignment>
552 <font>Liberation Sans</font>
553 <fontsize>14</fontsize>
554 <color>
555 <r>0</r>
556 <g>0</g>
557 <b>0</b>
558 </color>
559 <bgcolor mode="nobackground">
560 <r>255</r>
561 <g>255</g>
562 <b>255</b>
563 </bgcolor>
564 <resolution>1.00000000</resolution>
565 <minimum>0</minimum>
566 <maximum>50</maximum>
567 <randomizable group="0">false</randomizable>
568 <value>5</value>
569 </bsbObject>
570 <bsbObject version="2" type="BSBLabel">
571 <objectName/>
572 <x>134</x>
573 <y>275</y>
574 <width>141</width>
575 <height>30</height>
576 <uuid>{0ff7e4d8-7aa2-4580-992a-1085433af7a3}</uuid>
577 <visible>true</visible>
578 <midichan>0</midichan>
579 <midicc>0</midicc>
580 <label>Number of Shakes</label>
581 <alignment>right</alignment>
582 <font>Liberation Sans</font>
583 <fontsize>10</fontsize>
584 <precision>3</precision>
585 <color>
586 <r>0</r>
587 <g>0</g>
588 <b>0</b>
589 </color>
590 <bgcolor mode="nobackground">
591 <r>255</r>
592 <g>255</g>
593 <b>255</b>
594 </bgcolor>
595 <bordermode>noborder</bordermode>
596 <borderradius>1</borderradius>
597 <borderwidth>1</borderwidth>
598 </bsbObject>
599 <bsbObject version="2" type="BSBLabel">
600 <objectName/>
601 <x>8</x>
602 <y>338</y>
603 <width>220</width>
604 <height>30</height>
605 <uuid>{bb8274f3-5c02-4c77-910c-7af6261b3bdc}</uuid>
606 <visible>true</visible>
607 <midichan>0</midichan>
608 <midicc>0</midicc>
609 <label>Output Gain</label>
610 <alignment>left</alignment>
611 <font>Liberation Sans</font>
612 <fontsize>10</fontsize>
613 <precision>3</precision>
614 <color>
615 <r>0</r>
616 <g>0</g>
617 <b>0</b>
618 </color>
619 <bgcolor mode="nobackground">
620 <r>255</r>
621 <g>255</g>
622 <b>255</b>
623 </bgcolor>
624 <bordermode>noborder</bordermode>
625 <borderradius>1</borderradius>
626 <borderwidth>1</borderwidth>
627 </bsbObject>
628 <bsbObject version="2" type="BSBHSlider">
629 <objectName>OutGain</objectName>
630 <x>8</x>
631 <y>317</y>
632 <width>500</width>
633 <height>27</height>
634 <uuid>{8060c436-34f2-4247-9dc1-8c1a551bb6c6}</uuid>
635 <visible>true</visible>
636 <midichan>0</midichan>
637 <midicc>0</midicc>
638 <minimum>0.00000000</minimum>
639 <maximum>10.00000000</maximum>
640 <value>0.50000000</value>
641 <mode>lin</mode>
642 <mouseControl act="jump">continuous</mouseControl>
643 <resolution>-1.00000000</resolution>
644 <randomizable group="0">false</randomizable>
645 </bsbObject>
646 <bsbObject version="2" type="BSBDisplay">
647 <objectName>OutGain</objectName>
648 <x>448</x>
649 <y>338</y>
650 <width>60</width>
651 <height>30</height>
652 <uuid>{54cc0b6c-d8c5-41a7-96ae-7b54ef47ec42}</uuid>
653 <visible>true</visible>
654 <midichan>0</midichan>
655 <midicc>0</midicc>
656 <label>0.500</label>
657 <alignment>right</alignment>
658 <font>Liberation Sans</font>
659 <fontsize>9</fontsize>
660 <precision>3</precision>
661 <color>
662 <r>0</r>
663 <g>0</g>
664 <b>0</b>
665 </color>
666 <bgcolor mode="nobackground">
667 <r>255</r>
668 <g>255</g>
669 <b>255</b>
670 </bgcolor>
671 <bordermode>noborder</bordermode>
672 <borderradius>1</borderradius>
673 <borderwidth>1</borderwidth>
674 </bsbObject>
675 </bsbPanel>
676 <bsbPresets>
677 </bsbPresets>
678 <EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="true" loopStart="0" loopEnd="0"> </EventPanel>