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

Re: [Sc-devel] RFC: Pbind redesign?

I would have to vote no, I'm afraid. I routinely write child patterns in Pbind that look in the partially populated event for the values of earlier child patterns - Pkey. I mean, I do this all the time. I can't stress that enough. All the time. This proposal would break every one of my compositions.


On Dec 12, 2007, at 6:54 AM, ronald kuivila wrote:

Hi all,
  Currently, patterns that alter the contents of multiple keys of an event must make a copy of the event.
There are two reasons for this:

1. to prevent pollution of the protoEvent
2. to prevent a partially altered event from being propagated (if one of the streams defining a key value terminates).

  Item 1 could be addressed by making the copy in the EventStreamPlayer before sending 'next' to the event stream.

  Item 2 requires a reimplementation of patterns like Pbind to get all the new values and then transfer them into the Event.

  The advantage of this is that the Event passed to the stream by EventStreamPlayer is the Event that actually comes back to
EventStreamPlayer to be performed.  This will generate less garbage (those event copies).  And it would simplify "clean up" for 
patterns like Pmono.  (In the new approach, the event Pmono generates to create a synth is guaranteed to actually be played, so
it will contain all the information needed to set and release the synth.  Currently this requires a relatively jury-rigged callback scheme.) 

This would make it pretty easy to get rid of the mono event types.

   The disadvantage is that Pbind would have to iterate twice - once to get the values and once to set them in the event.
I do not know how best to evaluate these trade-offs.

  Here is an example of what that the new Pbind might look like:

AlternatePbind : Pattern {
var <>keys, <>patterns;
*new { arg ... pairs;
if (pairs.size.odd, { Error("Pbind should have even number of args.\n").throw; });

storeArgs { ^[keys, patterns] }
embedInStream { arg event;
var valArray;
var values = Array.fill(patterns.size,0);
var streams = patterns.copy.do(_.asStream);

loop {
streams.do { | str, i |
values[i] = str.next(event) ?? { ^event}
keys.do { | key, i |
if (key.isSequenceableCollection) {
valArray = values[i];
key.do { | k, j |
event[k] = valArray[j]
} {
event[key] = values[i]
event = event.yield;

: 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