|
@@ -1,11 +1,8 @@ |
|
|
main.csd
|
|
|
main.csd
|
|
|
Pete Shadbolt.2014
|
|
|
Pete Shadbolt.2014
|
|
|
Based on code by Iain McCurdy, 2006
|
|
|
Based on code by Iain McCurdy, 2006
|
|
|
|
|
|
|
|
|
THE delay OPCODE IS PLACED IN A SEPARATE, ALWAYS ON, INSTRUMENT FROM THE SOURCE SOUND PRODUCING INSTRUMENT.
|
|
|
|
|
|
THE IS A COMMONLY USED TECHNIQUE WITH TIME SMEARING OPCODES AND EFFECTS LIKE REVERBS AND DELAYS.
|
|
|
|
|
|
|
|
|
|
|
|
ksmps MAY NEED TO BE LOW (AND kr THEREFORE HIGH) WHEN WORKING WITH SHORT DELAY TIMES DEFINED INITIALLY AT KRATE
|
|
|
ksmps MAY NEED TO BE LOW (AND kr THEREFORE HIGH) WHEN WORKING WITH SHORT DELAY TIMES DEFINED INITIALLY AT KRATE
|
|
|
|
|
|
TODO: implement octave down/up (like old delay pedal), key control, panic button
|
|
|
|
|
|
|
|
|
<CsoundSynthesizer>
|
|
|
<CsoundSynthesizer>
|
|
|
|
|
|
|
|
@@ -15,99 +12,90 @@ ksmps MAY NEED TO BE LOW (AND kr THEREFORE HIGH) WHEN WORKING WITH SHORT DELAY T |
|
|
|
|
|
|
|
|
<CsInstruments>
|
|
|
<CsInstruments>
|
|
|
|
|
|
|
|
|
sr = 44100 ;SAMPLE RATE
|
|
|
|
|
|
ksmps = 4 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE (MAY NEED TO BE LOW WHEN WORKING WITH SHORT DELAY TIMES DEFINED INITIALLY AT KRATE)
|
|
|
|
|
|
nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
|
|
|
|
|
|
0dbfs = 1 ;MAXIMUM AMPLITUDE
|
|
|
|
|
|
|
|
|
|
|
|
;FLTK INTERFACE CODE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
FLcolor 255, 255, 255, 0, 0, 0
|
|
|
|
|
|
; LABEL | WIDTH | HEIGHT | X | Y
|
|
|
|
|
|
FLpanel "M I L C H L O D E", 500, 300, 0, 0
|
|
|
|
|
|
|
|
|
|
|
|
; ON | OFF | TYPE | WIDTH | HEIGHT | X | Y | OPCODE | INS | STARTTIM | DUR
|
|
|
|
|
|
gkOnOff,ihOnOff FLbutton "Input On/Off", 1, 0, 22, 180, 25, 5, 5, 0, 1, 0, -1
|
|
|
|
|
|
FLsetColor2 255, 255, 50, ihOnOff ;SET SECONDARY COLOUR TO YELLOW
|
|
|
|
|
|
|
|
|
|
|
|
;GENERAL_TEXT_SETTINGS SIZE | FONT | ALIGN | RED | GREEN | BLUE
|
|
|
|
|
|
FLlabel 13, 1, 3, 255, 255, 255 ;LABELS MADE INVISIBLE (I.E. SAME COLOR AS PANEL)
|
|
|
|
|
|
|
|
|
|
|
|
;BUTTON BANKS TYPE | NUMX | NUMY | WIDTH | HEIGHT | X | Y | OPCODE | INS | STARTTIM | DUR
|
|
|
|
|
|
;gkinput, ihinput FLbutBank 14, 1, 2, 18, 40, 250, 0, -1
|
|
|
|
|
|
|
|
|
|
|
|
;GENERAL_TEXT_SETTINGS SIZE | FONT | ALIGN | RED | GREEN | BLUE
|
|
|
|
|
|
FLlabel 13, 1, 3, 0, 0, 0 ;LABELS MADE VISIBLE AGAIN
|
|
|
|
|
|
|
|
|
|
|
|
;VALUE_DISPLAY_BOXES WIDTH | HEIGHT | X | Y
|
|
|
|
|
|
iddlt FLvalue " ", 80, 20, 5, 75
|
|
|
|
|
|
idmix FLvalue " ", 80, 20, 5, 125
|
|
|
|
|
|
idfeedbackamt FLvalue " ", 80, 20, 5, 175
|
|
|
|
|
|
idamp FLvalue " ", 80, 20, 5, 225
|
|
|
|
|
|
idporttime FLvalue " ", 80, 20, 5, 275
|
|
|
|
|
|
|
|
|
|
|
|
;SLIDERS MIN | MAX | EXP | TYPE | DISP | WIDTH | HEIGHT | X | Y
|
|
|
|
|
|
gkdlt,ihdlt FLslider "Delay Time (sec)", .001, 5, -1, 23, iddlt, 490, 25, 5, 50
|
|
|
|
|
|
gkmix,ihmix FLslider "Dry/Wet Mix", 0, 1, 0, 23, idmix, 490, 25, 5, 100
|
|
|
|
|
|
gkfeedamt,ihfeedamt FLslider "Feedback Ratio", -1, 1, 0, 23, idfeedbackamt, 490, 25, 5, 150
|
|
|
|
|
|
gkamp,ihamp FLslider "Output Amplitude Rescaling", 0, 1, 0, 23, idamp, 490, 25, 5, 200
|
|
|
|
|
|
gkporttime,ihporttime FLslider "Portamento Time", 0, 2, 0, 23, idporttime, 490, 25, 5, 250
|
|
|
|
|
|
gkingain,ihingain FLslider "Live Input Gain", 0, 1, 0, 23, -1, 140, 20, 350, 5
|
|
|
|
|
|
|
|
|
|
|
|
;SET_INITIAL_VALUES VALUE | HANDLE
|
|
|
|
|
|
FLsetVal_i 1, ihOnOff
|
|
|
|
|
|
FLsetVal_i .5, ihingain
|
|
|
|
|
|
FLsetVal_i .5, ihdlt
|
|
|
|
|
|
FLsetVal_i 0.5, ihmix
|
|
|
|
|
|
FLsetVal_i 0.7, ihfeedamt
|
|
|
|
|
|
FLsetVal_i .7, ihamp
|
|
|
|
|
|
FLsetVal_i 0.3, ihporttime
|
|
|
|
|
|
|
|
|
|
|
|
FLpanel_end ;END OF PANEL CONTENTS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FLrun ;RUN THE FLTK WIDGET THREAD
|
|
|
|
|
|
;END OF FLTK INTERFACE CODE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
|
|
|
instr 1 ;PLAYS FILE
|
|
|
|
|
|
if gkOnOff=0 then ;SENSE FLTK ON/OFF SWITCH
|
|
|
|
|
|
turnoff ;TURN THIS INSTRUMENT OFF IMMEDIATELY
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
asigL, asigR ins ;TAKE INPUT FROM COMPUTER'S AUDIO INPUT
|
|
|
|
|
|
gasigL = asigL * gkingain ;SCALE USING 'Input Gain' SLIDER
|
|
|
|
|
|
gasigR = asigR * gkingain ;SCALE USING 'Input Gain' SLIDER
|
|
|
|
|
|
|
|
|
sr = 44100 ;Sample rate
|
|
|
|
|
|
ksmps = 20 ;Number of audio samples in each control cycle
|
|
|
|
|
|
nchnls = 2 ;Number of channels (2=stereo)
|
|
|
|
|
|
0dbfs = 1 ;Maximum amplitude
|
|
|
|
|
|
gkporttime = 0.3; portamento time
|
|
|
|
|
|
|
|
|
|
|
|
;FLTK GUI interface
|
|
|
|
|
|
FLcolor 200, 200, 255, 0, 0, 0
|
|
|
|
|
|
FLpanel "M I L C H L O D E", 500, 300, 0, 0, 0, 1
|
|
|
|
|
|
gkOnOff,ihOnOff FLbutton "Input On/Off", 1, 0, 22, 180, 25, 5, 5, 0, 1, 0, -1
|
|
|
|
|
|
|
|
|
|
|
|
; Sliders
|
|
|
|
|
|
gkdlt,ihdlt FLslider "Delay Time (sec)", .001, 5, 0, 23, -1, 490, 25, 5, 50
|
|
|
|
|
|
gkmix,ihmix FLslider "Dry/Wet Mix", 0, 1, 0, 23, -1, 490, 25, 5, 100
|
|
|
|
|
|
gkfeedamt,ihfeedamt FLslider "Feedback Ratio", -1, 1, 0, 23, -1, 490, 25, 5, 150
|
|
|
|
|
|
gkamp,ihamp FLslider "Output Amplitude Rescaling", 0, 1, 0, 23, -1, 490, 25, 5, 200
|
|
|
|
|
|
gkingain,ihingain FLslider "Input Gain", 0, 1, 0, 23, -1, 140, 20, 350, 5
|
|
|
|
|
|
ih FLbox "Keys: ", 1, 5, 14, 490, 20, 0, 250
|
|
|
|
|
|
|
|
|
|
|
|
;Set defaults
|
|
|
|
|
|
FLsetVal_i 1, ihOnOff
|
|
|
|
|
|
FLsetVal_i .5, ihingain
|
|
|
|
|
|
FLsetVal_i 4, ihdlt
|
|
|
|
|
|
FLsetVal_i 0.5, ihmix
|
|
|
|
|
|
FLsetVal_i 0.95, ihfeedamt
|
|
|
|
|
|
FLsetVal_i .7, ihamp
|
|
|
|
|
|
|
|
|
|
|
|
FLpanel_end ;End of GUI
|
|
|
|
|
|
FLrun ;Run the FLTK thread
|
|
|
|
|
|
|
|
|
|
|
|
; Instr 1 is the source
|
|
|
|
|
|
instr 1
|
|
|
|
|
|
|
|
|
|
|
|
; Turn off with the switch
|
|
|
|
|
|
if gkOnOff=0 then
|
|
|
|
|
|
turnoff
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
; Get input from mic/line
|
|
|
|
|
|
asigL, asigR ins
|
|
|
|
|
|
gasigL = asigL * gkingain
|
|
|
|
|
|
gasigR = asigR * gkingain
|
|
|
endin
|
|
|
endin
|
|
|
|
|
|
|
|
|
instr 2 ;DELAY INSTRUMENT
|
|
|
|
|
|
kporttime linseg 0, .001, 1, 1, 1 ;USE OF AN ENVELOPE VALUE THAT QUICKLY RAMPS UP FROM ZERO TO 1. THIS PREVENTS VARIABLES GLIDING TO THEIR REQUIRED VALUES EACH TIME THE INSTRUMENT IS STARTED.
|
|
|
|
|
|
kporttime = kporttime * gkporttime ;SCALE PORTAMENTO FUNCTION WITH FLTK SLIDER VALUE
|
|
|
|
|
|
kdlt portk gkdlt, kporttime ;PORTAMENTO IS APPLIED TO THE VARIABLE 'gkdlt'. A NEW VARIABLE 'kdlt' IS CREATED.
|
|
|
|
|
|
adlt interp kdlt ;A NEW A-RATE VARIABLE 'adlt' IS CREATED BY INTERPOLATING THE K-RATE VARIABLE 'kdlt'
|
|
|
|
|
|
|
|
|
|
|
|
;;;LEFT CHANNEL DELAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
abufferL delayr 5 ;CREATE A DELAY BUFFER OF 5 SECONDS DURATION (EQUIVALENT TO THE MAXIMUM DELAY TIME POSSIBLE USING THIS EXAMPLE)
|
|
|
|
|
|
adelsigL deltap3 adlt ;TAP THE DELAY LINE AT gkdlt SECONDS
|
|
|
|
|
|
delayw gasigL + (adelsigL * gkfeedamt) ;WRITE AUDIO SOURCE AND FEEDBACK SIGNAL INTO THE BEGINNING OF THE BUFFER
|
|
|
|
|
|
|
|
|
|
|
|
;;;RIGHT CHANNEL DELAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
abufferR delayr 5 ;CREATE A DELAY BUFFER OF 5 SECONDS DURATION (EQUIVALENT TO THE MAXIMUM DELAY TIME POSSIBLE USING THIS EXAMPLE)
|
|
|
|
|
|
adelsigR deltap3 adlt ;TAP THE DELAY LINE AT gkdlt SECONDS
|
|
|
|
|
|
delayw gasigR + (adelsigR * gkfeedamt) ;WRITE AUDIO SOURCE AND FEEDBACK SIGNAL INTO THE BEGINNING OF THE BUFFER
|
|
|
|
|
|
|
|
|
|
|
|
aL ntrpol gasigL, adelsigL, gkmix
|
|
|
|
|
|
aR ntrpol gasigR, adelsigR, gkmix
|
|
|
|
|
|
|
|
|
|
|
|
outs aL * gkamp, aR * gkamp ;CREATE A MIX BETWEEN THE WET AND THE DRY SIGNALS AT THE OUTPUT
|
|
|
|
|
|
clear gasigL, gasigR ;CLEAR THE GLOBAL AUDIO SEND VARIABLES
|
|
|
|
|
|
|
|
|
; Instr 2 is the delay line
|
|
|
|
|
|
instr 2
|
|
|
|
|
|
|
|
|
|
|
|
; Sense keyboard
|
|
|
|
|
|
kKey FLkeyIn
|
|
|
|
|
|
kChanged changed kKey
|
|
|
|
|
|
printk2 kKey
|
|
|
|
|
|
;if kKey=112&&kChanged=1 then
|
|
|
|
|
|
;printf_i "awd"
|
|
|
|
|
|
;FLsetVal_i 0.0, gkfeedamt
|
|
|
|
|
|
;endif
|
|
|
|
|
|
|
|
|
|
|
|
kporttime linseg 0, .001, 1, 1, 1 ;A short envelope
|
|
|
|
|
|
kporttime = kporttime * gkporttime ;TODO: remove this
|
|
|
|
|
|
kdlt portk gkdlt, kporttime ;Apply portamento
|
|
|
|
|
|
adlt interp kdlt ;Interpolate
|
|
|
|
|
|
|
|
|
|
|
|
;Left channel
|
|
|
|
|
|
abufferL delayr 5 ;Buffer
|
|
|
|
|
|
adelsigL deltap3 adlt ;Tap
|
|
|
|
|
|
delayw gasigL + (adelsigL * gkfeedamt) ;Feedback
|
|
|
|
|
|
|
|
|
|
|
|
;Right channel
|
|
|
|
|
|
abufferR delayr 5 ;Buffer
|
|
|
|
|
|
adelsigR deltap3 adlt ;Tap
|
|
|
|
|
|
delayw gasigR + (adelsigR * gkfeedamt) ;Feedback
|
|
|
|
|
|
|
|
|
|
|
|
aL ntrpol gasigL, adelsigL, gkmix
|
|
|
|
|
|
aR ntrpol gasigR, adelsigR, gkmix
|
|
|
|
|
|
|
|
|
|
|
|
outs aL * gkamp, aR * gkamp ;Mix wet/dry
|
|
|
|
|
|
clear gasigL, gasigR ;Clear global audio sends
|
|
|
endin
|
|
|
endin
|
|
|
|
|
|
|
|
|
</CsInstruments>
|
|
|
</CsInstruments>
|
|
|
|
|
|
|
|
|
<CsScore>
|
|
|
<CsScore>
|
|
|
;INSTR | START | DURATION
|
|
|
|
|
|
i 2 0 -1 ;INSTRUMENT 2 (DELAY INSTRUMENT) PLAYS A HELD NOTE
|
|
|
|
|
|
|
|
|
i 2 0 -1 ;Instrument 2 plays a held note
|
|
|
|
|
|
|
|
|
f 0 3600 ;'DUMMY' SCORE EVENT KEEPS REALTIME PERFORMANCE GOING FOR 1 HOUR
|
|
|
|
|
|
|
|
|
f 0 3600 ;Keep performance going
|
|
|
</CsScore>
|
|
|
</CsScore>
|
|
|
|
|
|
|
|
|
</CsoundSynthesizer>
|
|
|
</CsoundSynthesizer>
|