[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sc-devel] add change notification when EventStreamPlayer stops





Hello James and Ron,

I am only adding the single line this.changed(...)
This line notifies the dependents of the stream in both cases:
1. When the stream stops playing because it has played its last event.
2. When the stream stops playing because it has been stopped by stop.

This covers as far as I know all cases when a stream stops playing.

Does this answer your question James?

Iannis Zannos



On Dec 25, 2007 5:01 PM, James Harkins <jamshark70@xxxxxxxxx> wrote:
This is useful -- my BP class has similar functionality.

Couple of questions:

When should the notification be sent? When the user requests stop, or only when the player wakes up and discovers a nil result?

A pause stream or event stream player can stop in several ways: manually using stop or pause, or automatically when the stream runs out. Perhaps a second argument to .changed to indicate the reason for the stop?

Should there be notifications for play/resume also?

Also, just FYI, Ron has done some refactoring of the default event and event stream player due to be checked in very soon, so I would suggest not committing this change yourself because Ron will overwrite it in the next couple of days. It's an easy matter to add this to what Ron has done.

hjh


On Dec 25, 2007, at 6:03 AM, Iannis Zannos wrote:


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);
)

*/
_______________________________________________
Sc-devel mailing list


: H. James Harkins

: jamshark70@xxxxxxxxxxxxxxxxx

: http://www.dewdrop-world.net

.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:


"Come said the Muse,

Sing me a song no poet has yet chanted,

Sing me the universal."  -- Whitman



_______________________________________________
Sc-devel mailing list
Sc-devel@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-devel