Dear All,
I am working on a visual metronome with Open Stage Control (JS) and would like to sync multiple clients. I provide a basic example below within SC. Is it possible to introduce a delay for the latency and send the sendPattern
ahead of time with a future timestamp so that the client can know when to actually trigger the action? Thanks in advance. Suggestions welcome for other ways to potentially do this.
// run this to receive the messages
(
OSCdef(\receiver, {arg msg, time, addr, port;
msg.postln;
}, \playing);
)
// run this to send the messages
(
var playPattern, sendPattern, stream, offset, offsetStream, tempoClock, player;
Event.addEventType(\osc, {
if (~addr.postln.notNil) {
~addr.sendMsg(~path, *~msg);
};
});
playPattern = Pbind(
\freq, Pseq([300, 350, 400, 450], inf),
\dur, 1
);
sendPattern = Pbind(
\type, \osc,
\addr, NetAddr.localAddr,
\path, "/playing",
\msg, Pseq([1, 2, 3, 4, 5, 6, 7, 8], inf),
\dur, 1
);
stream = Ppar([playPattern, sendPattern]).asStream;
offset = stream.fastForward(2);
offsetStream = Routine({offset.wait});
player = EventStreamPlayer(offsetStream ++ stream);
tempoClock = TempoClock(45/60.0);
player.play(tempoClock);
)