;Written by Iain McCurdy, 2009 ; Modified for QuteCsound by René, November 2010 ; Tested on Ubuntu 10.04 with csound-double cvs August 2010 and QuteCsound svn rev 733 ;Notes on modifications from original csd: ; Add table(s) for exp slider ; Instrument 1 is activated by MIDI and by the GUI ;my flags on Ubuntu: -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=alsa -Ma -m0 --midi-key-oct=4 --midi-velocity-amp=5 sr = 44100 ;SAMPLE RATE ksmps = 1 ;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, 4096, 10, 1 ;FUNCTION TABLE THAT STORES A SINGLE CYCLE OF A SINE WAVE giExp20000 ftgen 0, 0, 129, -25, 0, 20.0, 128, 20000.0 ;TABLES FOR EXP SLIDER instr 10 ;GUI ktrig metro 10 if (ktrig == 1) then kbasefreq invalue "Base_Frequency" gkbasefreq tablei kbasefreq, giExp20000, 1 outvalue "Base_Frequency_Value", gkbasefreq gkindex invalue "Modulation_Index" gkCarRatio invalue "Carrier_Frequency" gkModRatio invalue "Modulator_Frequency" gkCarAmp invalue "Carrier_Amplitude" gkndxatt invalue "Index_Attack" gkndxdec invalue "Index_Decay" gkndxslev invalue "Index_Sustain" gkndxrel invalue "Index_Release" gkndxdel invalue "Index_Delay" gkampatt invalue "Amp_Attack" gkampdec invalue "Amp_Decay" gkampslev invalue "Amp_Sustain" gkamprel invalue "Amp_Release" gkampdel invalue "Amp_Delay" endif endin instr 1 ;FM INSTRUMENT if p4!=0 then ;MIDI ioct = p4 ;READ OCT VALUE FROM MIDI INPUT iamp = p5 ;READ midi-velocity-amp FROM MIDI INPUT kCarAmp = iamp * gkCarAmp ;SET AMPLITUDE TO RECEIVED p5 (I.E. MIDI VELOCITY) MULTIPLIED BY SLIDER "Carrier_Amplitude" ;PITCH BEND=========================================================================================================================================================== iSemitoneBendRange = 4 ;PITCH BEND RANGE IN SEMITONES imin = 0 ;EQUILIBRIUM POSITION imax = iSemitoneBendRange * .0833333 ;MAX PITCH DISPLACEMENT (IN oct FORMAT) kbend pchbend imin, imax ;PITCH BEND VARIABLE (IN oct FORMAT) kbasefreq = cpsoct(ioct + kbend) ;SET FUNDEMENTAL FROM MIDI ;===================================================================================================================================================================== else ;GUI kbasefreq = gkbasefreq ;SET FUNDEMENTAL FROM GUI SLIDER "Base_Frequency" kCarAmp = gkCarAmp ;SET kamp TO SLIDER VALUE "Carrier_Amplitude" endif kporttime linseg 0,0.001,0.02 ;CREATE A VARIABLE FUNCTION THAT RAPIDLY RAMPS UP TO A SET VALUE kbasefreq portk kbasefreq, kporttime kndxenv madsr i(gkndxatt), i(gkndxdec), i(gkndxslev) + .0000001, i(gkndxrel) , i(gkndxdel) ;LINE SEGMENT ENVELOPE WITH MIDI RELEASE MECHANISM kpeakdeviation = kbasefreq * gkindex * kndxenv aModulator oscili kpeakdeviation, kbasefreq * gkModRatio,gisine kampenv mxadsr i(gkampatt), i(gkampdec), i(gkampslev) + .0000001, i(gkamprel) , i(gkampdel) ;EXPONENTIAL ENVELOPE WITH MIDI RELEASE MECHANISM aCarrier oscili kCarAmp * kampenv, (kbasefreq * gkCarRatio) + aModulator, gisine outs aCarrier, aCarrier endin instr 2 ;PRESET ;OPCODE DESTINATION | VALUE outvalue "Carrier_Frequency", p4 outvalue "Modulator_Frequency", p5 outvalue "Base_Frequency", p6 outvalue "Modulation_Index", p7 outvalue "Index_Attack", p8 outvalue "Index_Decay", p9 outvalue "Index_Sustain", p10 outvalue "Index_Release", p11 outvalue "Index_Delay", p12 outvalue "Amp_Attack", p13 outvalue "Amp_Decay", p14 outvalue "Amp_Sustain", p15 outvalue "Amp_Release", p16 outvalue "Amp_Delay", p17 endin ;INSTR | START | DURATION i 10 0 3600 ;GUI ;INIT (Metal Plate) | p4(CarRatio) | p5(ModRatio) | p6(BasFrq) | p7(index) | p8(NdxAtt) | p9(NdxDec) | p10(NdxSlev) | p11(NdxRel) | p12(NdxDel | p13(AmpAtt) | p14(AmpDec) | p15(AmpSlev) | p16(AmpRel) | p17(AmpDel) i 2 0.1 0 1 1.377 0.4035705 5 .005 3 0 .5 0 .005 7 0 .5 0 549 226 841 494 true 241 226 185 2 2 512 484 {aa607456-d368-4d59-8497-d16d608404c3} true 0 0 center Liberation Sans 18 3 255 255 255 5 27 150 border 5 2 514 2 312 348 {74928ed2-b701-4668-9a11-74763d317e9b} true 0 0 center Liberation Sans 18 3 255 255 255 5 27 150 border 5 2 520 48 305 277 {d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a} true 0 0 left Liberation Sans 14 3 255 255 255 255 255 255 noborder 1 1 8 6 124 30 {24979132-c53f-4414-ac6b-6b4f503ecfe8} true 0 0 event 1.00000000 ON / OFF (MIDI) / i 1 0 -1 true false Carrier_Amplitude 448 243 60 30 {745d6bee-b951-4a03-9fe8-9e10d5ae4556} true 0 0 right Arial 9 3 255 255 255 255 255 255 noborder 1 1 Carrier_Amplitude 8 220 500 27 {06814721-6151-4baa-84e2-8f39843b07a4} true 0 0 0.00000000 1.00000000 0.37000000 lin continuous -1.00000000 false 8 243 180 30 {c6d7165c-6730-426f-b293-52b411bc73cf} true 0 0 left Arial 10 3 255 255 255 255 255 255 noborder 1 1 130 131 234 83 {53a95371-23f7-4d54-a6c6-63bbabdb388d} true 0 0 229 133 32 46 {81ded06c-d53f-4a6d-a597-5f1b68b18042} true 0 0 center Arial Black 27 3 255 255 255 255 255 255 noborder 1 1 Carrier_Frequency 150 143 70 28 {6f8fc775-201d-40f9-931b-687c9b3ef417} true 0 0 left Liberation Sans 14 0 0 0 255 255 255 0.00010000 0.125 8 false 0.125 Modulator_Frequency 273 143 70 28 {fd4b783c-f008-4a1c-b2e6-50340aad9093} true 0 0 left Liberation Sans 14 0 0 0 255 255 255 0.00010000 0.125 8 false 0.125 273 172 70 50 {d7a84933-3d3a-4adf-8289-84a4413362a7} true 0 0 center Arial 10 3 255 255 255 255 255 255 noborder 1 1 150 172 70 50 {7723878b-fcac-4444-84a2-a4ba87008431} true 0 0 center Liberation Sans 10 3 255 255 255 255 255 255 noborder 1 1 8 67 180 30 {541ace1b-b1de-4c04-8d84-1de90288dded} true 0 0 left Liberation Sans 10 3 255 255 255 255 255 255 noborder 1 1 Base_Frequency 8 44 500 27 {eac88081-deaa-45c0-b896-32a3ffedc74a} true 0 0 0.00000000 1.00000000 0.40357050 lin continuous -1.00000000 false Base_Frequency_Value 448 67 60 30 {3be43919-ad18-4aef-b554-03c4b4d991c3} true 0 0 right Liberation Sans 9 3 255 255 255 255 255 255 noborder 1 1 8 110 180 30 {0c691576-66a5-4aa6-a82c-48f930da9708} true 0 0 left Liberation Sans 10 3 255 255 255 255 255 255 noborder 1 1 Modulation_Index 8 87 500 27 {9cf53cef-488f-4075-b87f-dc2c3e6a21e6} true 0 0 0.00000000 20.00000000 5.00000000 lin continuous -1.00000000 false Modulation_Index 448 110 60 30 {aa79d499-9fd2-4387-89af-8e846c1081c4} true 0 0 right Liberation Sans 9 3 255 255 255 255 255 255 noborder 1 1 8 284 500 96 {edbaff47-a52a-4733-801b-10e207571428} true 0 0 left Liberation Sans 14 3 255 255 255 255 255 255 border 1 1 Index_Attack 189 293 45 45 {7020c475-84e1-497d-abcc-1651846cd081} true 0 0 0.00500000 8.00000000 0.00500000 lin continuous 0.01000000 false 177 337 70 31 {2bc5a26f-6ed1-497f-9cc9-372067fc74a0} true 0 0 center Liberation Sans 10 3 255 255 255 255 255 255 noborder 1 1 Index_Attack 182 357 60 30 {39ac87aa-d118-4cee-98a5-30005f1b85b9} true 0 0 center Liberation Sans 9 3 255 255 255 255 255 255 noborder 1 1 Index_Decay 232 357 60 30 {e4a41d1d-7b92-4910-a33f-0505d9b85493} true 0 0 center Liberation Sans 9 3 255 255 255 255 255 255 noborder 1 1 227 337 70 31 {738e097b-25dd-4f34-8279-6c7e03e83210} true 0 0 center Liberation Sans 10 3 255 255 255 255 255 255 noborder 1 1 Index_Decay 239 293 45 45 {a92eed39-9f56-4cb4-bb3d-20f8c9ab692e} true 0 0 0.00000000 15.00000000 3.00000000 lin continuous 0.01000000 false Index_Sustain 283 356 60 30 {c44e6e8e-a319-4ad7-936f-1dbad8fe5d88} true 0 0 center Liberation Sans 9 3 255 255 255 255 255 255 noborder 1 1 278 336 70 31 {7fb72d6d-f804-4eed-8eec-03489eef4f54} true 0 0 center Liberation Sans 10 3 255 255 255 255 255 255 noborder 1 1 Index_Sustain 290 292 45 45 {1256d78b-64b4-4a33-b1a2-c6e147788a64} true 0 0 0.00000000 1.00000000 0.00000000 lin continuous 0.01000000 false Index_Release 334 356 60 30 {aede005f-af85-4a2e-826f-3b03c1a663a7} true 0 0 center Liberation Sans 9 3 255 255 255 255 255 255 noborder 1 1 329 336 70 31 {84305d1c-9695-47f1-8536-0be4b8783ca7} true 0 0 center Liberation Sans 10 3 255 255 255 255 255 255 noborder 1 1 Index_Release 341 292 45 45 {bd1488b8-dfc0-48f8-80db-21f899f3408a} true 0 0 0.00000000 15.00000000 0.50000000 lin continuous 0.01000000 false Index_Delay 385 356 60 30 {80742be8-4ca4-4e7c-b845-5e6f911ce892} true 0 0 center Liberation Sans 9 3 255 255 255 255 255 255 noborder 1 1 380 336 70 31 {70fbe521-a69d-45de-b056-52358ef4539f} true 0 0 center Liberation Sans 10 3 255 255 255 255 255 255 noborder 1 1 Index_Delay 392 292 45 45 {ad8b5897-aaca-485d-b0f4-12723d84012a} true 0 0 0.00000000 8.00000000 0.00000000 lin continuous 0.01000000 false 514 350 312 136 {d0e53040-2605-4b42-bb01-580909cc3849} true 0 0 center Liberation Sans 18 3 255 255 255 5 27 150 border 5 2 8 382 500 96 {ebccfe0c-c88a-475f-8960-eb0c68dc0465} true 0 0 left Liberation Sans 14 3 255 255 255 255 255 255 border 1 1 555 391 100 30 {59d7363f-ef65-48d5-9095-b9416211f693} true 0 0 event 1.00000000 Metal Plate / i 2 0 0 1 1.377 0.4035705 5 .005 3 0 .5 0 .005 7 0 .5 0 false false button1 555 430 100 30 {cbc62d10-c3dc-41ca-9387-093383525676} true 0 0 event 1.00000000 Clarinet / i 2 0 0 1 2.0005 0.371262 5.33 .005 .715 .852 .111 0 .087 .402 .785 .102 0 false false button1 685 391 100 30 {a945af70-b97a-4a70-8361-dd75becac320} true 0 0 event 1.00000000 Trumpet / i 2 0 0 1 1.0003 0.4372449 8.79 .005 .139 .616 .111 0 .018 .402 .785 .102 0 false false button1 685 431 100 30 {88201a85-55cc-4b46-95ca-e0d82f3e982c} true 0 0 event 1.00000000 Basson / i 2 0 0 5 1 0.1706 5.33 .005 .715 .852 .111 0 .087 .402 .785 .102 0 false false Amp_Delay 392 390 45 45 {ba22dd34-221f-4885-be63-0227b478280f} true 0 0 0.00000000 8.00000000 0.00000000 lin continuous 0.01000000 false 380 434 70 31 {cd2e5022-9b80-4261-b2cf-1327ea35b419} true 0 0 center Liberation Sans 10 3 255 255 255 255 255 255 noborder 1 1 Amp_Delay 385 454 60 30 {0ae5e1b4-46bc-456b-a7b6-d91b2d4196f9} true 0 0 center Liberation Sans 9 3 255 255 255 255 255 255 noborder 1 1 Amp_Release 341 390 45 45 {f94fee0f-a85f-49bc-92bb-1b449b5524b8} true 0 0 0.00000000 15.00000000 0.50000000 lin continuous 0.01000000 false 329 434 70 31 {da15df18-48b8-43ab-a879-b4da10429f3a} true 0 0 center Liberation Sans 10 3 255 255 255 255 255 255 noborder 1 1 Amp_Release 334 454 60 30 {ab141074-a7d2-4397-9da2-71162ac152c2} true 0 0 center Liberation Sans 9 3 255 255 255 255 255 255 noborder 1 1 Amp_Sustain 290 390 45 45 {a629f388-497b-45cd-a7d6-232a4699a56c} true 0 0 0.00000000 1.00000000 0.00000000 lin continuous 0.01000000 false 278 434 70 31 {c109df79-b140-4292-bbb1-ae448090e932} true 0 0 center Liberation Sans 10 3 255 255 255 255 255 255 noborder 1 1 Amp_Sustain 283 454 60 30 {ad993d2c-666e-4e49-8edc-b890b66c4b6a} true 0 0 center Liberation Sans 9 3 255 255 255 255 255 255 noborder 1 1 Amp_Decay 239 391 45 45 {d9a06f46-e411-492d-9402-3cb584ef32c4} true 0 0 0.00000000 15.00000000 7.00000000 lin continuous 0.01000000 false 227 435 70 31 {eefade2c-bcf8-4fa7-83bd-e4d449daf2cd} true 0 0 center Liberation Sans 10 3 255 255 255 255 255 255 noborder 1 1 Amp_Decay 232 455 60 30 {d366e403-6bae-49e9-90b7-920e1ff2e8f0} true 0 0 center Liberation Sans 9 3 255 255 255 255 255 255 noborder 1 1 Amp_Attack 182 455 60 30 {a8c5f4b0-7281-4c50-af8d-28fde5ff3d72} true 0 0 center Liberation Sans 9 3 255 255 255 255 255 255 noborder 1 1 177 435 70 31 {ccdc65d8-5b7e-4745-96ef-5bb738bc55f3} true 0 0 center Liberation Sans 10 3 255 255 255 255 255 255 noborder 1 1 Amp_Attack 189 391 45 45 {5971a2e0-a072-46fb-ba71-f5cf75fb8e71} true 0 0 0.00500000 8.00000000 0.00500000 lin continuous 0.01000000 false