1 // these support different ways of specifying the timing of a scheduled event
2 // see the atTime help file
5 schedBundle { arg bundle,server,timeOfRequest;
6 bundle.send(server,nil,nil); //0.0
11 + Float { // relative seconds
12 schedBundle { arg bundle,server,timeOfRequest;
13 // this also need doPrepare
14 bundle.send(server,this,timeOfRequest);
24 + Integer { // at the next N beat
25 schedBundle { arg bundle,server,timeOfRequest;
27 bundle.doPrepare(server,{
28 var now,nowRound,latencyBeats,deltaTillSend;
29 latencyBeats = Tempo.secs2beats(server.latency ? 0.05);
30 now = TempoClock.default.elapsedBeats;
31 nowRound = now.roundUp(4 / this);
33 deltaTillSend = (nowRound - now - latencyBeats);
34 if(deltaTillSend < 0.05,{
35 nowRound = nowRound + (4/this);
36 deltaTillSend = (nowRound - now - latencyBeats);
39 TempoClock.default.sched( deltaTillSend, {
41 // this executes at Server.latency before the event is due.
42 // calculate actual latency to the requested time
43 delta = Tempo.beats2secs(nowRound - TempoClock.default.elapsedBeats);
45 /*SystemClock.sched(delta,{
47 b = TempoClock.default.elapsedBeats;
48 [b,nowRound - b].debug("actual sched");
52 bundle.prSend(server, delta,Main.elapsedTime);
60 // Date raw seconds has to be set correctly !
61 // *new won't do this for you
62 schedBundle { arg bundle,server,timeOfRequest;
64 delta = rawSeconds - this.class.localtime.rawSeconds;
66 // should we prepare this a few seconds ahead of time ?
67 bundle.send(server,delta,timeOfRequest);