Multichannel expansion on all keys of Patterns

Hi!

What is the syntax for making a multichannel expansion of all the keys used in a Pbind?

This is possible:

Pbind(
	\degree, Ptuple([Pbrown(-7, 0,1), Pseq([1, 2, 3, 4, 5, 6], inf), Pwhite(7, 12)], inf),
	\dur, 0.25
).trace.play;

and this is also possible:

Pbind(
    [\midinote, \dur], Ptuple([Pseq([1,2,3,4,5]+55, inf),  Pseq([1,2,3,4,5,6].reciprocal, inf)], 1),
).trace.play

But why exactly this is not possible?

Pbind(
	[\degree, \dur], Ptuple([
		Ptuple([Pbrown(-7, 0,1), Pseq([1, 2, 3, 4, 5, 6], inf), Pwhite(7, 12)], inf),
		Ptuple([1, 0.25, 0.5],inf)
	], inf)
).trace.play;

It only provides a single note and then crashes throwing the error: ERROR: Primitive '_Event_Delta' failed.. Looking at the trace, it seems to be providing a meaningfull multichannel expansion: ( 'degree': [ -7, 1, 11 ], 'dur': [ 1, 0.25, 0.5 ] ).

What is the explanation for this behavior?

Is there a guide/tutorial that deals exactly with multichannel expansion on Patterns?

the problem is the \dur key - Pbind creates a single stream of Events separated by time delta - you cant multichannel expand any keys that determine that delta - to get multiple streams of different durations look at Ppar

1 Like

Is it maybe possible to hack this with a Pchain or something similar?

Or at least have a syntax more similar to multichannel expansion thus avoiding the use of Ppar?

What’s the result you hope to get from this formulation? Not just the first event – let’s say the first 2 seconds’ worth.

hjh

Something like:

( 'degree': [ -4, 1, 9 ], 'dur': [1, 0.25, 0.5] )
( 'degree': [ -3, 2, 8 ], 'dur': [1, 0.25, 0.5] )
( 'degree': [ -2, 3, 7 ], 'dur': [1, 0.25, 0.5] )
( 'degree': [ -3, 4, 8 ], 'dur': [1, 0.25, 0.5] )
( 'degree': [ -2, 5, 10 ], 'dur': [1, 0.25, 0.5] )
( 'degree': [ -3, 6, 8 ], 'dur': [1, 0.25, 0.5] )
( 'degree': [ -2, 1, 11 ], 'dur': [1, 0.25, 0.5] )
( 'degree': [ -1, 2, 7 ], 'dur': [1, 0.25, 0.5] )
( 'degree': [ 0, 3, 12 ], 'dur': [1, 0.25, 0.5] )
( 'degree': [ -1, 4, 10 ], 'dur': [1, 0.25, 0.5] )
( 'degree': [ 0, 5, 10 ], 'dur': [1, 0.25, 0.5] )
( 'degree': [ -1, 6, 7 ], 'dur': [1, 0.25, 0.5] )
( 'degree': [ 0, 1, 12 ], 'dur': [1, 0.25, 0.5] )
( 'degree': [ -1, 2, 7 ], 'dur': [1, 0.25, 0.5] )
( 'degree': [ -2, 3, 8 ], 'dur': [1, 0.25, 0.5] )
( 'degree': [ -1, 4, 11 ], 'dur': [1, 0.25, 0.5] )
( 'degree': [ 0, 5, 11 ], 'dur': [1, 0.25, 0.5] )
( 'degree': [ -1, 6, 9 ], 'dur': [1, 0.25, 0.5] )
( 'degree': [ 0, 1, 10 ], 'dur': [1, 0.25, 0.5] )

So, three parallel voices, each one with a unique dur and unique degree behaviour…

Ok.

The pattern specifies that all 3 pitches and durations should be generated together, at the same time, in one event. And this is also reflected in your output format.

So at time index 0, you’d get pitches -4, 1 and 9.

Now… what is the next time point?

Let’s assume that you want SC to search through the duration array, and find the shortest time, 0.25.

The pattern specifies that the pitches should be generated all at the same time. So -3, 2 and 8 would be produced at this time.

But -3 belongs to time point 1, right? And 8 to time 0.5? So it’s wrong to generate them at 0.25… but the Ptuple requires them to be produced together.

This is a logical inconsistency – impossible to satisfy both requirements.

Commonly in programming languages, logical inconsistencies such as this are disallowed… as you discovered here.

If you wish -4, -3, -2 etc to stream out with duration 1, and 1, 2, 3 etc with duration 0.25, then you have to separate them into distinct time streams, period. There is no alternative to that. You can re-merge the separate time streams using Ppar or play them separately, but what you cannot do is parallelize them in one pattern.

hjh

I would do it this way:

(
Ppar(
	[
		[1, 0.25,0.5],
		[Pbrown(-7, 0,1)  , Pseq([1, 2, 3, 4, 5, 6], inf), Pwhite(7, 12)] 
	].flop.collect{ |array|
		Pbind(\degree, array[1], \dur, array[0])
	} 
).play
)

the flop method “multi-channel-expands” the two arrays - we then collect the three Pbinds and combine them in parallel with Ppar

1 Like