Edit: 1. Damn tablet posted prematurely again. Maybe time to dump Firefox. 2. Maybe I misunderstood the question, but there’s a common requirement here, so…
If there’s one event, “wait until the event’s side effect (the synth) is finished before pulling the next event” is easy to define.
If there are multiple events at the same time point (delta 0), then at minimum there’s “wait until any one of the event’s synths is finished” or “wait until all of them have finished.” There may be other options too.
The “any” case would require firing on the first completion and discarding the remaining responders.
The “all” case works beautifully with a Condition. I’m not at the computer but something like:
// inside your loop
// also assuming event is pre-filled with the previous nonzero delta event
var events = Array.new, event;
var cond;
while {
event.notNil and: { event.delta <= 0 }
} {
events = events.add(event);
event = stream.next(());
};
cond = Condition({ events.size > 0 });
events.do { |ev|
ev.play;
// here, set up the responder
// its function should do:
// events.remove(ev);
// cond.signal;
};
cond.wait;
It’s a quite useful pattern that isn’t obvious – maybe doesn’t apply to this specific case anymore though.
hjh