;Written by Iain McCurdy, 2010 ; Modified for QuteCsound by René, January 2011. ; Thanks to Andres CABRERA for the mouse channels names. ; Tested on Ubuntu 10.04 with csound-float 5.13.0 and QuteCsound svn rev 817 with "Widgets are an independent window" ON. /* Mouse Bass ---------- This csd was originally written for use by someone who only had the use of a head-mouse for music performance. 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. 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). No clicking is required enabling better timing in performance. The GUI window needs to be in focus for this to work. The mouse relative position is given by the channels _MouseRelX and _MouseRelY. 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. Professional head mouse or iris tracking software can be very expensive and requires practice. iNavigate is a free option for Mac OS 10.5 if the user wants to experiment with this approach. */ ;Notes on modifications from original csd: ; No automatic rescale ; Replaced audio file by an audio generator ;Depending on your platform and distribution, you might need to enable displays using the --displays command line flag. ;my flags on Ubuntu: -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=null -m0 sr = 44100 ;SAMPLE RATE ksmps = 16 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO) 0dbfs = 1 ;MAXIMUM AMPLITUDE REGARDLESS OF BIT DEPTH instr 1 ;Boxes dimensions iwidth = 100 iheight = 100 ;Boxes positions ix1 = 350 ;C box iy1 = 50 ix2 = 490 ;G box iy2 = 110 ix3 = 610 ;D box iy3 = 220 ix4 = 650 ;A box iy4 = 350 ix5 = 610 ;E box iy5 = 480 ix6 = 490 ;B box iy6 = 600 ix7 = 350 ;Gb box iy7 = 650 ix8 = 220 ;Db box iy8 = 600 ix9 = 90 ;Ab box iy9 = 480 ix10 = 50 ;Eb box iy10 = 350 ix11 = 90 ;Bb box iy11 = 220 ix12 = 220 ;F box iy12 = 110 krelx invalue "_MouseRelX" krely invalue "_MouseRelY" ;DEFINE A MACRO FOR DETECTION OF MOUSE WITHIN EACH BOX - INPUTS FOR NUMBER AND PITCH (PCH FORMAT) #define NOTE_BOX_DETECT(N'PCH) # kinside$N init 0 if (ix$N <= krelx && krelx <= ix$N+iwidth && iy$N <= krely && krely <= iy$N+iheight) then kinside$N = 1 else kinside$N = 0 endif ktrig$N changed kinside$N ;CREATE A TRIGGER (MOMENTARY '1') IF MOUSE ENTERS OR LEAVES THIS BOX if ktrig$N=1 then ;IF MOUSE HAS JUST ENTERED OR LEFT THIS BOX... if kinside$N=1 then ;IF MOUSE HAS JUST ENTERED THIS BOX... event "i", 2, 0, 5, $PCH ;CREATE A 5 SECOND NOTE EVENT FOR INSTR 2. PASS PITCH VIA p4 elseif kinside$N=0 then ;OR ELSE IF MOUSE HAS JUST LEFT THIS BOX turnoff2 2, 0, 1 ;TURNOFF INSTRUMENT 2 endif ;END OF CONDITIONAL BRANCHING endif ;END OF CONDITIONAL BRANCHING # ;EXECUTE MACRO FOR EACH BOX... $NOTE_BOX_DETECT(1'8.00) $NOTE_BOX_DETECT(2'7.07) $NOTE_BOX_DETECT(3'8.02) $NOTE_BOX_DETECT(4'7.09) $NOTE_BOX_DETECT(5'8.04) $NOTE_BOX_DETECT(6'7.11) $NOTE_BOX_DETECT(7'8.06) $NOTE_BOX_DETECT(8'8.01) $NOTE_BOX_DETECT(9'7.08) $NOTE_BOX_DETECT(10'8.03) $NOTE_BOX_DETECT(11'7.10) $NOTE_BOX_DETECT(12'7.05) endin instr 2 ;BASS aenv linsegr 1,0.05,0 ;AMPLITUDE ENVELOPE (BASICALLY JUST THE RELEASE STAGE) icps = cpspch(p4) k1 linseg 0.55, .2, 0.2, 0, 0.2 k2 linseg 4, .2, 2, 0, 2 a2 oscil k2, icps/2, 1 a1 oscil k1, icps/2*a2, 1 outs a1*aenv, a1*aenv endin f 1 0 1024 10 1 ;sin table ;INSTR | START | DURATION i 1 0 3600 ;MOUSE POSITION DETECTION, PLAYS A NOTE FOR 1 HOUR 72 179 400 200 true 255 255 255 21 47 189 51 {8696498c-ea5a-4002-80e2-b73942e10bb0} true 0 0 left Liberation Sans 24 3 0 0 0 255 255 255 noborder 1 1 350 50 100 100 {4ff1845d-670e-4f5a-ad22-f0da34a0c44b} true 0 0 center Liberation Sans 24 3 0 0 0 100 255 255 noborder 1 1 490 110 100 100 {b37c8e33-54bb-4f53-83b5-6b83cc09e6ae} true 0 0 center Liberation Sans 24 3 0 0 0 255 200 55 noborder 1 1 610 220 100 100 {2fc81349-9dc1-4bd5-894b-ec2bfbd045e4} true 0 0 center Liberation Sans 24 3 0 0 0 200 255 200 noborder 1 1 650 350 100 100 {cfab6bf8-f61d-4c40-9e90-ae2ad4825b4b} true 0 0 center Liberation Sans 24 3 0 0 0 100 100 255 noborder 1 1 610 480 100 100 {2bdfd76e-2158-46b1-83f9-03daab95bb48} true 0 0 center Liberation Sans 24 3 0 0 0 105 200 55 noborder 1 1 490 600 100 100 {1b83334e-ab1b-4eb0-998c-0bda40dd8478} true 0 0 center Liberation Sans 24 3 0 0 0 255 50 50 noborder 1 1 350 650 100 100 {fddbed6f-a446-4fbe-89fc-c9c644a5667b} true 0 0 center Liberation Sans 24 3 0 0 0 255 100 255 noborder 1 1 220 600 100 100 {5ddf806c-247b-4151-bcfd-42a82748e7bd} true 0 0 center Liberation Sans 24 3 0 0 0 55 200 255 noborder 1 1 90 480 100 100 {f282639e-421b-4715-9c45-99f21b1f84f8} true 0 0 center Liberation Sans 24 3 0 0 0 255 200 55 noborder 1 1 50 350 100 100 {1f07ff1d-0a47-40af-9185-de05106ee1af} true 0 0 center Liberation Sans 24 3 0 0 0 255 100 100 noborder 1 1 90 220 100 100 {7252cfc2-94e0-4989-8477-03aeb8979ab4} true 0 0 center Liberation Sans 24 3 0 0 0 0 200 100 noborder 1 1 220 110 100 100 {27944727-f486-4946-9ec7-372383e51123} true 0 0 center Liberation Sans 24 3 0 0 0 150 0 255 noborder 1 1 _MouseRelX 122 105 59 25 {eac032fa-9eec-4268-81a6-f6eb875d9517} true 0 0 left DejaVu Sans 10 3 0 0 0 255 255 255 border 1 1 _MouseRelY 122 133 59 25 {e527159b-e21a-4f35-b4e3-525b6d4cf7b1} true 0 0 left DejaVu Sans 10 3 0 0 0 255 255 255 border 1 1 2 105 120 25 {55616170-a887-428f-ac65-3e612102334f} true 0 0 right DejaVu Sans 10 3 0 0 0 255 255 255 noborder 1 1 2 133 120 25 {93bd69f1-40e2-4832-a787-a01f4a9f7de5} true 0 0 right DejaVu Sans 10 3 0 0 0 255 255 255 noborder 1 1