Check PlayBuf’s Help File. In case you don’t know it, you can open an Help page (Documentation) for every class in SuperCollider by putting your cursor on it and pressing Ctrl+D (or Cmd+D on a mac).
It explains all the arguments PlayBuf takes and also gives some code examples you can execute right away
The only catch about PlayBuf compared to BufRd is that when you change its start position you need to retrigger it. It won’t jump to the new position by itself. In your case you can do it easily like this: automatically trigger PlayBuf when the start position changes.
SynthDef(\player){|out=0, bufNum=0, start=0|
Out.ar(out,
PlayBuf.ar(1, bufNum,
rate: BufRateScale.ir(bufNum),
trigger: Changed.kr(start),
start: start,
loop:0
)
)
}.add;
x = Synth(\player,[bufnum:b]);
// now when you set a new start, PlayBuf will jump to it (popping)
x.set(\start, 44100);
x.set(\start, 44100 * 2);
x.set(\start, 0);
// ...
And PlayBuf doesn’t take an end argument. We are not anymore controlling a “playhead” directly, there is no Phasor (since the precise phase is handled internally by PlayBuf), but we can still make it jump to a new position by changing the start
parameter and sending a trigger to its ‘trigger’ parameter (which updates the internal phase to the new start).
So, you won’t get those small loops anymore. Instead, the player will just continue playing. (Want the loops again? One way with PlayBuf is to “retrigger” it rhytmically with an Impulse.kr(1/loopDur): trig: Changed.kr(start) + Impulse.kr(1/loopDur)
)
The reason why I’m not sending you yet some code for loading a soundfile into separate shorter buffer is that loading them is quite straightforward, but then we would have to find a clever system to handle the situation when a “skip” happens across the boundaries between two different buffers. I can’t find a way to do it without adding a lot of complexity to your code, which can be avoided by using PlayBuf with only one “long” buffer.