;Written by Iain McCurdy, 2006 ;Modified for QuteCsound by René, September 2010, updated Feb 2011 ;Tested on Ubuntu 10.04 with csound-float 5.13.0 and QuteCsound svn rev 817 ;Notes on modifications from original csd: ; Add Browser for audio file and use of FilePlay2 udo, now accept mono or stereo wav files ;my flags on Ubuntu: -iadc -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=null -m0 --env:SSDIR+=../../SourceMaterials sr = 44100 ;SAMPLE RATE ksmps = 32 ;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 gihalfsine ftgen 0, 0, 1025, 9, 0.5, 1, 0 ;HALF SINE WINDOW FUNCTION USED FOR AMPLITUDE ENVELOPING opcode FilePlay2, aa, Skoo ; Credit to Joachim Heintz ;gives stereo output regardless your soundfile is mono or stereo Sfil, kspeed, iskip, iloop xin ichn filenchnls Sfil if ichn == 1 then aL diskin2 Sfil, kspeed, iskip, iloop aR = aL else aL, aR diskin2 Sfil, kspeed, iskip, iloop endif xout aL, aR endop instr 10 ;GUI gkGain invalue "Gain" ;init .5 gktrans invalue "Transposition" ;init 0 gkdlt invalue "Delay_Time" ;init .05 gkFB invalue "Feedback" ;init 0 gkinput invalue "Input" gkMix invalue "Mix" ;init 1 endin instr 1 ;PLAYS FILE if gkinput=0 then Sfile invalue "_Browse1" ;OUTPUT OPCODE FILE | SPEED | INSKIP | LOOPING (0=OFF 1=ON) asigL, asigR FilePlay2 Sfile, 1, 0, 1 else asigL, asigR ins endif aenv linsegr 0,0.01,1,0.01,0 ;ANTI CLICK ENVELOPE WITH RELEASE STAGE gasigL = asigL * gkGain * aenv ;RESCALE AUDIO SIGNAL WITH ON-SCREEN GAIN SLIDER gasigR = asigR * gkGain * aenv ;RESCALE AUDIO SIGNAL WITH ON-SCREEN GAIN SLIDER endin instr 2 ;PITCH SHIFTER kporttime linseg 0,0.001,0.005,1,0.005 ;CREATE A VARIABLE FUNCTION THAT RAPIDLY RAMPS UP TO A SET VALUE ktrans portk gktrans, kporttime ;SMOOTH CHANGES IN SLIDER VARIABLE kdlt portk gkdlt, kporttime ;SMOOTH CHANGES IN SLIDER VARIABLE adlt interp kdlt ;CREATE A-RATE VERSION OF kdlt koctfract = ktrans/12 ;TRANSPOSITION AS FRACTION OF AN OCTAVE kratio = cpsoct(8+koctfract)/cpsoct(8) ;RATIO OF NEW FREQ TO A DECLARED BASE FREQUENCY (MIDDLE C) krate = (kratio-1)/kdlt ;SUBTRACT 1/1 SPEED aphase1 phasor -krate ;MOVING PHASE 1-0 aphase2 phasor -krate, .5 ;MOVING PHASE 1-0 - PHASE OFFSET BY 180 DEGREES (.5 RADIANS) agate1 tablei aphase1, gihalfsine, 1, 0, 1 ;WINDOW FUNC =HALF SINE agate2 tablei aphase2, gihalfsine, 1, 0, 1 ;WINDOW FUNC =HALF SINE ;LEFT CHANNEL=========================================================================================================================================================== aignore delayr 2 ;DECLARE DELAY BUFFER adelsig1L deltap3 aphase1 * adlt ;VARIABLE TAP aGatedSig1L = adelsig1L * agate1 delayw gasigL + (aGatedSig1L*gkFB) ;WRITE AUDIO TO THE BEGINNING OF THE DELAY BUFFER, MIX IN FEEDBACK SIGNAL - PROPORTION DEFINED BY gkFB aignore delayr 2 ;DECLARE DELAY BUFFER adelsig2L deltap3 aphase2 * adlt ;VARIABLE TAP aGatedSig2L = adelsig2L * agate2 delayw gasigL + (aGatedSig2L*gkFB) ;WRITE AUDIO TO THE BEGINNING OF THE DELAY BUFFER, MIX IN FEEDBACK SIGNAL - PROPORTION DEFINED BY gkFB ;======================================================================================================================================================================= ;RIGHT CHANNEL========================================================================================================================================================== aignore delayr 2 ;DECLARE DELAY BUFFER adelsig1R deltap3 aphase1 * adlt ;VARIABLE TAP aGatedSig1R = adelsig1R * agate1 delayw gasigR + (aGatedSig1R*gkFB) ;WRITE AUDIO TO THE BEGINNING OF THE DELAY BUFFER, MIX IN FEEDBACK SIGNAL - PROPORTION DEFINED BY gkFB aignore delayr 2 ;DECLARE DELAY BUFFER adelsig2R deltap3 aphase2 * adlt ;VARIABLE TAP aGatedSig2R = adelsig2R * agate2 delayw gasigR + (aGatedSig2R*gkFB) ;WRITE AUDIO TO THE BEGINNING OF THE DELAY BUFFER, MIX IN FEEDBACK SIGNAL - PROPORTION DEFINED BY gkFB ;======================================================================================================================================================================= aGatedMixL = (aGatedSig1L + aGatedSig2L) * .5 ;SUM AND RESCALE PITCH SHIFTER OUTPUTS (LEFT CHANNEL) aGatedMixR = (aGatedSig1R + aGatedSig2R) * .5 ;SUM AND RESCALE PITCH SHIFTER OUTPUTS (RIGHT CHANNEL) aL ntrpol gasigL,aGatedMixL,gkMix aR ntrpol gasigR,aGatedMixR,gkMix outs aL, aR ;SEND AUDIO TO OUTPUTS clear gasigL, gasigR ;CLEAR GLOBAL AUDIO VARIABLES endin ;INSTR | START | DURATION i 10 0 -1 ;GUI i 2 0 -1 ;INSTRUMENT 2 PLAYS A HELD NOTE f 0 3600 ;DUMMY SCORE EVENT KEEPS REALTIME PERFORMANCE GOING FOR 1 HOUR 72 179 1134 413 true 241 226 185 3 2 516 368 {aa607456-d368-4d59-8497-d16d608404c3} true 0 0 center Liberation Sans 18 3 0 0 0 158 220 217 border 5 2 5 5 118 29 {487d5181-d838-4cce-9628-317fefc350cb} true 0 0 event 1.00000000 ON / OFF / i 1 0 -1 true false Gain 9 60 500 27 {de47f47d-bcea-4c1c-ab4b-a323452b1f7e} true 0 0 0.00000000 1.00000000 0.47600000 lin continuous -1.00000000 false 9 78 100 30 {0200a063-5db8-4668-bc2d-2d989a083f6e} true 0 0 left Arial 10 3 0 0 0 255 255 255 noborder 1 1 Gain 449 77 60 30 {ab191e3a-430d-4f1d-88aa-9840342cd2d3} true 0 0 right Arial 9 3 0 0 0 255 255 255 noborder 1 1 518 2 606 367 {74928ed2-b701-4668-9a11-74763d317e9b} true 0 0 center Liberation Sans 18 3 0 0 0 158 220 217 border 5 2 524 19 594 346 {d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a} true 0 0 left Liberation Sans 14 3 0 0 0 255 255 255 noborder 1 1 Transposition 449 117 60 30 {732b2008-7445-4893-a260-e68561cf8e71} true 0 0 right Arial 9 3 0 0 0 255 255 255 noborder 1 1 9 159 120 30 {b57ba536-8f28-4986-9bf7-8eb84262d8ca} true 0 0 left Arial 10 3 0 0 0 255 255 255 noborder 1 1 Transposition 9 100 500 27 {b8fa76b9-3d04-4156-a2f2-a413d3864da3} true 0 0 -24.00000000 24.00000000 2.30400000 lin continuous -1.00000000 false Delay_Time 448 157 60 30 {5f670bb1-e411-4f17-94a3-2321fdf5742b} true 0 0 right Arial 9 3 0 0 0 255 255 255 noborder 1 1 Delay_Time 9 140 500 27 {1920efdc-fe11-4010-a22c-50efec0c27d3} true 0 0 0.00100000 2.00000000 0.10095000 lin continuous -1.00000000 false 9 118 160 30 {aea841b2-29e6-42d6-ac23-02439b1cc47f} true 0 0 left Arial 10 3 0 0 0 255 255 255 noborder 1 1 98 261 80 30 {429fca04-6933-4c2e-9e1a-301edbfcdc10} true 0 0 right Arial 10 3 0 0 0 255 255 255 noborder 1 1 Input 180 263 120 30 {45d19438-752c-4ed6-a700-3a764c5ab185} true 0 0 Audio File 0 Live 1 1 false Feedback 10 180 500 27 {afe11ed2-eb11-423d-a391-3677ebeda4f1} true 0 0 0.00000000 1.00000000 0.18200000 lin continuous -1.00000000 false Feedback 449 197 60 30 {d6bd3764-66b6-499b-8028-0113ff526003} true 0 0 right Arial 9 3 0 0 0 255 255 255 noborder 1 1 8 199 120 30 {4100a5b8-76c3-4420-9229-a606f4defaf9} true 0 0 left Arial 10 3 0 0 0 255 255 255 noborder 1 1 _Browse1 10 302 170 30 {2f6cb425-0ff4-4d5c-8417-9ec219e24182} true 0 0 value 1.00000000 AndItsAll.wav Browse Audio File / false false _Browse1 182 302 330 30 {408db175-49b4-461e-81e8-fd44ab10814b} true 0 0 left Arial 10 3 0 0 0 206 206 206 nobackground 182 332 330 30 {cc4ee995-e25a-4871-bb14-477ea340315b} true 0 0 left Liberation Sans 12 3 0 0 0 255 255 255 noborder 1 1 Mix 8 216 500 27 {4789481d-2dc3-4414-9c94-80e2ff95c3cd} true 0 0 0.00000000 1.00000000 1.00000000 lin continuous -1.00000000 false 8 241 80 25 {be3fcf6a-e523-4700-9b94-375bc6583a14} true 0 0 left Arial 10 3 0 0 0 255 255 255 noborder 1 1