[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-users] latency in sclang



On investigating some timing issues in sclang I did the following test

(
var r, t1, t2, a = nil!10;
r = Routine{
	10.do{|i|
		t1 = Main.elapsedTime;
		0.1.wait;
		t2 = Main.elapsedTime;
		a[i] = t2 - t1;
		t1 = t2;
	};
	10.do{|i| a[i].postln};
};

r.play;
)

It turns out that all intervals are quite exact (jitter below 0.1 ms), with the exception of the very first being about 0.5 ms too short. This behaviour is repeatable and seems independent of the wait duration. It can be avoided by scheduling the routine with some delay

	SystemClock.sched(0.1,{r.play});
	
So it's not a serious problem in practice, but I'm curious about

a) how can this behaviour be explained in technical terms?

b) is there a default latency setting for sclang like s.latency?

Thanks for any enlightenment.

-mb