Hello! I’m experiencing some stuttering sample playback on OS X. @Geoffroy on lines suggested I ask here for help.
I’ve built a simple sampler application. A stripped down version that shows the issue looks like this:
s.waitForBoot({
~b1 = Buffer.read(s, "1.wav");
SynthDef(\sampler, {
arg obs=0, buf, rate=1, amp=1;
var sig;
sig = PlayBuf.ar(1, buf, rate, \t_tr.kr(1, 0), doneAction: Done.freeSelf);
Out.ar(obs, sig);
}).add;
~handler = {
arg msg, time, addr, recvPort;
Synth(\sampler, [\buf, ~b1.bufnum]);
};
n = NetAddr.new("127.0.0.1");
o = OSCFunc(~handler, '/sampler/1', n, 49162);
});
I’m running this sclang script from the command line (on OS X 10.14 on a macbook pro) with sclang sampler.scd
.
To reproduce the issue I’m seeing, in a separate terminal window I’m triggering the sample via OSC using sendosc in a steady pulse with while true; do sendosc 127.0.0.1 49162 /sampler/1; sleep 0.5; done
.
If I do anything fairly intensive on my machine while this is running (for example open a new browser tab for Gmail in FF), the audio stutters. It sounds like some of the OSC events are not arriving in time, and sometimes get backed up before all firing at once.
I’ve run the code in the IDE as well, and the issue is also present there. While stuttering, the CPU load reported in the IDE window is under 1%. The sound doesn’t glitch, it’s almost as if the messages are getting delayed and then several are arriving close together.
Is this just something to be expected when running supercollider under OS X with other things happening on the machine, or is there something wrong in the way I’m using sclang/OSC? Are there any tips for achieving more solid timing?