File: schedBundle.sc

package info (click to toggle)
supercollider 1%3A3.6.6~repack-2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 23,792 kB
  • ctags: 25,269
  • sloc: cpp: 177,129; lisp: 63,421; ansic: 11,297; python: 1,787; perl: 766; yacc: 311; sh: 286; lex: 181; ruby: 173; makefile: 168; xml: 13
file content (70 lines) | stat: -rw-r--r-- 1,774 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// these support different ways of specifying the timing of a scheduled event
// see the atTime help file

+ Nil { // now
	schedBundle { arg bundle,server,timeOfRequest;
		bundle.send(server,nil,nil); //0.0
	}
}


+ Float { // relative seconds
	schedBundle {  arg bundle,server,timeOfRequest;
		// this also need doPrepare
		bundle.send(server,this,timeOfRequest);
	}
}
/**
  * 1 : bar
  * 2 : half-note
  * 4 : quarter note
  * 8 : 8th note
  * 16 : 16th note
  */
+ Integer { // at the next N beat
	schedBundle { arg bundle,server,timeOfRequest;

		bundle.doPrepare(server,{
			var now,nowRound,latencyBeats,deltaTillSend;
			latencyBeats = Tempo.secs2beats(server.latency ? 0.05);
			now = TempoClock.default.elapsedBeats;
			nowRound = now.roundUp(4 / this);

			deltaTillSend = (nowRound - now - latencyBeats);
			if(deltaTillSend < 0.05,{
				nowRound = nowRound + (4/this);
				deltaTillSend = (nowRound - now - latencyBeats);
			});

			TempoClock.default.sched( deltaTillSend, {
				var lateness,delta;
				// this executes at Server.latency before the event is due.
				// calculate actual latency to the requested time
				delta = Tempo.beats2secs(nowRound -  TempoClock.default.elapsedBeats);

				/*SystemClock.sched(delta,{
					var b;
					b = TempoClock.default.elapsedBeats;
					[b,nowRound - b].debug("actual sched");
					nil;
				});*/

				bundle.prSend(server, delta,Main.elapsedTime);
				nil
			});
		});
	}
}

+ Date {
	// Date raw seconds has to be set correctly !
	// *new won't do this for you
	schedBundle { arg bundle,server,timeOfRequest;
		var delta;
		delta = rawSeconds - this.class.localtime.rawSeconds;
		if(delta >= 0.0,{
			// should we prepare this a few seconds ahead of time ?
			bundle.send(server,delta,timeOfRequest);
		});
	}
}