Hi Everyone. Sorry that I posted this before and deleted it. I hope that doesn´t cause confusion. I´m new to the forums but already learning alot!
I´ve created a Karplus Strong String model using a Delay UGen. Now I would like to translate that same code, but this time to using a Buffer as a delay line. My “translation” is not working - Maybe someone can spot what is going wrong with my BufRd and BufWr usage.
First the Karplus Strong model with DelayC. I´ve also set it up so that I can tune the “string” but it doesn´t work in higher frequencies (this is a whole other question - feel free to help me with this as well):
(
SynthDef(\karplus_tuneable, { arg impulse = 0.5, amp = 0.5, del = 440, gain = 0.99, lpf = 2000;
var in = Impulse.ar(impulse);
var infeed = LocalIn.ar(1);
var delay = DelayC.ar(in + infeed, 3, (1/del) - (1/s.sampleRate * s.options.blockSize));
var lpdelay = LPF.ar(delay * gain, lpf);
LocalOut.ar(lpdelay);
Out.ar(0, lpdelay*amp!2);
}).add
)
x = Synth(\karplus_tuneable, [\del, 440]);
And here, my “translation” to using a Buffer. (Doesn´t work, although a cool sound results).
~buffer = Buffer.alloc(s, s.sampleRate * 8.0, 1);
(
SynthDef(\karplus_buffer, { arg impulse = 0.5, length = 1;
var in = Impulse.ar(impulse);
var infeed = LocalIn.ar(1);
var frames = BufFrames.kr(~buffer.bufnum) * length;
var phasor = Phasor.ar(0, BufRateScale.kr(~buffer.bufnum), 0, frames);
var bufferIn = BufWr.ar(impulse + infeed, ~buffer, phasor, 0, frames);
var bufferOut = BufRd.ar(1, ~buffer.bufnum, phasor * frames) * 0.9;
var outfeed = LocalOut.ar(bufferOut);
DetectSilence.ar(infeed, doneAction: 2);
Out.ar(0, Limiter.ar(bufferOut, 0.2));
}).add
)
x = Synth(\karplus_buffer, [\length, 1]);
What have I done wrong? Why isn´t buffer behaving? What am I missing?
Thank you!