Forgot a help fix: Drag a dock's title bar, not divider, to reposition
[supercollider.git] / HelpSource / Classes / AppClock.schelp
blob067a786616b9fe0c53e8a3cf3a365f61c28e758b
1 CLASS::AppClock
2 categories::Scheduling>Clocks
3 summary::Clock running on main application thread
4 related::Classes/SystemClock, Classes/TempoClock
6 DESCRIPTION::
7 SystemClock is more accurate, but cannot call Cocoa primitives. AppClock is less accurate (uses NSTimers) but can call Cocoa primitives.
9 You will need to use the link::Classes/SystemClock:: to get accurate/musical scheduling.
11 CLASSMETHODS::
13 private::initClass
15 method::sched
16 The float you return specifies the delta to resched the function for. Returning nil will stop the task from being rescheduled.
17 code::
19 AppClock.sched(0.0,{ arg time;
20         ["AppClock has been playing for ",time].postln;
21         rrand(0.1,0.9);
22 });
25 code::
27 AppClock.sched(2.0,{
28         "2.0 seconds later".postln;
29         nil;
30 });
34 method::clear
35 Clear the AppClock's scheduler to stop it.
36 code::
37 AppClock.clear;
40 method::play
41 The link::Classes/Routine:: (or link::Classes/Task::) yields a float value indicating the delta (secs) for the AppClock to wait until resuming the Routine.
42 code::
44 var w, r;
45 w = Window.new("trem", Rect(512, 256, 360, 130));
46 w.front;
47 r = Routine({ arg appClockTime;
48         ["AppClock has been playing for secs:",appClockTime].postln;
49         60.do({ arg i;
50                 0.05.yield;
51                 w.bounds = w.bounds.moveBy(10.rand2, 10.rand2);
52                 w.alpha = cos(i*0.1pi)*0.5+0.5;
53         });
54         1.yield;
55         w.close;
56 });
57 AppClock.play(r);
61 method::tick
62 AppClock.tick is called periodically by the SuperCollider application itself. This updates the link::Classes/Scheduler:: and causes any scheduled tasks to be executed. You should never call this method yourself.