|
BTW, there are some problems using Routine and Task, if you need to
start and stop them in rapid succession (see posts from earlier this
year concerning "routine buildup"). James Harkins provided a wonderful
solution for this called BetterTask, which I attach to this message. LF Esben Stien wrote: tom tlalim <ttlalim@xxxxxxxxx> writes: |
{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf110
{\fonttbl\f0\fnil\fcharset77 Monaco;\f1\fswiss\fcharset77 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
\f0\fs18 \cf0 \
////BettetTask by James Harkins\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
\f1\fs24 \cf0 BetterTask : Task \{\
var <isWaiting = false;\
\
play \{ arg argClock, doReset = (false), quant=0.0;\
if (stream.notNil, \{ "already playing".postln; ^this \});\
if (doReset, \{ this.reset \});\
clock = argClock ? clock ? TempoClock.default;\
streamHasEnded = false;\
stream = originalStream;\
isWaiting = true;\
clock.play(\{\
if(isWaiting and: \{ nextBeat.isNil \}) \{\
clock.sched(0, this);\
isWaiting = false;\
\};\
nil\
\}, quant);\
^this\
\}\
\
stop \{\
stream = nil;\
isWaiting = false;\
\}\
\
pause \{ this.stop \}\
\}
\f0\fs18 \
\
}