Revision: 9089
http://supercollider.svn.sourceforge.net/supercollider/?rev=9089&view=revAuthor: rkuivila
Date: 2009-04-21 11:19:04 +0000 (Tue, 21 Apr 2009)
Log Message:
-----------
Fixed EventStreamPlayer revision. Now the ESP is scheduled by the clock and
it next method calls a Routine to actually perform events. This allows Server.sync
to be called from an Event.
Modified Paths:
--------------
trunk/build/SCClassLibrary/Common/Streams/Stream.sc
Modified: trunk/build/SCClassLibrary/Common/Streams/Stream.sc
===================================================================
--- trunk/build/SCClassLibrary/Common/Streams/Stream.sc 2009-04-21 02:17:27 UTC (rev 9088)
+++ trunk/build/SCClassLibrary/Common/Streams/Stream.sc 2009-04-21 11:19:04 UTC (rev 9089)
@@ -421,25 +421,105 @@
////////////////////////////////////////////////////////////////////////
-EventStreamPlayer : PauseStream {
- var <>event, <>muteCount = 0, <>cleanup;
+//EventStreamPlayer : PauseStream {
+// var <>event, <>muteCount = 0, <>cleanup;
+//
+// *new { arg stream, event;
+// ^super.new(stream).event_(event ? Event.default).cleanup_(EventStreamCleanup.new);
+// }
+//
+// // freeNodes is passed as false from
+// //TempoClock:cmdPeriod
+// removedFromScheduler { | freeNodes = true |
+// nextBeat = nil;
+// cleanup.terminate(freeNodes);
+// this.prStop;
+// this.changed(\stopped);
+// }
+// prStop {
+// stream = nextBeat = nil;
+// isWaiting = false;
+// }
+//
+// stop {
+// cleanup.terminate;
+// this.prStop;
+// this.changed(\userStopped);
+// }
+//
+// mute { muteCount = muteCount + 1; }
+// unmute { muteCount = muteCount - 1; }
+// canPause { ^this.streamHasEnded.not and: { cleanup.functions.isEmpty } }
+//
+// next { arg inTime;
+// var nextTime;
+// var outEvent = stream.next(event.copy);
+// if (outEvent.isNil) {
+// streamHasEnded = stream.notNil;
+// cleanup.clear;
+// this.removedFromScheduler;
+// ^nil
+// }{
+// nextTime = outEvent.playAndDelta(cleanup, muteCount > 0);
+// if (nextTime.isNil) { this.removedFromScheduler; ^nil };
+// nextBeat = inTime + nextTime; // inval is current logical beat
+// ^nextTime
+// };
+// }
+//
+// asEventStreamPlayer { ^this }
+//
+// play { arg argClock, doReset = (false), quant;
+// if (stream.notNil, { "already playing".postln; ^this });
+// if (doReset, { this.reset });
+// clock = argClock ? clock ? TempoClock.default;
+// streamHasEnded = false;
+// stream = originalStream;
+// isWaiting = true; // make sure that accidental play/stop/play sequences
+// // don't cause memory leaks
+// era = CmdPeriod.era;
+// quant = quant.asQuant;
+// event = event.synchWithQuant(quant);
+//
+// clock.play({
+// if(isWaiting and: { nextBeat.isNil }) {
+// clock.sched(0, this);
+// isWaiting = false;
+// this.changed(\playing)
+// };
+// nil
+// }, quant);
+// this.changed(\userPlayed);
+// ^this
+// }
+//
+//}
+
+EventStreamPlayer\xCA:\xCAPauseStream\xCA{
+ var\xCA<>event, <>muteCount = 0, <>cleanup, <>routine;
- *new { arg stream, event;
- ^super.new(stream).event_(event ? Event.default).cleanup_(EventStreamCleanup.new);
+ *new {\xCAarg\xCAstream, event;
+ ^super.new(stream).event_(event ?\xCAEvent.default).init;
}
+
+ init {
+ var me = this;
+ cleanup = EventStreamCleanup.new;
+ routine = Routine{\xCA| inTime |\xCAloop { inTime =\xCAme.prNext(inTime).yield } };
+ }
// freeNodes is passed as false from
//TempoClock:cmdPeriod
- removedFromScheduler { | freeNodes = true |
- nextBeat = nil;
+ removedFromScheduler {\xCA| freeNodes = true |
+ nextBeat =\xCAnil;
cleanup.terminate(freeNodes);
this.prStop;
this.changed(\stopped);
}
prStop {
- stream = nextBeat = nil;
- isWaiting = false;
- }
+ stream = nextBeat =\xCAnil;
+ isWaiting =\xCAfalse;
+ \xCA}
stop {
cleanup.terminate;
@@ -451,9 +531,11 @@
unmute { muteCount = muteCount - 1; }
canPause { ^this.streamHasEnded.not and: { cleanup.functions.isEmpty } }
- next { arg inTime;
- var nextTime;
- var outEvent = stream.next(event.copy);
+ next { | inTime | ^routine.next(inTime) }
+
+ prNext {\xCAarg\xCAinTime;
+ var\xCAnextTime;
+ var\xCAoutEvent = stream.next(event.copy);
if (outEvent.isNil) {
streamHasEnded = stream.notNil;
cleanup.clear;
@@ -461,30 +543,30 @@
^nil
}{
nextTime = outEvent.playAndDelta(cleanup, muteCount > 0);
- if (nextTime.isNil) { this.removedFromScheduler; ^nil };
+ if (nextTime.isNil) {\xCAthis.removedFromScheduler; ^nil\xCA};
nextBeat = inTime + nextTime; // inval is current logical beat
^nextTime
};
}
- asEventStreamPlayer { ^this }
+ asEventStreamPlayer { ^this\xCA}
- play { arg argClock, doReset = (false), quant;
- if (stream.notNil, { "already playing".postln; ^this });
- if (doReset, { this.reset });
- clock = argClock ? clock ? TempoClock.default;
- streamHasEnded = false;
+ play {\xCAarg\xCAargClock, doReset = (false), quant;
+ if (stream.notNil, {\xCA"already playing".postln; ^this\xCA});
+ if (doReset, {\xCAthis.reset });
+ clock = argClock ? clock ?\xCATempoClock.default;
+ streamHasEnded =\xCAfalse;
stream = originalStream;
- isWaiting = true; // make sure that accidental play/stop/play sequences
+ isWaiting =\xCAtrue; // make sure that accidental play/stop/play sequences
// don't cause memory leaks
- era = CmdPeriod.era;
+ era =\xCACmdPeriod.era;
quant = quant.asQuant;
event = event.synchWithQuant(quant);
clock.play({
if(isWaiting and: { nextBeat.isNil }) {
- clock.sched(0, this);
- isWaiting = false;
+ clock.sched(0,\xCAthis );
+ isWaiting =\xCAfalse;
this.changed(\playing)
};
nil
@@ -494,4 +576,3 @@
}
}
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
_______________________________________________
sc-dev mailing list
info (subscription, etc.):
http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtmlarchive:
http://www.listarc.bham.ac.uk/marchives/sc-dev/search:
http://www.listarc.bham.ac.uk/lists/sc-dev/search/