Events playing late in simple Pbind or Routine

While playing this, which is a basic bassdrum sound, I got a weird lagging of each event. I also got some strange messages in the post window saying “late 0.08973143” accompanying an odd event.

I tried sending it to a friend who could not replicate the results. Is this a known bug? And if so, is there a fix? I thought it could be a difference of stability between Routine and Pbind, but they seem to exhibit the same behaviour.

I am using SCNvim on nvim 0.8.0 but have not updated to lua-config yet. Could it be an issue with the nvim version?

s.waitForBoot({

	(
		SynthDef(\micro, {
			var sig, env, noise;

			noise = LFNoise2.ar(300);

			env = EnvGen.kr(
				Env.perc(
					\atk.kr(0.01), 
					\rel.kr(0.65),
					curve: -4),
					\t_trig.kr(1),
					doneAction: 2
				);

				sig = SinOsc.ar(
					\freq.kr(30) * XLine.kr(2.5, 1, 0.45)
				);

				Out.ar(
                    // sending to main and output 7 on device
					[0, 6], 
					(sig!2 + (noise * 0.17))* \vol.kr(0.2)*env
				);

			}).add;
		)

	s.sync;

	(
		r = Routine.new({ loop{
			Synth.new(\micro);
			wait(0.5); } }
		);

		p = Pbind(
			\instrument, \micro,
			\dur, Pseq([0.5], inf),
			\freq, 30,
		);
	)

	r.play;
	// p.play;
});

See this thread for an explanation of “late” messages.

In short, you probably want to adjust the server latency (s.latency) and use s.bind inside the Routine. This will ensure perfect sync between synths generated inside Routines and those generated by Pbinds. By default, s.bind and Pbind both use s.latency to defer the timestamp of OSC messages by this amount, which allows for precise timing, but you can also choose different latency values by using s.makeBundle in a Routine (instead of s.bind) or by changing the \latency key of a Pbind.

s.latency = 0.2;

(
r = Routine.new({ loop{
    s.bind{ Synth.new(\micro) };
    wait(0.5); } }
);

p = Pbind(
    \instrument, \micro,
    \dur, Pseq([0.5], inf),
    \freq, 30,
);
)

(
r.play;
p.play;
)

Thanks a lot! I knew there was something I had forgotten.