From 771eba53fc4e6155085938105e89a6fd95973ded Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Mon, 28 Dec 2015 14:16:28 -0500 Subject: [PATCH] Fun with scheduling --- sclang-play/tutorial.sc | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/sclang-play/tutorial.sc b/sclang-play/tutorial.sc index 8508916..7dfd76d 100644 --- a/sclang-play/tutorial.sc +++ b/sclang-play/tutorial.sc @@ -736,3 +736,45 @@ SystemClock.sched(10, { x.free; b.free; }); ) + +( + SystemClock.sched(5, { "hello".postln }); +) + +( + var timeNow = TempoClock.default.beats; + "Time is now: ".post; + timeNow.postln; + "Scheduling for: ".post; + (timeNow + 5).postln; + TempoClock.default.schedAbs(timeNow + 5, + { "Time is later: ".post; thisThread.clock.beats.postln; nil } + ); +) + +( + var timeNow; + "------------------------------------".postln; + TempoClock.default.tempo = 2; + timeNow = TempoClock.default.beats; + "Time is now: ".post; + timeNow.postln; + "Scheduling for: ".post; + (timeNow + 5).postln; + TempoClock.default.schedAbs(timeNow + 5, + { "Time is later: ".post; thisThread.clock.beats.postln; nil } + ); +) + +( + "SystemClock.beats: ".post; SystemClock.beats.postln; + "TempoClock.default.beats: ".post; TempoClock.default.beats.postln; + "AppClock.beats: ".post; AppClock.beats.postln; + Task({ + "thisThread.clock.beats: ".post; thisThread.clock.beats.postln; + }).play; +) + +( + TempoClock.default.sched(5, { "hello".postln; nil; }); +)