Debian Codegraph @

src/Examples/McCurdy Collection/Mouse/MouseBass_Synth.csd

raw
1 ;Written by Iain McCurdy, 2010
2
3 ; Modified for QuteCsound by René, January 2011.
4 ; Thanks to Andres CABRERA for the mouse channels names.
5
6 ; Tested on Ubuntu 10.04 with csound-float 5.13.0 and QuteCsound svn rev 817 with "Widgets are an independent window" ON.
7
8
9 /*
10 Mouse Bass
11 ----------
12 This csd was originally written for use by someone who only had the use of a head-mouse for music performance.
13 The notes of the chromatic scale are arranged in coloured boxes according to the circle of fifths as this is perhaps the arrangement that is most useful to a bass guitarist.
14 If the mouse enters one of the boxes the note indicated by its label is played. If the mouse leaves the box the note is stopped (with a short release segment).
15 No clicking is required enabling better timing in performance. The GUI window needs to be in focus for this to work.
16 The mouse relative position is given by the channels _MouseRelX and _MouseRelY.
17
18 If the windows need to be resized, for example to accomodate use on a netbook, it is mandatory to manually update the values of boxes dimensions and positions in the csd file.
19
20 Professional head mouse or iris tracking software can be very expensive and requires practice.
21 iNavigate is a free option for Mac OS 10.5 if the user wants to experiment with this approach.
22 */
23
24
25 ;Notes on modifications from original csd:
26 ; No automatic rescale
27 ; Replaced audio file by an audio generator
28
29
30 ;Depending on your platform and distribution, you might need to enable displays using the --displays command line flag.
31 ;my flags on Ubuntu: -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=null -m0
32 <CsoundSynthesizer>
33 <CsOptions>
34
35 </CsOptions>
36 <CsInstruments>
37 sr = 44100 ;SAMPLE RATE
38 ksmps = 16 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
39 nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
40 0dbfs = 1 ;MAXIMUM AMPLITUDE REGARDLESS OF BIT DEPTH
41
42
43 instr 1
44 ;Boxes dimensions
45 iwidth = 100
46 iheight = 100
47
48 ;Boxes positions
49 ix1 = 350 ;C box
50 iy1 = 50
51
52 ix2 = 490 ;G box
53 iy2 = 110
54
55 ix3 = 610 ;D box
56 iy3 = 220
57
58 ix4 = 650 ;A box
59 iy4 = 350
60
61 ix5 = 610 ;E box
62 iy5 = 480
63
64 ix6 = 490 ;B box
65 iy6 = 600
66
67 ix7 = 350 ;Gb box
68 iy7 = 650
69
70 ix8 = 220 ;Db box
71 iy8 = 600
72
73 ix9 = 90 ;Ab box
74 iy9 = 480
75
76 ix10 = 50 ;Eb box
77 iy10 = 350
78
79 ix11 = 90 ;Bb box
80 iy11 = 220
81
82 ix12 = 220 ;F box
83 iy12 = 110
84
85 krelx invalue "_MouseRelX"
86 krely invalue "_MouseRelY"
87
88 ;DEFINE A MACRO FOR DETECTION OF MOUSE WITHIN EACH BOX - INPUTS FOR NUMBER AND PITCH (PCH FORMAT)
89 #define NOTE_BOX_DETECT(N'PCH)
90 #
91 kinside$N init 0
92 if (ix$N <= krelx && krelx <= ix$N+iwidth && iy$N <= krely && krely <= iy$N+iheight) then
93 kinside$N = 1
94 else
95 kinside$N = 0
96 endif
97
98 ktrig$N changed kinside$N ;CREATE A TRIGGER (MOMENTARY '1') IF MOUSE ENTERS OR LEAVES THIS BOX
99 if ktrig$N=1 then ;IF MOUSE HAS JUST ENTERED OR LEFT THIS BOX...
100 if kinside$N=1 then ;IF MOUSE HAS JUST ENTERED THIS BOX...
101 event "i", 2, 0, 5, $PCH ;CREATE A 5 SECOND NOTE EVENT FOR INSTR 2. PASS PITCH VIA p4
102 elseif kinside$N=0 then ;OR ELSE IF MOUSE HAS JUST LEFT THIS BOX
103 turnoff2 2, 0, 1 ;TURNOFF INSTRUMENT 2
104 endif ;END OF CONDITIONAL BRANCHING
105 endif ;END OF CONDITIONAL BRANCHING
106 #
107
108 ;EXECUTE MACRO FOR EACH BOX...
109 $NOTE_BOX_DETECT(1'8.00)
110 $NOTE_BOX_DETECT(2'7.07)
111 $NOTE_BOX_DETECT(3'8.02)
112 $NOTE_BOX_DETECT(4'7.09)
113 $NOTE_BOX_DETECT(5'8.04)
114 $NOTE_BOX_DETECT(6'7.11)
115 $NOTE_BOX_DETECT(7'8.06)
116 $NOTE_BOX_DETECT(8'8.01)
117 $NOTE_BOX_DETECT(9'7.08)
118 $NOTE_BOX_DETECT(10'8.03)
119 $NOTE_BOX_DETECT(11'7.10)
120 $NOTE_BOX_DETECT(12'7.05)
121 endin
122
123 instr 2 ;BASS
124 aenv linsegr 1,0.05,0 ;AMPLITUDE ENVELOPE (BASICALLY JUST THE RELEASE STAGE)
125
126 icps = cpspch(p4)
127
128 k1 linseg 0.55, .2, 0.2, 0, 0.2
129 k2 linseg 4, .2, 2, 0, 2
130
131 a2 oscil k2, icps/2, 1
132 a1 oscil k1, icps/2*a2, 1
133
134 outs a1*aenv, a1*aenv
135 endin
136 </CsInstruments>
137 <CsScore>
138 f 1 0 1024 10 1 ;sin table
139
140 ;INSTR | START | DURATION
141 i 1 0 3600 ;MOUSE POSITION DETECTION, PLAYS A NOTE FOR 1 HOUR
142 </CsScore>
143 </CsoundSynthesizer>
144
145 <bsbPanel>
146 <label>Widgets</label>
147 <objectName/>
148 <x>72</x>
149 <y>179</y>
150 <width>400</width>
151 <height>200</height>
152 <visible>true</visible>
153 <uuid/>
154 <bgcolor mode="background">
155 <r>255</r>
156 <g>255</g>
157 <b>255</b>
158 </bgcolor>
159 <bsbObject version="2" type="BSBLabel">
160 <objectName/>
161 <x>21</x>
162 <y>47</y>
163 <width>189</width>
164 <height>51</height>
165 <uuid>{8696498c-ea5a-4002-80e2-b73942e10bb0}</uuid>
166 <visible>true</visible>
167 <midichan>0</midichan>
168 <midicc>0</midicc>
169 <label>Mouse Bass</label>
170 <alignment>left</alignment>
171 <font>Liberation Sans</font>
172 <fontsize>24</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="BSBLabel">
189 <objectName/>
190 <x>350</x>
191 <y>50</y>
192 <width>100</width>
193 <height>100</height>
194 <uuid>{4ff1845d-670e-4f5a-ad22-f0da34a0c44b}</uuid>
195 <visible>true</visible>
196 <midichan>0</midichan>
197 <midicc>0</midicc>
198 <label>C</label>
199 <alignment>center</alignment>
200 <font>Liberation Sans</font>
201 <fontsize>24</fontsize>
202 <precision>3</precision>
203 <color>
204 <r>0</r>
205 <g>0</g>
206 <b>0</b>
207 </color>
208 <bgcolor mode="background">
209 <r>100</r>
210 <g>255</g>
211 <b>255</b>
212 </bgcolor>
213 <bordermode>noborder</bordermode>
214 <borderradius>1</borderradius>
215 <borderwidth>1</borderwidth>
216 </bsbObject>
217 <bsbObject version="2" type="BSBLabel">
218 <objectName/>
219 <x>490</x>
220 <y>110</y>
221 <width>100</width>
222 <height>100</height>
223 <uuid>{b37c8e33-54bb-4f53-83b5-6b83cc09e6ae}</uuid>
224 <visible>true</visible>
225 <midichan>0</midichan>
226 <midicc>0</midicc>
227 <label>G</label>
228 <alignment>center</alignment>
229 <font>Liberation Sans</font>
230 <fontsize>24</fontsize>
231 <precision>3</precision>
232 <color>
233 <r>0</r>
234 <g>0</g>
235 <b>0</b>
236 </color>
237 <bgcolor mode="background">
238 <r>255</r>
239 <g>200</g>
240 <b>55</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>610</x>
249 <y>220</y>
250 <width>100</width>
251 <height>100</height>
252 <uuid>{2fc81349-9dc1-4bd5-894b-ec2bfbd045e4}</uuid>
253 <visible>true</visible>
254 <midichan>0</midichan>
255 <midicc>0</midicc>
256 <label>D</label>
257 <alignment>center</alignment>
258 <font>Liberation Sans</font>
259 <fontsize>24</fontsize>
260 <precision>3</precision>
261 <color>
262 <r>0</r>
263 <g>0</g>
264 <b>0</b>
265 </color>
266 <bgcolor mode="background">
267 <r>200</r>
268 <g>255</g>
269 <b>200</b>
270 </bgcolor>
271 <bordermode>noborder</bordermode>
272 <borderradius>1</borderradius>
273 <borderwidth>1</borderwidth>
274 </bsbObject>
275 <bsbObject version="2" type="BSBLabel">
276 <objectName/>
277 <x>650</x>
278 <y>350</y>
279 <width>100</width>
280 <height>100</height>
281 <uuid>{cfab6bf8-f61d-4c40-9e90-ae2ad4825b4b}</uuid>
282 <visible>true</visible>
283 <midichan>0</midichan>
284 <midicc>0</midicc>
285 <label>A</label>
286 <alignment>center</alignment>
287 <font>Liberation Sans</font>
288 <fontsize>24</fontsize>
289 <precision>3</precision>
290 <color>
291 <r>0</r>
292 <g>0</g>
293 <b>0</b>
294 </color>
295 <bgcolor mode="background">
296 <r>100</r>
297 <g>100</g>
298 <b>255</b>
299 </bgcolor>
300 <bordermode>noborder</bordermode>
301 <borderradius>1</borderradius>
302 <borderwidth>1</borderwidth>
303 </bsbObject>
304 <bsbObject version="2" type="BSBLabel">
305 <objectName/>
306 <x>610</x>
307 <y>480</y>
308 <width>100</width>
309 <height>100</height>
310 <uuid>{2bdfd76e-2158-46b1-83f9-03daab95bb48}</uuid>
311 <visible>true</visible>
312 <midichan>0</midichan>
313 <midicc>0</midicc>
314 <label>E</label>
315 <alignment>center</alignment>
316 <font>Liberation Sans</font>
317 <fontsize>24</fontsize>
318 <precision>3</precision>
319 <color>
320 <r>0</r>
321 <g>0</g>
322 <b>0</b>
323 </color>
324 <bgcolor mode="background">
325 <r>105</r>
326 <g>200</g>
327 <b>55</b>
328 </bgcolor>
329 <bordermode>noborder</bordermode>
330 <borderradius>1</borderradius>
331 <borderwidth>1</borderwidth>
332 </bsbObject>
333 <bsbObject version="2" type="BSBLabel">
334 <objectName/>
335 <x>490</x>
336 <y>600</y>
337 <width>100</width>
338 <height>100</height>
339 <uuid>{1b83334e-ab1b-4eb0-998c-0bda40dd8478}</uuid>
340 <visible>true</visible>
341 <midichan>0</midichan>
342 <midicc>0</midicc>
343 <label>B</label>
344 <alignment>center</alignment>
345 <font>Liberation Sans</font>
346 <fontsize>24</fontsize>
347 <precision>3</precision>
348 <color>
349 <r>0</r>
350 <g>0</g>
351 <b>0</b>
352 </color>
353 <bgcolor mode="background">
354 <r>255</r>
355 <g>50</g>
356 <b>50</b>
357 </bgcolor>
358 <bordermode>noborder</bordermode>
359 <borderradius>1</borderradius>
360 <borderwidth>1</borderwidth>
361 </bsbObject>
362 <bsbObject version="2" type="BSBLabel">
363 <objectName/>
364 <x>350</x>
365 <y>650</y>
366 <width>100</width>
367 <height>100</height>
368 <uuid>{fddbed6f-a446-4fbe-89fc-c9c644a5667b}</uuid>
369 <visible>true</visible>
370 <midichan>0</midichan>
371 <midicc>0</midicc>
372 <label>Gb</label>
373 <alignment>center</alignment>
374 <font>Liberation Sans</font>
375 <fontsize>24</fontsize>
376 <precision>3</precision>
377 <color>
378 <r>0</r>
379 <g>0</g>
380 <b>0</b>
381 </color>
382 <bgcolor mode="background">
383 <r>255</r>
384 <g>100</g>
385 <b>255</b>
386 </bgcolor>
387 <bordermode>noborder</bordermode>
388 <borderradius>1</borderradius>
389 <borderwidth>1</borderwidth>
390 </bsbObject>
391 <bsbObject version="2" type="BSBLabel">
392 <objectName/>
393 <x>220</x>
394 <y>600</y>
395 <width>100</width>
396 <height>100</height>
397 <uuid>{5ddf806c-247b-4151-bcfd-42a82748e7bd}</uuid>
398 <visible>true</visible>
399 <midichan>0</midichan>
400 <midicc>0</midicc>
401 <label>Db</label>
402 <alignment>center</alignment>
403 <font>Liberation Sans</font>
404 <fontsize>24</fontsize>
405 <precision>3</precision>
406 <color>
407 <r>0</r>
408 <g>0</g>
409 <b>0</b>
410 </color>
411 <bgcolor mode="background">
412 <r>55</r>
413 <g>200</g>
414 <b>255</b>
415 </bgcolor>
416 <bordermode>noborder</bordermode>
417 <borderradius>1</borderradius>
418 <borderwidth>1</borderwidth>
419 </bsbObject>
420 <bsbObject version="2" type="BSBLabel">
421 <objectName/>
422 <x>90</x>
423 <y>480</y>
424 <width>100</width>
425 <height>100</height>
426 <uuid>{f282639e-421b-4715-9c45-99f21b1f84f8}</uuid>
427 <visible>true</visible>
428 <midichan>0</midichan>
429 <midicc>0</midicc>
430 <label>Ab</label>
431 <alignment>center</alignment>
432 <font>Liberation Sans</font>
433 <fontsize>24</fontsize>
434 <precision>3</precision>
435 <color>
436 <r>0</r>
437 <g>0</g>
438 <b>0</b>
439 </color>
440 <bgcolor mode="background">
441 <r>255</r>
442 <g>200</g>
443 <b>55</b>
444 </bgcolor>
445 <bordermode>noborder</bordermode>
446 <borderradius>1</borderradius>
447 <borderwidth>1</borderwidth>
448 </bsbObject>
449 <bsbObject version="2" type="BSBLabel">
450 <objectName/>
451 <x>50</x>
452 <y>350</y>
453 <width>100</width>
454 <height>100</height>
455 <uuid>{1f07ff1d-0a47-40af-9185-de05106ee1af}</uuid>
456 <visible>true</visible>
457 <midichan>0</midichan>
458 <midicc>0</midicc>
459 <label>Eb</label>
460 <alignment>center</alignment>
461 <font>Liberation Sans</font>
462 <fontsize>24</fontsize>
463 <precision>3</precision>
464 <color>
465 <r>0</r>
466 <g>0</g>
467 <b>0</b>
468 </color>
469 <bgcolor mode="background">
470 <r>255</r>
471 <g>100</g>
472 <b>100</b>
473 </bgcolor>
474 <bordermode>noborder</bordermode>
475 <borderradius>1</borderradius>
476 <borderwidth>1</borderwidth>
477 </bsbObject>
478 <bsbObject version="2" type="BSBLabel">
479 <objectName/>
480 <x>90</x>
481 <y>220</y>
482 <width>100</width>
483 <height>100</height>
484 <uuid>{7252cfc2-94e0-4989-8477-03aeb8979ab4}</uuid>
485 <visible>true</visible>
486 <midichan>0</midichan>
487 <midicc>0</midicc>
488 <label>Bb</label>
489 <alignment>center</alignment>
490 <font>Liberation Sans</font>
491 <fontsize>24</fontsize>
492 <precision>3</precision>
493 <color>
494 <r>0</r>
495 <g>0</g>
496 <b>0</b>
497 </color>
498 <bgcolor mode="background">
499 <r>0</r>
500 <g>200</g>
501 <b>100</b>
502 </bgcolor>
503 <bordermode>noborder</bordermode>
504 <borderradius>1</borderradius>
505 <borderwidth>1</borderwidth>
506 </bsbObject>
507 <bsbObject version="2" type="BSBLabel">
508 <objectName/>
509 <x>220</x>
510 <y>110</y>
511 <width>100</width>
512 <height>100</height>
513 <uuid>{27944727-f486-4946-9ec7-372383e51123}</uuid>
514 <visible>true</visible>
515 <midichan>0</midichan>
516 <midicc>0</midicc>
517 <label>F</label>
518 <alignment>center</alignment>
519 <font>Liberation Sans</font>
520 <fontsize>24</fontsize>
521 <precision>3</precision>
522 <color>
523 <r>0</r>
524 <g>0</g>
525 <b>0</b>
526 </color>
527 <bgcolor mode="background">
528 <r>150</r>
529 <g>0</g>
530 <b>255</b>
531 </bgcolor>
532 <bordermode>noborder</bordermode>
533 <borderradius>1</borderradius>
534 <borderwidth>1</borderwidth>
535 </bsbObject>
536 <bsbObject version="2" type="BSBDisplay">
537 <objectName>_MouseRelX</objectName>
538 <x>122</x>
539 <y>105</y>
540 <width>59</width>
541 <height>25</height>
542 <uuid>{eac032fa-9eec-4268-81a6-f6eb875d9517}</uuid>
543 <visible>true</visible>
544 <midichan>0</midichan>
545 <midicc>0</midicc>
546 <label>0.000</label>
547 <alignment>left</alignment>
548 <font>DejaVu Sans</font>
549 <fontsize>10</fontsize>
550 <precision>3</precision>
551 <color>
552 <r>0</r>
553 <g>0</g>
554 <b>0</b>
555 </color>
556 <bgcolor mode="background">
557 <r>255</r>
558 <g>255</g>
559 <b>255</b>
560 </bgcolor>
561 <bordermode>border</bordermode>
562 <borderradius>1</borderradius>
563 <borderwidth>1</borderwidth>
564 </bsbObject>
565 <bsbObject version="2" type="BSBDisplay">
566 <objectName>_MouseRelY</objectName>
567 <x>122</x>
568 <y>133</y>
569 <width>59</width>
570 <height>25</height>
571 <uuid>{e527159b-e21a-4f35-b4e3-525b6d4cf7b1}</uuid>
572 <visible>true</visible>
573 <midichan>0</midichan>
574 <midicc>0</midicc>
575 <label>0.000</label>
576 <alignment>left</alignment>
577 <font>DejaVu Sans</font>
578 <fontsize>10</fontsize>
579 <precision>3</precision>
580 <color>
581 <r>0</r>
582 <g>0</g>
583 <b>0</b>
584 </color>
585 <bgcolor mode="background">
586 <r>255</r>
587 <g>255</g>
588 <b>255</b>
589 </bgcolor>
590 <bordermode>border</bordermode>
591 <borderradius>1</borderradius>
592 <borderwidth>1</borderwidth>
593 </bsbObject>
594 <bsbObject version="2" type="BSBLabel">
595 <objectName/>
596 <x>2</x>
597 <y>105</y>
598 <width>120</width>
599 <height>25</height>
600 <uuid>{55616170-a887-428f-ac65-3e612102334f}</uuid>
601 <visible>true</visible>
602 <midichan>0</midichan>
603 <midicc>0</midicc>
604 <label>Mouse Relative X</label>
605 <alignment>right</alignment>
606 <font>DejaVu Sans</font>
607 <fontsize>10</fontsize>
608 <precision>3</precision>
609 <color>
610 <r>0</r>
611 <g>0</g>
612 <b>0</b>
613 </color>
614 <bgcolor mode="nobackground">
615 <r>255</r>
616 <g>255</g>
617 <b>255</b>
618 </bgcolor>
619 <bordermode>noborder</bordermode>
620 <borderradius>1</borderradius>
621 <borderwidth>1</borderwidth>
622 </bsbObject>
623 <bsbObject version="2" type="BSBLabel">
624 <objectName/>
625 <x>2</x>
626 <y>133</y>
627 <width>120</width>
628 <height>25</height>
629 <uuid>{93bd69f1-40e2-4832-a787-a01f4a9f7de5}</uuid>
630 <visible>true</visible>
631 <midichan>0</midichan>
632 <midicc>0</midicc>
633 <label>Mouse Relative Y</label>
634 <alignment>right</alignment>
635 <font>DejaVu Sans</font>
636 <fontsize>10</fontsize>
637 <precision>3</precision>
638 <color>
639 <r>0</r>
640 <g>0</g>
641 <b>0</b>
642 </color>
643 <bgcolor mode="nobackground">
644 <r>255</r>
645 <g>255</g>
646 <b>255</b>
647 </bgcolor>
648 <bordermode>noborder</bordermode>
649 <borderradius>1</borderradius>
650 <borderwidth>1</borderwidth>
651 </bsbObject>
652 </bsbPanel>
653 <bsbPresets>
654 </bsbPresets>
655 <EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="true" loopStart="0" loopEnd="0"> </EventPanel>