what is the best way to continuously execute (loop) a function inside a
task? I am currently using
b = Task({inf.do({“bang!”.postln; 1.wait})}, t);
and feel this can be improved to have the .wait time become dependent on
the TempoClock’s speed even?
Thanks for all ideas here, much appreciated!
best, Peter
Or loop { ... }. Personally I feel that loop { ... } is less visually noisy than inf.do { ... } but there should be no functional difference.
The looping mechanism is one thing. How you calculate the wait time is a separate question that has no dependency on the looping mechanism being used.
The tempo is available by thisThread.clock.tempo and you can use this however you wish to calculate a wait time. (E.g. if you want the wait time in seconds to be constant, regardless of tempo, you could write (waitTimeInSeconds * thisThread.clock.tempo).wait;.) It’s up to you, what calculation you want.