Why is Clock not a subclass of Scheduler (or why can't I .advance a Clock)?

Is there a good reason why Clock is not a subclass of Scheduler and so it doesn’t have an advance method? Granted, one can do nearly the same thing with a high time compression, which can also be pre-set just for a given time period (i.e. what would be argument to advance) using a “self-modifying” clock:

c = TempoClock(1)
p = Pbind.new(\instrument, \default, \dur, 2, \degree, Pseq([1,2,3], inf)).play(c)

x = c.tempo; // save current tempo
(c.sched(12, { c.tempo = x; nil }); // compress the next 12 secs...
c.tempo = 10;)                      // by a factor of 10

But still, since Clocks are logical times, is there a good reason why they don’t support “instant” jumps ahead with advance?

SystemClock and AppClock run in seconds, so it doesn’t make sense to do that.

TempoClock has a beats_ setter method.

r = fork {
	10.do { |i|

TempoClock.default.sched(3, {
	TempoClock.default.beats = TempoClock.default.beats + 5;


This method doesn’t create any race conditions with postln’s but alas it does with actual sounds (unlike accelerating the clock, my initial “hack”). As with all race conditions, this can be a bit hard to repro… Here’s code that “works for me”, or rather fails for me:

c = TempoClock()
p = PmonoArtic(\default, \dur, 0.1).play(c)

c.beats = c.beats + 3 // hit a few times until the sound pattern becomes permanently irregular
p.stop // some hanged notes are still playing forever, need to Cmd+. stop them!!

Aha, you didn’t say you were going to be playing tasks when you jump time.

If you send a note-on (s_new) message at one moment and, within the same control block, set its gate to 0, then notes are likely to get stuck. So it isn’t safe to jump instantaneously in this case, actually.

I’m not clear on the expectation… Are you looking for an Ableton Live kind of timeline, where you can jump to any moment on demand? I wouldn’t use the physical clock for this. I’d associate moments on a virtual timeline with the physical clock, and change the mapping when you need to jump – the clock continues uninterrupted while the timeline does as you wish.


1 Like

I wasn’t planning to do something that complicated (with the clock), I was just annoyed that that notes being currently played don’t get immediately gated out (released when a Pbind (or PmonoArtic with legato < 1) is stopped.