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

[sc-dev] network time in sclang

assuming that the system time is set corectly, how could I achieve synchronicity of tasks on two clients? When I send a message to two servers, this is no problem, as the server schedules relative to network time. What do I have to do to get the same on the client?

trying it this way:
var t, theTask;
theTask = { Main.elapsedTime.postln; nil };
t =  Date.localtime.bootSeconds;
SystemClock.sched(t.roundUp(1.0) - t, theTask)

there seems to be a lot of jitter though:

var t, theTask, x;
x = Main.elapsedTime;
theTask = Routine { loop { (Main.elapsedTime - x).postln; 1.wait } };
t =  Date.localtime.bootSeconds;
SystemClock.sched(t.roundUp(1.0) - t, theTask);
SystemClock.sched(0.0, Routine { loop { x = Main.elapsedTime; 1.wait } });

When a bundle is made in sclang, the scheduled time is:

time += g->thread->seconds.uf; (latency + thisThread.seconds)

but when I look up thisThread.seconds it seem to be the seconds from
a bit later than startup, which is not 1970. As two clients start at different
times, their reference times seem totally unrelated.

under os x Main.elapsedTime returns:
AudioGetCurrentHostTime  - gHostStartNanos
(whereas under linux it is GetTimeOfDay).

How is this related to network time? Where is this connection made?