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

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



Hi Ron,

thanks for carrying on with this. Generally, I think it is a good idea to clarify the input - ouput relation in streams. What about streams like Pstutter etc?

what happens if, in a Pbind, one of the value streams further up the chain modify the inevent? then this change would propagate into the downstream.
Maybe this is a degenerate nodo case ...



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; });
		^super.newCopyArgs(*(pairs.clump(2).flop))
	}



	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;
		}
	}
}


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


--





.