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

Re: [sc-users] State of a pattern / EventStreamPlayer



On Jul 21, 2009, at 12:18 PM, Hjalte Møller wrote:

Thank's James,

you're so very helpfull :)

I agree that the scheme is quite clean, and your example is just what I was looking for. But this only works for the toppattern (the EventStreamPlayer), and I think it would be cool if it were possible the get notification when an embedded pattern has ended...

That's a bit trickier, because it isn't the embedded pattern that comes to an end. It's really the stream made from that pattern that finishes. Attaching a dependent to the pattern itself wouldn't help because the pattern's state doesn't change (hence nothing to update).

I know to little about Streams and Events to really know what is possible here, but it would nice to have something to put into a pattern itself. Maybe a pattern object like Pfunc, but Pended, so if the stream containing it ends it evaluates...

Off the top of my head:

a = Pbind(\degree, Pseries(0, 1, 8), \dur, 0.25);
b = Pbind(\degree, Pseries(0, 1, 8), \dur, 0.5);

a = Pseq([a, Pfuncn { /* send notification here */; Event.silent(0) }], 1);
b = Pseq([b, Pfuncn { /* send notification here */; Event.silent(0) }], 1);

Pseq([a,b], inf).play

Then, for convenience, you could have a function or class to apply the wrapper automatically:

f = { |pattern, endAction|
Pseq([a, Pfuncn { endAction.value; Event.silent(0) }], 1);
};

Pseq([f.(a), f.(b)], inf)

Note that this would handle streams stopping by themselves, but not an explicit stop by the user. For the latter, look at Pfset.

hjh


: H. James Harkins
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal."  -- Whitman