I’m having trouble changing the playback rate as I stream a buffer. I’d like to be able to use a hardware controller to change the rate as the buffer is playing.
At the moment I am reading an external sample into a buffer. Here is the player. I am using doneAction:1 so that triggering the gate just pauses playback, which can recommence when the player is restarted:
player = { | gate=1, rate=1.0, startPos=0 |
var env;
env = EnvGen.kr (
Env.adsr(1, 0.5, 0.95, 0.3, 0.5, 1.0, -6.0),
gate,
doneAction:1);
PlayBuf.ar( 1,
buf,
BufRateScale.kr(buf) * rate,
startPos:startPos,
loop:1 ) * env };
New samples are loaded into a buffer like this:
buf = Buffer.read(s, path);
and they are played and stopped like this:
// start
controller = player.play;
// stop / pause
controller.set(\gate, 0)
I had hoped that by setting the rate using:
BufRateScale.kr(pInfo[\buffer]) * rate
eg. I assumed I would be able to continuously change the rate by setting the value of rate using:
controller.set(\rate, -0.5)
But that doesn’t work. What should I be doing?
Thanks in advance
Andy