;Written by Iain McCurdy, 2010 ;Modified for QuteCsound by René, February 2011 ;Tested on Ubuntu 10.04 with csound-float 5.13.0 and QuteCsound svn rev 817 ;Notes on modifications from original csd: ; Add table for exp slider /* Rhythmicon ------------------------------------------------------------------------------------------------------------------------ This example is an implmentation of the 'Rhythmicon', an instrument designed an built by the inventor Leon Theremin and commissioned by the composer Henry Cowell. This instrument presented users with a short 17 note keyboard. The first 16 notes produced a sequence of pitches the fundamentals of which followed a harmonic series based on on the pitch produced by the first note. Therefore if the first note played 100 Hz, the second played 200 Hz, the third 300 Hz, the fourth 400 Hz etc. Each note sounded as a rhythmical pulse rising in speed up the keyboard. The ratios of these pulsation speeds ascending the keyboard also followed the ratios of the harmonic series therefore the second key played a pulse twice that of the first, the third three time that of the first and so on. The 17th note produced no sound but instead acted as a switch that added a syncopation effect (I am unsure as to exactly how this was implemented so I have omitted it from my instrument). More information on the Rhythmicon can be found by searching on the internet. In my example the fundamental rate of pulsation defaults to 0.5 Hz. The user can modulate this using the 'Rate' slider. This example can be played either from a MIDI keyboard or by using the on-screen buttons. The numbers on the GUI buttons indicate the rhythmic subdivisions of that note with respect to the pulsation rate of the first note. These numbers therefore also indicate the ratios of frequencies of the tones they produce. Two methods of tone generation are provided which can be chosen using the 'VOICE' radio button selector. Firstly a plucked string physical model can be used (although certain tuning anomalies may be encountered). The reflectivity of the fixings at either end of the string (damping) can be changed using the 'Pluck Reflection' slider. Secondly a VCO can be employed. Waveform, filter cutoff and resonance can be modulated here. The frequency of the lowest tone that the Rhythmicon will produce can be set using the 'Fundamental Freq.' slider. The user can also define the lowest MIDI note that will activate the Rhythmicon with the 'Starting Note' counter. */ ;my flags on Ubuntu: -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=alsa -Ma -m0 sr = 44100 ;SAMPLE RATE ksmps = 100 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO) 0dbfs = 1 ;MAXIMUM AMPLITUDE REGARDLESS OF BIT DEPTH gisine ftgen 0,0,131072,10,1 giExp1 ftgen 0, 0, 129, -25, 0, 20.0, 128, 2000.0 ;TABLE FOR EXP SLIDER giExp2 ftgen 0, 0, 129, -25, 0, 100.0, 128, 10000.0 ;TABLE FOR EXP SLIDER instr 10 ;GUI ktrig metro 10 if (ktrig == 1) then gkrate invalue "Fund_Rate" kfund invalue "Fund_Pitch" gkfund tablei kfund, giExp1, 1 outvalue "Fund_Pitch_Value", gkfund gkgain invalue "Gain" ;100, 10000, -1 gkdur invalue "Note_Dur" gkrefl invalue "Pluck_Reflection" gkVCOres invalue "VCO_Resonance" kVCOcf invalue "VCO_Cutoff" gkVCOcf tablei kVCOcf, giExp2, 1 outvalue "VCO_Cutoff_Value", gkVCOcf gkStartNote invalue "StartNote" gkvoice invalue "Voice" gkwave invalue "Wave" endif endin instr 1 ;MIDI inum notnum ;READ IN MIDI NOTE NUMBER iStartNote init i(gkStartNote) ;STARTING NOTE FOR THE RHYTHMICON if inum<=iStartNote then ;IF A NOTE BELOW THE STARTING NOTE IS PLAYED... turnoff ;...IT WILL BE IGNORED AND THIS INSTRUMENT WILL BE TURNED OFF endif ;END OF CONDITIONAL BRANCHING inum = inum - iStartNote ;CREATE A NEW VALUE FOR inum. I.E. COUNTING BEGINS AT RHYTHMICON START NOTE FROM 1 krate = gkrate * inum ;RATE IS A PRODUCT OF RHYTHMICON NOTE COUNT AND 'RATE' SLIDER ktrigger metro krate ;GENERATE A METRONOME TRIGGER FOR THIS NOTE schedkwhen ktrigger, 0, 0, 30, 0, gkdur, gkfund * inum ;SCHEDULE NOTE PULSE (INSTR 30) endin ;DEFINE A MACRO FOR A GUI TRIGGERED NOTE #define GUI_NOTE(I) # instr $I inum = p4 ;READ p4 VALUE krate = gkrate * inum ;RATE IS A PRODUCT OF RHYTHMICON NOTE COUNT AND 'RATE' SLIDER ktrigger metro krate ;GENERATE A METRONOME TRIGGER FOR THIS NOTE schedkwhen ktrigger, 0, 0, 30, 0, gkdur, gkfund * inum ;SCHEDULE NOTE PULSE (INSTR 30) endin # ;CREATE INSTRUMENTS 11-26 USING A MACRO EXPANSION OF 'GUI_NOTE' WITH ARGUMENTS $GUI_NOTE(11) $GUI_NOTE(12) $GUI_NOTE(13) $GUI_NOTE(14) $GUI_NOTE(15) $GUI_NOTE(16) $GUI_NOTE(17) $GUI_NOTE(18) $GUI_NOTE(19) $GUI_NOTE(20) $GUI_NOTE(21) $GUI_NOTE(22) $GUI_NOTE(23) $GUI_NOTE(24) $GUI_NOTE(25) $GUI_NOTE(26) instr 30 ;SOUND PRODUCING INSTRUMENT aenv linseg 0,0.005,1, p3-0.005, 0 ;AMPLITUDE ENVELOPE ipick init 0.1 ;PICK-UP POSITION iplk random 0.85,0.98 ;PLUCK POSITION iamp init 1 ;AMPLITUDE if gkvoice=0 then asig wgpluck2 iplk, 1, p4, ipick, gkrefl ;PLUCKED STRING PHYSICAL MODEL asig = asig * aenv * gkgain ;SCALE AUDIO SIGNAL USING AMPLITUDE ENVELOPE AND OUTPUT GAIN SLIDER elseif gkvoice=1 then asig vco aenv * i(gkgain), p4, i(gkwave)+1, 0.5, gisine kcf expon i(gkVCOcf),p3,20 asig moogvcf asig, kcf, gkVCOres endif outs asig, asig ;SEND AUDIO TO OUTPUTS endin i 10 0 3600 ;GUI 874 233 518 642 true 241 226 185 3 2 512 640 {049f4dd4-ff71-4d6d-9157-43c84efad8a4} true 0 0 center Liberation Sans 18 3 255 255 255 5 27 150 border 5 2 8 250 502 178 {11faf86e-aa61-4c25-b9cc-b5e7a1d6b5d2} true 0 0 StartNote 50 215 60 26 {bc5a9d05-aa02-4152-98d1-26cf9c89309d} true 0 0 center Liberation Sans 12 0 0 0 255 255 255 1.00000000 0 127 false 59 8 166 200 30 {b6afbe1e-677c-44a6-ba84-4c32dc21b0a7} true 0 0 left Liberation Sans 10 3 255 255 255 255 255 255 noborder 1 1 Gain 8 143 500 27 {859d1ded-b337-4ee7-ac9b-48a1b5f77d16} true 0 0 0.00000000 1.00000000 0.29200000 lin continuous -1.00000000 false Gain 448 166 60 30 {95f6cb02-77ec-46fe-876b-a93efac3c5e5} true 0 0 right Liberation Sans 9 3 255 255 255 255 255 255 noborder 1 1 8 113 180 30 {7fd47947-fd0d-4964-85e5-682fed1916c7} true 0 0 left Liberation Sans 10 3 255 255 255 255 255 255 noborder 1 1 Fund_Pitch 8 90 500 27 {475cdd64-a4ca-4ebc-a000-90448e932478} true 0 0 0.00000000 1.00000000 0.27000000 lin continuous -1.00000000 false Fund_Pitch_Value 448 113 60 30 {dc75acc2-c015-4b8d-8fb2-467b9fb96d42} true 0 0 right Liberation Sans 9 3 255 255 255 255 255 255 noborder 1 1 8 60 200 30 {3ebc1139-1fdb-48dc-9150-49ee8dfdbd4a} true 0 0 left Liberation Sans 10 3 255 255 255 255 255 255 noborder 1 1 Fund_Rate 8 37 500 27 {e37b61b7-9175-45bf-8dc5-8ff8612545a2} true 0 0 0.10000000 2.00000000 0.50280000 lin continuous -1.00000000 false Fund_Rate 448 60 60 30 {e54486c5-f9aa-4d0e-9a67-6506dae3c790} true 0 0 right Liberation Sans 9 3 255 255 255 255 255 255 noborder 1 1 7 191 123 30 {4efe17ef-0071-418f-a4b2-30d8d3309eae} true 0 0 left Liberation Sans 10 3 255 255 255 255 255 255 noborder 1 1 158 219 200 30 {994b6a17-546e-4319-9b86-bb6f0cee081d} true 0 0 left Liberation Sans 10 3 255 255 255 255 255 255 noborder 1 1 Note_Dur 158 196 350 27 {cf15ae28-0472-4a21-8382-d6af83dd0a56} true 0 0 0.10000000 3.00000000 1.00314286 lin continuous -1.00000000 false Note_Dur 448 218 60 30 {cf8351fc-2960-4245-8559-b6b4e952f379} true 0 0 right Liberation Sans 9 3 255 255 255 255 255 255 noborder 1 1 Voice 106 444 80 30 {39794b17-c7ed-43ac-aa8b-34f01d131983} true 0 0 Pluck 0 VCO 1 0 false Wave 309 444 80 30 {a5a9d02b-d2d7-430b-8bc1-5e86ae9c98f5} true 0 0 Saw 0 Square 1 Tri 2 0 false 24 444 80 30 {887d940f-1739-4ff2-bc73-c29804145881} true 0 0 right Liberation Sans 10 3 255 255 255 255 255 255 noborder 1 1 227 444 80 30 {ac89d217-b801-48a4-8870-61ece5ddada7} true 0 0 right Liberation Sans 10 3 255 255 255 255 255 255 noborder 1 1 8 612 200 30 {37e632ae-42ea-478e-b426-bd3192d4412f} true 0 0 left Liberation Sans 10 3 255 255 255 255 255 255 noborder 1 1 VCO_Cutoff 8 589 500 27 {6447a9dd-b5c1-48c1-b1f4-244014495b21} true 0 0 0.00000000 1.00000000 0.60600000 lin continuous -1.00000000 false VCO_Cutoff_Value 448 612 60 30 {c4adb2be-24a8-4c1f-a688-a6275b926a32} true 0 0 right Liberation Sans 9 3 255 255 255 255 255 255 noborder 1 1 8 559 180 30 {9816b929-aa80-4ced-be9f-6ee419fa0663} true 0 0 left Liberation Sans 10 3 255 255 255 255 255 255 noborder 1 1 VCO_Resonance 8 536 500 27 {c9b039b8-50e9-42db-a1e7-785ebfdcbeff} true 0 0 0.00000000 1.00000000 0.10200000 lin continuous -1.00000000 false VCO_Resonance 448 559 60 30 {7096a5c3-3446-418d-b80f-c0697d8d07a1} true 0 0 right Liberation Sans 9 3 255 255 255 255 255 255 noborder 1 1 8 506 200 30 {cfb56f63-67b6-486f-acd0-8dc64562adab} true 0 0 left Liberation Sans 10 3 255 255 255 255 255 255 noborder 1 1 Pluck_Reflection 8 483 500 27 {56370972-f91b-4314-a6e7-ba20c7a70350} true 0 0 0.00100000 0.99900000 0.37425200 lin continuous -1.00000000 false Pluck_Reflection 448 506 60 30 {1f14eb88-0115-4928-90fa-7e1074b5b48a} true 0 0 right Liberation Sans 9 3 255 255 255 255 255 255 noborder 1 1 66 341 40 80 {a6aa45c5-a625-4d3b-a423-a71788f7ca80} true 0 0 event 1.00000000 1 / i 11 0 -1 1 true false 106 341 40 80 {7f9fcc69-c74e-464e-9cf1-7eb600cec1f7} true 0 0 event 1.00000000 3 / i 13 0 -1 3 true false 146 341 40 80 {0072a3f8-0eec-49f6-bea5-d3011a06de41} true 0 0 event 1.00000000 5 / i 15 0 -1 5 true false 186 341 40 80 {5a33b46a-1901-45bf-947b-bc87a8708501} true 0 0 event 1.00000000 6 / i 16 0 -1 6 true false 226 341 40 80 {69f2fe7a-784c-433e-a69f-4fc23be174a5} true 0 0 event 1.00000000 8 / i 18 0 -1 8 true false 266 341 40 80 {38cf6f9f-be50-480f-bf41-7217252e10e8} true 0 0 event 1.00000000 10 / i 20 0 -1 10 true false 306 341 40 80 {7bc6fa14-834e-45a5-a59e-585975281250} true 0 0 event 1.00000000 12 / i 22 0 -1 12 true false 346 341 40 80 {93e698d0-5245-49a9-a4e6-15c6fdabfc2f} true 0 0 event 1.00000000 13 / i 23 0 -1 13 true false 386 341 40 80 {8e5a3b8e-c8f8-4dab-834c-ac874f7f4826} true 0 0 event 1.00000000 15 / i 25 0 -1 15 true false 85 261 40 80 {a40cd6c5-77e7-4734-8c0a-3d34ba7fa59d} true 0 0 event 1.00000000 2 / i 12 0 -1 2 true false 125 261 40 80 {ba285baf-f254-47c1-884c-a8cd517d8acc} true 0 0 event 1.00000000 4 / i 14 0 -1 4 true false 205 261 40 80 {d7bcff40-9869-4088-bb39-eaeb03ca5a27} true 0 0 event 1.00000000 7 / i 17 0 -1 7 true false 245 261 40 80 {05550019-f053-47c1-8448-bc9001bf56bc} true 0 0 event 1.00000000 9 / i 19 0 -1 9 true false 285 261 40 80 {7f93c309-603f-4450-a5b0-cf62ee002c5b} true 0 0 event 1.00000000 11 / i 21 0 -1 11 true false 365 261 40 80 {8a284bd1-eade-4fc9-8d5b-e6f298c580cc} true 0 0 event 1.00000000 14 / i 24 0 -1 14 true false 405 261 40 80 {20a4f5dc-27d4-4dcd-a802-1db138ec38e8} true 0 0 event 1.00000000 16 / i 26 0 -1 16 true false