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

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

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.


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


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.
            if (muteCount > 0) { outEvent.put (\freq, \rest) };
            if ((nextTime = outEvent.delta).isNil) { stream = nil };
            nextBeat = inTime + nextTime;    // inval is current logical beat


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