Hi there -
I am a little confused about a basic feature of using a routine.
I’m hoping the following illustrates my point. Essentially, I don’t know if the “wait” time will need to be 6 seconds or 20 seconds, depending on the function nested in there. Is there a way to adjust the wait based on whether there is still a process running?
Routine({
4.do{
//a bunch of code that takes a different amount of time each time it is executed.
10.wait;
};
};
Thanks @jordan for this explanation and the Quark.
One thing seems confusing to me still, though…
Let’s say I have something like:
10.do{
~abstractFunction.();
};
Is it possible to have some sort of flag inside of ~abstractFunction that would indicate to a CondVar or Barrier when it was time to move on to the next iteration of the Do Loop?
It seems like that with both of these examples, the condition is set from outside the operating function…
I’m a little confused as to what you want to do now. The previous example will evaluate ~abSTRACTfunction 10 times, running each in series (waiting for the previous to finish).
If you want to run them in parallel (at the same time) and need to wait for all of them to be finished, you should use Barrier.
Routine({
thisThread.clock.beats.postln;
4.do{
//a bunch of code that takes a different amount of time each time it is executed.
var tps;
tps=10.0.rand.postln; // this means you have to grab the executed time of your function into the variable tps...
tps.wait; // the time it takes to evaluate your function
(10-tps).wait; // then make the difference to get the expected duration as the remaining time ...
// this supposes that your function should not exceed 10 seconds in this case ...
thisThread.clock.beats.postln;
};
}).play