2 categories::Scheduling>Clocks
3 summary:: Clock running on separate accurately timed thread
4 related::Classes/AppClock, Classes/TempoClock
8 SystemClock is more accurate, but cannot call Cocoa primitives. AppClock is less accurate (uses NSTimers) but can call Cocoa primitives.
13 The float you return specifies the delta to resched the function for. Returning nil will stop the task from being rescheduled.
16 SystemClock.sched(0.0,{ arg time;
24 SystemClock.sched(2.0,{
25 "2.0 seconds later".postln;
32 Clear the SystemClock's scheduler to stop it.
40 SystemClock.schedAbs( (thisThread.seconds + 4.0).round(1.0),{ arg time;
41 ("the time is exactly " ++ time.asString
42 ++ " seconds since starting SuperCollider").postln;
48 Calls to the cocoa framework (including all GUI) may not be made directly from actions triggered by SystemClock or incoming socket messages (OSCFunc).
50 To get around this, use code::{ }.defer ::. This will execute the function using the AppClock and is equivalent to code::AppClock.sched(0, function)::
55 w = Window.new("trem", Rect(512, 256, 360, 130));
57 r = Routine({ arg time;
61 w.bounds = w.bounds.moveBy(10.rand2, 10.rand2);
62 w.alpha = cos(i*0.1pi)*0.5+0.5;
71 This example is only to show how to make calls to Cocoa/GUI when scheduling with the SystemClock. If you only wish to control the GUI, use AppClock.