I had a question about best practices in loading and playing a buffer.
Essentially, I’ve made a single DragSink GUI element that I’d like to load an audio file into and have it start playing. I understand that it takes a few seconds, on average, between loading a buffer and starting a Synth.
Is the best approach to have the DragSink reference a function with a built-in Routine that executes the steps with some gap time between them? Or is there a better approach?
As @Spacechild1 says, use Buffer.read but you also need to put this in a routine with s.sync to wait for the buffer to load. On my machine it takes about 4ms to load a buffer of a couple of seconds.
(
{
var t = Main.elapsedTime;
b = Buffer.read(s, ...path to your buffer ....);
s.sync;
(Main.elapsedTime - t).postln;
b.play
}.fork
)