3 classvar <>verbose = false, <all, <defaultClock;
4 var <updateFunc, <>dt, <>stopTest, <name, <clock, <task, restartFunc;
6 *new { arg updateFunc, dt = 0.2, stopTest = false, name = "anon", clock, autostart=true;
7 ^super.newCopyArgs(updateFunc, dt, stopTest, name, clock).init( autostart );
13 defaultClock = AppClock;
16 *stop { |name| all.do { |skip| if (skip.name == name) { skip.stop } }; }
18 *stopAll { all.do(_.stop).clear; }
20 init { |autostart=true|
22 if( verbose ) { ("SkipJack" + name + "starts.").postcln };
23 while { dt.value.wait; stopTest.value.not } { updateFunc.value(this) };
26 if ( autostart ) { this.start };
30 task.play(clock ? defaultClock);
31 if( verbose ) { ("SkipJack" + name + "is back up.").postcln };
36 if( verbose ) { ("SkipJack" + name + "already playing.").postcln };
39 task.reset.play(clock ? defaultClock);
42 if( verbose ) { ("SkipJack" + name + "started.").postcln };
50 CmdPeriod.remove(this);
51 if( verbose ) { ("SkipJack" + name + "stopped.").postcln };
56 *new { arg name = "anon", updateFunc, dt=0.2, stopTest = false;
57 "Watcher is only for backward compatibility, use SkipJack!".postln;
58 ^super.newCopyArgs(updateFunc, dt, stopTest, name).init.start;