---------- Forwarded message ----------
From:
Julian Rohrhuber <
rohrhuber@xxxxxxxxxxxxxx>
Date: Dec 25, 2007 5:38 PM
Subject: Re: [Sc-devel] add change notification when EventStreamPlayer stops
To:
sc-devel@xxxxxxxxxxxxxxxI'd suggest that it should be in PauseStream, then:
Index:
Stream.sc===================================================================
---
Stream.sc (revision 6828)
+++
Stream.sc (working copy)
@@ -357,9 +357,10 @@
stop {
stream = nil;
isWaiting = false;
+ this.changed (\stopped);
}
removedFromScheduler { nextBeat = nil; this.stop }
- streamError { stream = nextBeat = nil; streamHasEnded =
true; isWaiting = false; }
+ streamError { this.removedFromScheduler ; streamHasEnded = true; }
wasStopped {
^streamHasEnded.not and: { stream.isNil } // stopped
by clock or stop-message
@@ -387,8 +388,12 @@
next { arg inval;
var nextTime = stream.next(inval);
- if (nextTime.isNil) { streamHasEnded = stream.notNil;
stream = nextBeat = nil }
- { nextBeat = inval + nextTime }; //
inval is current logical beat
+ if (nextTime.isNil) {
+ streamHasEnded = stream.notNil;
+ this.removedFromScheduler;
+ } {
+ nextBeat = inval + nextTime
+ }; // inval is current logical beat
^nextTime
}
awake { arg beats, seconds, inClock;
@@ -446,4 +451,30 @@
asEventStreamPlayer { ^this }
}
>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);
>)
>
>*/
>
--