[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Sc-devel] add change notification when EventStreamPlayer stops
Hello,
I would like to suggest adding a this.changed(\stopped); message to EventStreamPlayer, so it can notify any dependents when it stops. This would be congruent with a scheme for notifying when a Node ends, which I can also post here, if it is of interest. The scheme uses a new class: ServerWatche
r and the known NodeWatcher class, plus a few methods for Node, "onStart", "onEnd".
Below are the modified code for EventStreamPlayer:next, plus 2 examples.
Seasons greetings,
Iannis Z.
+ EventStreamPlayer {
next { arg inTime;
var nextTime;
var outEvent = stream.next(event);
if (outEvent.isNil) {
streamHasEnded = stream.notNil;
stream = nextBeat = nil;
// IZ: notify dependant objects that stream has ended.
this.changed(\stopped);
^nil
}{
if (muteCount > 0) { outEvent.put
(\freq, \rest) };
outEvent.play;
if ((nextTime = outEvent.delta).isNil) { stream = nil };
nextBeat = inTime + nextTime; // inval is current logical beat
^nextTime
};
}
}
/*
Examples:
(
a = Pbind(\degree, Pseq([1,2,3, Pwhite(10, 20, 5)],2), \dur, 0.2).play;
a.addDependant({ | who, how | format("% %", who, how).postln });
)
(
var stream;
stream = Ppar([
Pbind(\degree, Pseq([4,5,6],4), \dur, 0.5),
Pbind(\degree, Pseq([1,2,3],2))
], inf).play;
stream.addDependant({ | who, how | format("% %", who, how).postln });
{ stream.stop }.defer(5);
)
*/