scide: LookupDialog - redo lookup on classes after partial lookup
[supercollider.git] / SCClassLibrary / Common / Control / schedBundle.sc
blob02d8644e0c34684f2d9cc05d7fa529db709ce345
1 // these support different ways of specifying the timing of a scheduled event
2 // see the atTime help file
4 + Nil { // now
5         schedBundle { arg bundle,server,timeOfRequest;
6                 bundle.send(server,nil,nil); //0.0
7         }
11 + Float { // relative seconds
12         schedBundle {  arg bundle,server,timeOfRequest;
13                 // this also need doPrepare
14                 bundle.send(server,this,timeOfRequest);
15         }
17 /**
18   * 1 : bar
19   * 2 : half-note
20   * 4 : quarter note
21   * 8 : 8th note
22   * 16 : 16th note
23   */
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);
37                         });
39                         TempoClock.default.sched( deltaTillSend, {
40                                 var lateness,delta;
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,{
46                                         var b;
47                                         b = TempoClock.default.elapsedBeats;
48                                         [b,nowRound - b].debug("actual sched");
49                                         nil;
50                                 });*/
52                                 bundle.prSend(server, delta,Main.elapsedTime);
53                                 nil
54                         });
55                 });
56         }
59 + Date {
60         // Date raw seconds has to be set correctly !
61         // *new won't do this for you
62         schedBundle { arg bundle,server,timeOfRequest;
63                 var delta;
64                 delta = rawSeconds - this.class.localtime.rawSeconds;
65                 if(delta >= 0.0,{
66                         // should we prepare this a few seconds ahead of time ?
67                         bundle.send(server,delta,timeOfRequest);
68                 });
69         }