I wonder if anyone can help with a SC performance question?
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 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.
Is this just something to be expected when running SC under OS X with other things happening on the machine, or is there something wrong in the way I’m using SC? Are there any tips for achieving more solid timing?