Hi everyone!
I’ve currently run into an issue with trying to randomize my delay. I’ve tried different things and also just tested with one of the knob-parameters. But basically what I need is a button that either generates random values of my delay-parameters and when turned off, I want to control it myself.
I assume I have to add it into my if-statement somehow, but currently nothing happens when I click the code.
This is the code!
EDIT: Now formatted!
<Cabbage>
form caption("Freezer") size(700, 450), guiMode("queue") pluginId("1011"), ;bundle "snare.wav"
image bounds(0, 0, 700, 450) channel("image10013") file("distortion.png") alpha(0.24)
;REVERB + FREEZE
groupbox bounds(0, 2, 317, 178) channel("groupbox66") colour(41, 21, 21, 255)
label bounds(102, 2, 100, 21) channel("Reverb") text("Reverb") textColour(255, 255, 255, 255) fontColour(157, 202, 33, 255)
rslider bounds(14, 30, 60, 60) channel("Reverb-mix") range(0, 1, 0, 1, 0.001) text("Mix") textColour(255, 255, 255, 255) trackerColour(157, 202, 33, 255)
rslider bounds(114, 30, 60, 60) channel("Feedback") range(0.1, 1, 0.1, 1, 0.001) text("Feedback") textColour(255, 255, 255, 255) trackerColour (157, 202, 33, 255)
rslider bounds(218, 30, 60, 60) channel("Frekvens") range(100, 20000, 20000, 1, 0.001) text("Low-Pass") textColour(255, 255, 255, 255) trackerColour(157, 202, 33, 255)
checkbox bounds(2, 114, 298, 54) channel("Freeze") text("Freeze Reverb") fontColour:0(255, 0, 0, 255) fontColour:1(0, 255, 0, 255) colour:0(255, 0, 0, 255)
;DELAY
groupbox bounds(384, 4, 316, 175) channel("groupbox68") colour(17, 14, 14, 255)
label bounds(500, 2, 104, 19) channel("label10048") text("Delay") fontColour(255, 255, 0, 250)
rslider bounds(624, 110, 50, 42) channel("dLowpass") range(0, 20000, 20000, 0.2, 0.001) text("LPF") textColour(255, 255, 255, 255) trackerColour(255, 255, 0, 255)
rslider bounds(620, 54, 59, 45) channel("dHighpass") range(0, 20000, 0, 0.2, 0.001) text("HPF") colour(255, 255, 255, 255) textColour(255, 255, 255, 255) trackerColour(255, 255, 0, 255)
rslider bounds(410, 28, 56, 60) channel("DelayMix") range(0, 1, 0, 1, 0.001) trackerColour(255, 255, 0, 250) text("Mix") textColour(255, 255, 255, 255)
rslider bounds(478, 28, 60, 60) channel("DelayTime") range(10, 1500, 0, 1, 0.001) trackerColour(255, 255, 0, 250) text("Time in ms") textColour(255, 255, 255, 255)
rslider bounds(548, 28, 60, 60) channel("DFeedback") range(0, 1, 0, 1, 0.001) trackerColour(255, 255, 0, 250) text("Feedback") textColour(255, 255, 255, 255)
checkbox bounds(410, 100, 169, 39) channel("RandomDelay") text("Random Delay") fontColour:1(0, 255, 0, 255) fontColour:0(255, 0, 0, 255) colour:0(255, 0, 0, 255)
;MASTER & SAMPLE/DIRECT INPUT-kontrol
groupbox bounds(1, 250, 355, 200) channel("groupbox68") colour(17, 14, 14, 255)
label bounds(88, 250, 154, 18) channel("label10050") text("Master-controls") fontColour(197, 109, 109, 255)
rslider bounds(6, 320, 75, 64) channel("Speed") range(1, 5, 1, 1, 0.125) text("Sample Speed") textColour(197, 109, 109, 255) trackerColour(0, 255, 0, 255)
checkbox bounds(8, 276, 169, 39) channel("kEnableSample") text("Sample/Input") fontColour:1(0, 255, 0, 255) fontColour:0(255, 0, 0, 255) colour:0(255, 0, 0, 255)
rslider bounds(606, 354, 91, 91), channel("Gain"), range(0, 1, 0.5, 1, 0.01), text("Master"), trackerColour(0, 255, 0, 255), outlineColour(0, 0, 0, 50), textColour(0, 17, 5, 255)
rslider bounds(90, 322, 83, 63) channel("PitchScale") range(0, 2, 1, 1, 0.001) text("Scale") textColour(197, 109, 109, 255) trackerColour(0, 255, 0, 255)
vslider bounds(290, 278, 50, 158) channel("Shift") range(0, 1000, 0, 0.3, 0.001) text("PShift") textColour(197, 109, 109, 255) trackerColour(0, 255, 0, 255)
hslider bounds(158, 116, 150, 50) channel("FreezeFreq") range(0, 20000, 0, 1, 0.001) text("Freq Modulation") textColour(255, 255, 255, 255)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d
</CsOptions>
<CsInstruments>
ksmps = 32
nchnls = 2
0dbfs = 1
;GLOBALE VÆRDIER
gaRevL init 0
gaRevR init 0
gaDel init 0
gaSend init 0
instr 1
;Cabbage-værdier i instrumentet
;______________________________________
kGain cabbageGetValue "Gain"
kSpeed cabbageGetValue "Speed"
kEnable cabbageGetValue "kEnableSample"
kPitchShiftRandom cabbageGetValue "kPitchShiftRandom"
kShift cabbageGetValue "Shift"
kScale cabbageGetValue "PitchScale"
kPitchShiftRandom randh 8, 0.8
kShift += kPitchShiftRandom
;Sample eller stemme som bliver analyseret af PVS
;______________________________________
;Gjør at når sample-button er på, bruger den sample og når den er slået fra bruger den mikrofon-input
if kEnable == 0 then // sample
asig1, asig2 diskin2 "sampletest.wav", 1*kSpeed, 0, 1
elseif kEnable == 1 then // mikrofon
aIn1 inch 1
aIn2 inch 2
asig1 = aIn1
asig2 = aIn2
endif
;Værdier som skal ind for selve PVS-analysen
ifftsize = 1024
ioverlap = ifftsize/4
iwinsize = 1024
iwintype = 0
inbins = ifftsize/2 + 1
;Trækker ut parametere for henvoldvis at skalere og pitch-shifte signalet
;___________
fSig1 pvsanal asig1, ifftsize, ioverlap, iwinsize, iwintype
fSig2 pvsanal asig2, ifftsize, ioverlap, iwinsize, iwintype
fScale1 pvscale fSig1, kScale
fScale2 pvscale fSig2, kScale
fShift1 pvshift fScale1, kShift, 0
fShift2 pvshift fScale2, kShift, 0
aOut1 pvsynth fShift1
aOut2 pvsynth fShift2
gaSend += (aOut1 +aOut2) * kGain
endin
;REVERB
;________________________________________________________
instr 2
kFeedback cabbageGetValue "Feedback"
kFrekvens cabbageGetValue "Frekvens"
kFreeze chnget "Freeze"
kFreezeFreq chnget "FreezeFreq"
gaRevL, gaRevR reverbsc gaSend, gaSend, kFeedback, kFrekvens
;FREEZE-REVERB
;_____________________
ifftsize = 1024
ioverlap = ifftsize/4
iwinsize = 1024
iwintype = 0
fSigL pvsanal gaRevL,ifftsize, ioverlap, iwinsize, iwintype
fSigR pvsanal gaRevR, ifftsize, ioverlap, iwinsize, iwintype
fOutL pvsfreeze fSigL, kFreeze, kFreezeFreq
fOutR pvsfreeze fSigR, kFreeze, kFreezeFreq
aOutL pvsynth fOutL
aOutR pvsynth fOutR
;Gør at Freeze-signalet er lig med reverb signalet, så det kommer ind, når jeg summerer i mastervolumen.
gaRevL = aOutL
gaRevR = aOutR
endin
;DELAY
;________________________________________________________
instr 3
aFeed init 0
kDelayTime cabbageGetValue "DelayTime"
kFeedback cabbageGetValue "DFeedback"
kRandomDelay cabbageGetValue "RandomDelay"
if kRandomDelay == 1 then
kDelayTime randh 10, 1500, 1 ;
kFeedback randh 0, 1, 1
kDelayMix randh 10, 100, 1
endif
aTime interp kDelayTime
aTime tone aTime, 1
aDelay vdelay gaSend + aFeed, aTime, 1500
kLowpass cabbageGetValue "dLowpass"
kHighpass cabbageGetValue "dHighpass"
aLowpass butterlp aDelay, kLowpass
aHighpass butterhp aDelay, kHighpass
aFeed = 0.5*(aHighpass + aLowpass) * kFeedback
gaDel += aDelay
endin
;MASTER-INSTRUMENT
;_____________________
instr 50
kRevMix cabbageGetValue "Reverb-mix"
kDelayMix cabbageGetValue "DelayMix"
;Mixslider for Delay
aDel = gaDel * kDelayMix
;Summering af signaler i effekt
aMixL = gaSend * (1-kRevMix) + gaRevL*kRevMix + aDel
aMixR = gaSend * (1-kRevMix) + gaRevR*kRevMix + aDel
outs aMixL, aMixR
;GLOBAL VALUES
gaDel = 0
gaRevL = 0
gaRevR = 0
gaSend = 0
endin
</CsInstruments>
<CsScore>
f0 z
i1 0 z
i2 0 z
i3 0 z
i50 0 z
</CsScore>
</CsoundSynthesizer>