1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
7 <meta name=
"Generator" content=
"Cocoa HTML Writer">
8 <meta name=
"CocoaVersion" content=
"949.43">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica
; min-height: 22.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica
}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #606060}
18 p
.p9
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #0029b0; min-height: 12.0px}
19 p
.p10
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #0029b0}
20 span
.s1
{color: #0029b0}
21 span
.s2
{color: #000000}
22 span
.s3
{color: #0016bd}
23 span
.s4
{color: #606060}
24 span
.Apple-tab-span
{white-space:pre
}
28 <p class=
"p1"><b>AppClock
</b></p>
29 <p class=
"p2"><br></p>
30 <p class=
"p3"><b>superclass: Clock
</b></p>
31 <p class=
"p4"><br></p>
32 <p class=
"p5">SystemClock is more accurate, but cannot call Cocoa primitives.
</p>
33 <p class=
"p5">AppClock is less accurate (uses NSTimers) but can call Cocoa primitives.
</p>
34 <p class=
"p4"><br></p>
35 <p class=
"p5">You will need to use the SystemClock to get accurate/musical scheduling.
</p>
36 <p class=
"p6"><br></p>
37 <p class=
"p6"><br></p>
38 <p class=
"p6"><br></p>
39 <p class=
"p5"><b>*sched(delta,task)
</b></p>
40 <p class=
"p5"><span class=
"Apple-tab-span"> </span>the float you return specifies the delta to resched the function for
</p>
41 <p class=
"p6"><br></p>
42 <p class=
"p7"><span class=
"s1"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>AppClock
</span>.sched(
0.0,{ arg time;
<span class=
"Apple-converted-space"> </span></p>
43 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>[
"AppClock has been playing for ",time]
<span class=
"s2">.postln;
<span class=
"Apple-converted-space"> </span></span></p>
44 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>rrand(
0.1,
0.9)
<span class=
"Apple-converted-space"> </span></p>
45 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>});
</p>
46 <p class=
"p6"><br></p>
47 <p class=
"p5"><span class=
"Apple-tab-span"> </span>returning
<span class=
"s1">nil
</span> will stop the task from being rescheduled
</p>
48 <p class=
"p6"><br></p>
49 <p class=
"p7"><span class=
"s1"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>AppClock
</span>.sched(
2.0,{
<span class=
"Apple-converted-space"> </span></p>
50 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>"2.0 seconds later"<span class=
"s2">.postln;
<span class=
"Apple-converted-space"> </span></span></p>
51 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s1">nil
</span><span class=
"Apple-converted-space"> </span></p>
52 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>});
</p>
53 <p class=
"p6"><br></p>
54 <p class=
"p5"><b>*clear
</b></p>
55 <p class=
"p5"><span class=
"Apple-tab-span"> </span>clear the AppClock's scheduler to stop it
</p>
56 <p class=
"p9"><br></p>
57 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>AppClock
<span class=
"s2">.clear
</span></p>
58 <p class=
"p6"><br></p>
59 <p class=
"p5"><b>*play(task)
</b></p>
60 <p class=
"p5"><b><span class=
"Apple-tab-span"> </span></b>The task/Routine yields a float value indicating the delta (secs) for the AppClock to wait
</p>
61 <p class=
"p5"><span class=
"Apple-tab-span"> </span>until resuming the Routine.
</p>
62 <p class=
"p6"><br></p>
63 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(
</p>
64 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">var
</span> w, r;
</p>
65 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>w =
<span class=
"s3">Window
</span>.new(
<span class=
"s4">"trem"</span>,
<span class=
"s3">Rect
</span>(
512,
256,
360,
130));
</p>
66 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>w.front;
</p>
67 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>r =
<span class=
"s3">Routine
</span>({
<span class=
"s3">arg
</span> appClockTime;
</p>
68 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>[
</span>"AppClock has been playing for secs:"<span class=
"s2">,appClockTime].postln;
</span></p>
69 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>60.do({
<span class=
"s3">arg
</span> i;
</p>
70 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>0.05.yield;
</p>
71 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>w.bounds = w.bounds.moveBy(
10.rand2,
10.rand2);
</p>
72 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>w.alpha = cos(i*
0.1pi)*
0.5+
0.5;
</p>
73 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>});
</p>
74 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>1.yield;
</p>
75 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>w.close;
</p>
76 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>});
</p>
77 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">AppClock
</span>.play(r);
</p>
78 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>)
</p>
79 <p class=
"p6"><span class=
"Apple-tab-span"> </span></p>
80 <p class=
"p5"><b>*tick
</b></p>
81 <p class=
"p5"><span class=
"Apple-tab-span"> </span>AppClock.tick is called periodically by the SuperCollider application itself.
</p>
82 <p class=
"p5"><span class=
"Apple-tab-span"> </span>This updates the Scheduler and causes any scheduled tasks to be executed.
<span class=
"Apple-converted-space"> </span>You
</p>
83 <p class=
"p5"><span class=
"Apple-tab-span"> </span>should never call this method yourself.
</p>
84 <p class=
"p4"><br></p>
85 <p class=
"p4"><br></p>