;Written by Iain McCurdy, 2009 ;Modified for QuteCsound by René, April 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 ; Add INIT instrument ;my flags on Ubuntu: -iadc -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=alsa -Ma -m0 sr = 44100 ;SAMPLE RATE ksmps = 64 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO) 0dbfs = 1 ;MAXIMUM SOUND INTENSITY LEVEL REGARDLESS OF BIT DEPTH giwave1 ftgen 1, 0, 131072, 9, 1, 1, 0, 1.7, 1, 0, 2.31, 1, 0, 2.56, 1, 0, 3.67, 1, 0 ;COMPLEX WAVEFORM giwave2 ftgen 2, 0, 131072, 10, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ;ODD PARTIALS giwave3 ftgen 3, 0, 131072, 9, 1, 1, 270 ;INVERTED COSINE giwave4 ftgen 4, 0, 131072, 7, 1, 65536, 1, 0, -1, 65537, -1 ;SQUARE WAVE giwave5 ftgen 5, 0, 131072, 11, 40, 1, 1.1 ;BUZZ WAVEFORM giwave6 ftgen 6, 0, 131072, 19, 3, 1, 0, 0, 7, 0.5, 0, 0, 13, 0.1, 0, 0 ;SELECTED HARMONICS WAVEFORM giExp1 ftgen 0, 0, 129, -25, 0, 20.0, 128, 2000.0 ;TABLE FOR EXP SLIDER instr 10 ;GUI ktrig metro 10 if (ktrig == 1) then ;SLIDERS gkamp invalue "Amplitude" kfreq invalue "Frequency" gkfreq tablei kfreq, giExp1, 1 outvalue "Frequency_Value", gkfreq gkShapeAmount invalue "ShapeAmt" ;KNOBS gkstrlevS invalue "StrLevS" gkatttimS invalue "AttTimS" gkattlevS invalue "AttLevS" gkdectimS invalue "DecTimS" gksuslevS invalue "SusLevS" gkreltimS invalue "RelTimS" gkrellevS invalue "RelLevS" gkvel invalue "Vel" gkstrlevA invalue "StrLevA" gkatttimA invalue "AttTimA" gkattlevA invalue "AttLevA" gkdectimA invalue "DecTimA" gksuslevA invalue "SusLevA" gkreltimA invalue "RelTimA" gkrellevA invalue "RelLevA" gkLFOdepS invalue "LFODepth" gkLFOratS invalue "LFORate" gkLFOdelS invalue "LFODelay" gkLFOrisS invalue "LFORise" ;MENUS gkfn invalue "Waveform" gktype invalue "DistType" endif endin instr 11 ;INIT outvalue "Amplitude" , 0.15 outvalue "Frequency" , 0.65049 outvalue "ShapeAmt" , 0.0 outvalue "StrLevS" , 0.0 outvalue "AttTimS" , .005 outvalue "AttLevS" , 1.0 outvalue "DecTimS" , 1.0 outvalue "SusLevS" , 0.0 outvalue "RelTimS" , .5 outvalue "RelLevS" , 0.0 outvalue "StrLevA" , 0.0 outvalue "AttTimA" , .005 outvalue "AttLevA" , 1.0 outvalue "DecTimA" , 1.0 outvalue "SusLevA" , 1.0 outvalue "RelTimA" , .5 outvalue "RelLevA" , 0.0 outvalue "LFODepth" , 0.18 outvalue "LFORate" , 1.0 outvalue "LFODelay" , 0.0 outvalue "LFORise" , 0.4 outvalue "Vel" , 1.0 endin instr 1 ;MIDI ACTIVATED INSTRUMENT ktrig changed gkfn ;TEST WHETHER INPUT ARGUMENTS HAVE CHANGED. IF ANY OF THEM HAVE, OUTPUT A '1' OTHERWISE OUTPUT ZERO. if ktrig=1 then ;IF 'ktrig' IS '1'... reinit UPDATE ;BEGIN A REINITIALIZATION PASS AT LABEL 'UPDATE' endif ;END OF CONDITIONALIZATION PASS ibipolar = 0 ;UNIPOLAR/BIPOLAR SWITCH (0=UNIPOLAR 1=BIPOLAR) ifullscale = 1 ;FULLSCALE VALUE ioct octmidi ;PITCH BEND INFORMATION IS READ iSemitoneBendRange= 2 ;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) kfreq = cpsoct(ioct+ kbend) aosc phasor kfreq ;DEFINE A PHASOR kShapeEnv linsegr i(gkstrlevS), i(gkatttimS), i(gkattlevS), i(gkdectimS), i(gksuslevS), i(gkreltimS), i(gkrellevS) ;ENVELOPE USED TO MODULATE 'SHAPE AMOUNT' ivel veloc 0,1 kShapeEnv = kShapeEnv * (gkvel * ivel) kLFOenv linseg 0,i(gkLFOdelS)+0.00001,0,i(gkLFOrisS)+0.00001,1,1,1 kShapeLFO lfo gkLFOdepS*kLFOenv, gkLFOratS, 1 ;TRIANGLE WAVEFORM kShapeAmount limit kShapeEnv+kShapeLFO, -1, 1 aAmpEnv linsegr i(gkstrlevA), i(gkatttimA), i(gkattlevA), i(gkdectimA), i(gksuslevA), i(gkreltimA), i(gkrellevA) ;ENVELOPE USED TO MODULATE AMPLITUDE apd1 pdhalf aosc, kShapeAmount, ibipolar, ifullscale ;PHASE DISTORT THE PHASOR (aosc) CREATED 4 LINES ABOVE apd2 pdhalfy aosc, kShapeAmount, ibipolar, ifullscale ;PHASE DISTORT THE PHASOR (aosc) CREATED 4 LINES ABOVE if gktype=0 then apd = apd1 elseif gktype=1 then apd = apd2 endif UPDATE: ;LABEL FOR WHERE TO BEGIN REINITIALIZATION PASS aout tablei apd, i(gkfn)+1, 1 ;READ WAVEFORM USING PHASE DISTORTED WAVEFORM rireturn ;RETURN TO PERFORMANCE outs aout * gkamp * aAmpEnv, aout * gkamp * aAmpEnv ;SEND AUDIO TO OUTPUTS endin instr 2 ktrig changed gkfn ;TEST WHETHER INPUT ARGUMENTS HAVE CHANGED. IF ANY OF THEM HAVE, OUTPUT A '1' OTHERWISE OUTPUT ZERO. if ktrig=1 then ;IF 'ktrig' IS '1'... reinit UPDATE ;BEGIN A REINITIALIZATION PASS AT LABEL 'UPDATE' endif ;END OF CONDITIONALIZATION PASS ibipolar = 0 ;UNIPOLAR/BIPOLAR SWITCH (0=UNIPOLAR 1=BIPOLAR) ifullscale = 1 ;FULLSCALE VALUE aosc phasor gkfreq ;DEFINE A PHASOR kLFOenv linseg 0, i(gkLFOdelS)+0.00001, 0, i(gkLFOrisS)+0.00001, 1, 1, 1 kShapeLFO lfo gkLFOdepS*kLFOenv, gkLFOratS, 1 ;TRIANGLE WAVEFORM kShapeAmount limit gkShapeAmount+kShapeLFO, -1, 1 apd1 pdhalf aosc, kShapeAmount, ibipolar, ifullscale ;PHASE DISTORT THE PHASOR (aosc) CREATED 4 LINES ABOVE apd2 pdhalfy aosc, kShapeAmount, ibipolar, ifullscale ;PHASE DISTORT THE PHASOR (aosc) CREATED 4 LINES ABOVE if gktype=0 then apd = apd1 elseif gktype=1 then apd = apd2 endif UPDATE: ;LABEL FOR WHERE TO BEGIN REINITIALIZATION PASS aout tablei apd, i(gkfn)+1, 1 ;READ WAVEFORM USING PHASE DISTORTED WAVEFORM rireturn ;RETURN TO PERFORMANCE outs aout * gkamp, aout * gkamp ;SEND AUDIO TO OUTPUTS endin ;INSTR | START | DURATION i 10 0.0 3600 ;GUI i 11 0.0 0.01 ;INIT 800 167 800 595 true 241 226 185 2 2 512 590 {aa607456-d368-4d59-8497-d16d608404c3} true 0 0 center Liberation Sans 18 3 255 255 0 106 117 150 border 5 2 8 221 500 120 {56796b55-f924-40e9-ac1e-20eb7186c3bc} true 0 0 left Liberation Sans 14 3 255 255 0 255 255 255 border 5 2 8 69 160 30 {b066c36d-a132-4a1a-aee4-e421b02bca48} true 0 0 left Liberation Sans 10 3 255 255 0 255 255 255 noborder 1 1 Amplitude 448 69 60 30 {262729b5-3e13-43d4-af01-99d1e8aabf34} true 0 0 right Liberation Sans 9 3 255 255 0 255 255 255 noborder 1 1 Amplitude 8 53 500 27 {f4910f7d-2341-46e1-aa20-a4d3db351c24} true 0 0 0.00000000 1.00000000 0.15000001 lin continuous -1.00000000 false 8 107 160 30 {5a8c0afb-17da-4ca7-a331-f3ef38db1431} true 0 0 left Liberation Sans 10 3 255 255 0 255 255 255 noborder 1 1 Frequency_Value 448 107 60 30 {12d2c823-daba-4a56-9f0c-462a6c951992} true 0 0 right Liberation Sans 9 3 255 255 0 255 255 255 noborder 1 1 Frequency 8 91 500 27 {5442ecac-367f-413c-a49e-5f42a2727519} true 0 0 0.00000000 1.00000000 0.65048999 lin continuous -1.00000000 false 8 146 220 30 {d1ad1809-ed86-4ecd-b6c9-15b4c9686e35} true 0 0 left Liberation Sans 10 3 255 255 0 255 255 255 noborder 1 1 ShapeAmt 448 146 60 30 {39d4f770-c1eb-4c2d-9b6d-41b78e8955f0} true 0 0 right Liberation Sans 9 3 255 255 0 255 255 255 noborder 1 1 ShapeAmt 8 130 500 27 {37911dd5-758c-4ec8-9871-ce3f5cd67670} true 0 0 -1.00000000 1.00000000 0.00000000 lin continuous -1.00000000 false Waveform 340 184 160 26 {fd321c7c-a7e3-49dd-9c35-b4d1a0054c73} true 0 0 Complex Waveform 0 Odd Partials 1 Inverted Cosine 2 Square Wave 3 Buzz 4 Harms:3-7-13 5 5 false 10 16 120 26 {c4c1aae5-edb9-47d9-94a7-8d15578e0bf2} true 0 0 event 1.00000000 On / Off - MIDI / i 2 0 -1 true false 39 184 80 26 {86841fd4-baff-4c80-bfdc-c165066052cc} true 0 0 right Liberation Sans 10 3 255 255 0 255 255 255 noborder 1 1 DistType 119 184 100 26 {81b86aae-0ea8-4a71-bc13-0f6de4dbc254} true 0 0 X - Axis 0 Y - Axis 1 1 false 260 184 80 26 {e192d1b0-4e18-4b7a-97cb-800767992d7e} true 0 0 right Liberation Sans 10 3 255 255 0 255 255 255 noborder 1 1 StrLevS 26 252 50 50 {dd04e6b9-e006-4285-8fd2-72c9bd78f362} true 0 0 -1.00000000 1.00000000 0.00000000 lin continuous 0.01000000 false 22 302 60 26 {9c7c0b3e-69f4-4dbb-8e77-4f99a6e8576a} true 0 0 center Liberation Sans 10 3 255 255 0 255 255 255 noborder 1 1 StrLevS 22 315 60 30 {8f780deb-76cf-42f5-9487-938d015f2f50} true 0 0 center Liberation Sans 9 3 255 255 0 255 255 255 noborder 1 1 AttTimS 86 252 50 50 {034bc01e-e81b-4e15-8e08-c14461f55459} true 0 0 0.00100000 8.00000000 0.00500000 lin continuous 0.01000000 false 82 302 60 26 {2134e2f3-a91d-46e1-aa02-25f91ddb96c6} true 0 0 center Liberation Sans 10 3 255 255 0 255 255 255 noborder 1 1 AttTimS 82 315 60 30 {ee9c3348-96db-4140-9371-07814a2dc654} true 0 0 center Liberation Sans 9 3 255 255 0 255 255 255 noborder 1 1 AttLevS 146 252 50 50 {4cc579ba-981a-4ced-b962-bbcebb12b7bc} true 0 0 -1.00000000 1.00000000 1.00000000 lin continuous 0.01000000 false 142 302 60 26 {f8ff7ea5-915e-45b6-86d1-8ef007ac30b3} true 0 0 center Liberation Sans 10 3 255 255 0 255 255 255 noborder 1 1 AttLevS 142 315 60 30 {0c93fe27-64ec-436c-a9c5-ca1082270d69} true 0 0 center Liberation Sans 9 3 255 255 0 255 255 255 noborder 1 1 DecTimS 206 252 50 50 {7cf7c01d-feca-49e2-8f42-c3754199198b} true 0 0 0.00100000 8.00000000 1.00000000 lin continuous 0.01000000 false 202 302 60 26 {9b4a8823-34bd-48f1-a34f-d78119371642} true 0 0 center Liberation Sans 10 3 255 255 0 255 255 255 noborder 1 1 DecTimS 202 315 60 30 {14f71d96-f649-4c60-95eb-4033a010f6b2} true 0 0 center Liberation Sans 9 3 255 255 0 255 255 255 noborder 1 1 SusLevS 266 252 50 50 {f3433f95-20b3-4c0f-8f1c-65a42a5f6f7e} true 0 0 -1.00000000 1.00000000 0.00000000 lin continuous 0.01000000 false 262 302 60 26 {1b8fb0fb-9f01-4bab-80e5-730bcc354bc1} true 0 0 center Liberation Sans 10 3 255 255 0 255 255 255 noborder 1 1 SusLevS 262 315 60 30 {4f083865-4df8-4b19-944c-e8ba5bc15594} true 0 0 center Liberation Sans 9 3 255 255 0 255 255 255 noborder 1 1 RelTimS 326 252 50 50 {ab239c31-101c-463e-b854-f8206d208e0c} true 0 0 0.00000000 8.00000000 0.50000000 lin continuous 0.01000000 false 322 302 60 26 {2923a27c-d5b2-44b2-9a05-f547567f963a} true 0 0 center Liberation Sans 10 3 255 255 0 255 255 255 noborder 1 1 RelTimS 322 315 60 30 {9e550522-78c0-4a83-a75d-3a562bf843ab} true 0 0 center Liberation Sans 9 3 255 255 0 255 255 255 noborder 1 1 RelLevS 386 252 50 50 {bc0f91c1-dd0a-476e-8a62-0f8ec1ba7ee7} true 0 0 -1.00000000 1.00000000 0.00000000 lin continuous 0.01000000 false 382 302 60 26 {0f9605b6-ec16-4716-b214-b6cdaddcf1f3} true 0 0 center Liberation Sans 10 3 255 255 0 255 255 255 noborder 1 1 RelLevS 382 315 60 30 {02462a1d-8528-4180-8b80-8b8f458d9bd1} true 0 0 center Liberation Sans 9 3 255 255 0 255 255 255 noborder 1 1 Vel 446 252 50 50 {5968bfd4-9146-4a73-83a6-e7699de92c7d} true 0 0 0.00000000 1.00000000 1.00000000 lin continuous 0.01000000 false 442 302 60 26 {36418b77-ef34-41ca-8687-1d8f8a187a6f} true 0 0 center Liberation Sans 10 3 255 255 0 255 255 255 noborder 1 1 Vel 442 315 60 30 {964f4d64-8378-4324-812a-6bcda2424a1d} true 0 0 center Liberation Sans 9 3 255 255 0 255 255 255 noborder 1 1 8 343 500 120 {dca7a4d6-cf7e-4e6b-84fe-24843b99f8f2} true 0 0 left Liberation Sans 14 3 255 255 0 255 255 255 border 5 2 StrLevA 26 374 50 50 {ad4992bf-a7cc-496e-acb8-57ffe82e6426} true 0 0 0.00000000 1.00000000 0.00000000 lin continuous 0.01000000 false 22 423 60 26 {907d2242-c1f6-4578-8ba4-2aaef58051ff} true 0 0 center Liberation Sans 10 3 255 255 0 255 255 255 noborder 1 1 StrLevA 22 436 60 30 {93751cba-0781-4e6c-8ec0-cfeef9b88b82} true 0 0 center Liberation Sans 9 3 255 255 0 255 255 255 noborder 1 1 AttTimA 86 374 50 50 {9faf4745-57b3-4c1d-a312-943b4902e1b0} true 0 0 0.00100000 8.00000000 0.00500000 lin continuous 0.01000000 false 82 423 60 26 {7a3462bf-9790-4234-b69d-ff2af8752207} true 0 0 center Liberation Sans 10 3 255 255 0 255 255 255 noborder 1 1 AttTimA 82 436 60 30 {449833c6-a5de-40bc-b564-15efdd3a247e} true 0 0 center Liberation Sans 9 3 255 255 0 255 255 255 noborder 1 1 AttLevA 146 374 50 50 {fc097eb6-7321-4353-8c6f-53568c79bd8a} true 0 0 0.00000000 1.00000000 1.00000000 lin continuous 0.01000000 false 142 423 60 26 {79d207ad-d99f-41e9-a8ba-024b5a50a89d} true 0 0 center Liberation Sans 10 3 255 255 0 255 255 255 noborder 1 1 AttLevA 142 436 60 30 {73669288-bd5c-4033-b650-87535ce7c123} true 0 0 center Liberation Sans 9 3 255 255 0 255 255 255 noborder 1 1 DecTimA 206 374 50 50 {f9f6e6e4-081e-4e18-a435-00926860da85} true 0 0 0.00100000 8.00000000 1.00000000 lin continuous 0.01000000 false 202 423 60 26 {facdc01c-9969-4750-9f6a-e7c412e3c4a8} true 0 0 center Liberation Sans 10 3 255 255 0 255 255 255 noborder 1 1 DecTimA 202 436 60 30 {bf50e950-5683-43ca-92f4-7146af8847ed} true 0 0 center Liberation Sans 9 3 255 255 0 255 255 255 noborder 1 1 SusLevA 266 374 50 50 {ecc1255b-2270-4745-add8-0f8d54843bb0} true 0 0 0.00000000 1.00000000 1.00000000 lin continuous 0.01000000 false 262 423 60 26 {848a3adb-e1f6-4183-9a19-ec2ad7f26cca} true 0 0 center Liberation Sans 10 3 255 255 0 255 255 255 noborder 1 1 SusLevA 262 436 60 30 {63d2e42c-7f99-4e7c-88b8-7c4eccf6aa10} true 0 0 center Liberation Sans 9 3 255 255 0 255 255 255 noborder 1 1 RelTimA 326 374 50 50 {440cf36c-cf9e-45d7-a3c3-e24188b0c7d3} true 0 0 0.00000000 8.00000000 0.50000000 lin continuous 0.01000000 false 322 423 60 26 {ba651e78-c00c-4b71-9830-9a6b204e9860} true 0 0 center Liberation Sans 10 3 255 255 0 255 255 255 noborder 1 1 RelTimA 322 436 60 30 {385332ec-38a5-4f29-9510-dacd6aefd47f} true 0 0 center Liberation Sans 9 3 255 255 0 255 255 255 noborder 1 1 RelLevA 386 374 50 50 {0b19f226-1af0-4cb0-865c-f486f9b178f6} true 0 0 0.00000000 1.00000000 0.00000000 lin continuous 0.01000000 false 382 423 60 26 {dbf71d42-4632-4bfb-9923-465124c12185} true 0 0 center Liberation Sans 10 3 255 255 0 255 255 255 noborder 1 1 RelLevA 382 436 60 30 {b043791e-9f6f-40b2-ba5c-17830042c168} true 0 0 center Liberation Sans 9 3 255 255 0 255 255 255 noborder 1 1 8 465 500 120 {226d388f-b5da-4b20-9162-98673361dffc} true 0 0 left Liberation Sans 14 3 255 255 0 255 255 255 border 5 2 LFODepth 206 496 50 50 {266cf62e-dcdc-4cbf-9a2d-ee4e355a1088} true 0 0 0.00000000 1.00000000 0.18000001 lin continuous 0.01000000 false 202 545 60 26 {8c0122dc-e02d-4d98-ab63-b1e63c342147} true 0 0 center Liberation Sans 10 3 255 255 0 255 255 255 noborder 1 1 LFODepth 202 558 60 30 {2a18c41a-5bca-40f4-9952-fcaa43bf2288} true 0 0 center Liberation Sans 9 3 255 255 0 255 255 255 noborder 1 1 LFORate 266 496 50 50 {a1e79a84-2277-46ad-9303-12ce1f1ae943} true 0 0 0.00000000 16.00000000 1.00000000 lin continuous 0.01000000 false 262 545 60 26 {70dc6e78-20ba-4a81-866e-501e666d2bef} true 0 0 center Liberation Sans 10 3 255 255 0 255 255 255 noborder 1 1 LFORate 262 558 60 30 {7010fc13-3cd7-4441-9ea3-00866bdfc37a} true 0 0 center Liberation Sans 9 3 255 255 0 255 255 255 noborder 1 1 LFODelay 326 496 50 50 {551a0f31-5ad4-47c1-889c-668b4588afd3} true 0 0 0.00000000 5.00000000 0.00000000 lin continuous 0.01000000 false 322 545 60 26 {b1176770-5875-44e8-b169-e1d0c8997ee2} true 0 0 center Liberation Sans 10 3 255 255 0 255 255 255 noborder 1 1 LFODelay 322 558 60 30 {7173c82d-2140-4760-8705-cb148a2f140c} true 0 0 center Liberation Sans 9 3 255 255 0 255 255 255 noborder 1 1 LFORise 386 496 50 50 {5f74f884-9679-4715-b677-48b1de7256b1} true 0 0 0.00000000 5.00000000 0.40000001 lin continuous 0.01000000 false 382 545 60 26 {a06bbb52-9726-47c8-acbc-d91cdb7efeae} true 0 0 center Liberation Sans 10 3 255 255 0 255 255 255 noborder 1 1 LFORise 382 558 60 30 {b593d736-0c0b-494c-95e4-b9695580e85d} true 0 0 center Liberation Sans 9 3 255 255 0 255 255 255 noborder 1 1 515 2 280 590 {9798823d-b60e-424f-a3c4-1a43d5e0312d} true 0 0 center Liberation Sans 18 3 255 255 0 106 117 150 border 5 2 521 49 269 539 {66493881-548a-48d2-bdb6-08aad6d0fe91} true 0 0 left Liberation Sans 14 3 255 255 0 255 255 255 noborder 2 1