Hey, i was wondering i someone could help me adjusting the Code of the PV_BinDelay, so the parameters delay and feedback could be sequenced in a Pbind vs. using the GUI.
Im not sure if this is even possible and how the buffer data is handled in this case. thanks alot
(
s.doWhenBooted({
var size, fftSize, awin, delaySilder, fbSlider, maxdel, synth, cond;
var setup, onReadyFunc, fftBuffer, delTimeBuffer, fbAmtBuffer, createGUI;
size = 128;
fftSize = size * 2;
maxdel = 0.5;
cond = Condition.new;
SynthDef(\spectralDelay, {
arg pan=0, amp=0.5, in=0, inMix=0, out=0, freq=150,
fftBuf=0, delayBuf=0, fbBuf=0, maxdel=0.5;
var sig, input, chain;
var env = EnvGen.kr(Env.perc(0.01,1), doneAction:2);
input = Saw.ar(freq) * env * amp;
//input = In.ar(in, 2) * inMix;
chain = FFT(fftBuf, input, 0.25);
chain = PV_BinDelay(chain, maxdel, delayBuf, fbBuf, 0.25);
sig = IFFT(chain).dup;
Out.ar(out, sig * amp);
}).add;
/* Functions that allocate buffers and call onReadyFunc when done */
setup = {
Routine.run({
"Allocating FFT buffer".postln;
fftBuffer = Buffer.alloc(s, fftSize, 1);
"Allocating DelTime buffer".postln;
delTimeBuffer = Buffer.alloc(s, size, 1);
"Allocating FB buffer".postln;
fbAmtBuffer = Buffer.alloc(s, size, 1);
s.sync(cond);
onReadyFunc.value()
});
};
createGUI = {
awin = Window("test", Rect(200 , 450, 10 + (size * 1), 10 + (size * 2)));
awin.view.decorator = FlowLayout(awin.view.bounds);
delaySilder = MultiSliderView(awin, Rect(0, 0, size * 1, size * 1));
delaySilder.action = {arg xb;
("Deltime index: " ++ xb.index ++" value: " ++ (xb.currentvalue * maxdel)).postln;
delTimeBuffer.set(xb.index, xb.currentvalue * maxdel)
};
fbSlider = MultiSliderView(awin, Rect(0, 0, size * 1, size * 1));
fbSlider.action = {arg xb;
("FB index: " ++ xb.index ++" value: " ++ xb.currentvalue).postln;
fbAmtBuffer.set(xb.index, xb.currentvalue)
};
[delaySilder, fbSlider].do({
arg thisSliderView;
var initDataArray;
initDataArray = Array.fill(size, {0.0});
thisSliderView.value_(initDataArray);
thisSliderView.xOffset_(5);
thisSliderView.thumbSize_(12.0);
// value axis size of each blip in pixels
thisSliderView.valueThumbSize_(15.0);
// index axis size of each blip in pixels
thisSliderView.indexThumbSize_( thisSliderView.bounds.width / initDataArray.size );
thisSliderView.gap = 0;
});
awin.front;
awin.onClose_({
synth.free;
fftBuffer.free;
fbAmtBuffer.free;
delTimeBuffer.free;
})
};
onReadyFunc = {
createGUI.defer();
Pbind(
\instrument, \spectralDelay,
//\in, ~bus[\spectral],
\inMix, 1,
\fftBuf, fftBuffer.bufnum,
\delayBuf, delTimeBuffer.bufnum,
\fbBuf, fbAmtBuffer.bufnum,
\amp, 0.5,
\pan, 0,
\out, 0,
).play;
};
setup.value();
})
)