Play pause global tempo clock

Hi, I have many routines in my project and a variable like this storing the tempo ~tempo = TempoClock.tempo_(180/60);.

I would like to be able to play and pause this clock instead of attempting to restart all my routines. Is it possible? I have tried stopping the clock it but when I create a new clock then nothing happens. How could I implement a solution? Thanks

You could try setting the tempo to 0, perhaps.

hjh

You are not allowed to set a TempoClock to 0, but you can use etempo_(0) and send a gate = 0 message to all the nodes in the group. Another approach is to keep everything in Pdefs and iterate over the list of Pdefs, but this won’t preserve the timing between Pdefs if they were started on different beats of the bar or are of different lengths.

~tempo = 1.5;
t = TempoClock(~tempo);

(
s.waitForBoot{
	~group = Group.new;
	s.sync;
	Pdef(\a, Pbind(\dur, 0.5, \midinote, Pwhite(50, 60), \group, ~group)).play(t);
	Pdef(\b, Pbind(\dur, 0.75, \midinote, Pwhite(50, 60), \group, ~group)).play(t);
}
)

(
t.etempo_(0); // stop
~group.set(\gate, 0); // free notes
)

t.etempo_(~tempo); // resume

/// another approach

[\a, \b].collect{|n|Pdef(n).stop } // stop
[\a, \b].collect{|n|Pdef(n).play(t) }