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

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



Hello Iannis,

sorry, this is a misunderstanding: there was no doubt about how dependencies may be useful. The code I posted simply makes it available _both_ for PauseStream (i.e. Task) and for EventStreamPlayer.

At 11:21 Uhr +0200 27.12.2007, Iannis Zannos wrote:
Hello Julian,

The reason why I put it in EventStreamPlayer is that it is responsible for playing Patterns (Pbind's). So Patterns can notify anyone when they stop, just as Synths can do with the scheme I mentioned which adds the "onEnd" method to Node.
Example of use:
Consider a button that represents a synth. Pressing the button creates a synth and sets the button to "synth is on". When the synth stops, the button is notified by "onEnd" to reset the button to "synth is off". The same thing can be implemented for a pattern: Pressing the button starts the pattern. When the pattern ends, it sets the button to "pattern is off". It seems that for this EventStreamPlayer must be used, because Patterns create EventStreamPlayers to play. I tried modifying PauseStream and it did not work.

Iannis

---------- Forwarded message ----------
From: Julian Rohrhuber <<mailto:rohrhuber@xxxxxxxxxxxxxx>rohrhuber@xxxxxxxxxxxxxx>
Date: Dec 25, 2007 5:38 PM
Subject: Re: [Sc-devel] add change notification when EventStreamPlayer stops
To: <mailto:sc-devel@xxxxxxxxxxxxxxx>sc-devel@xxxxxxxxxxxxxxx


I'd suggest that it should be in PauseStream, then:

Index: <http://Stream.sc>Stream.sc
===================================================================
--- <http://Stream.sc>Stream.sc   (revision 6828)
+++ <http://Stream.sc>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);
)

*/


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

--






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



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


--





.