Pxxx that duplicates all the iterations of its embeded pattern

Hi, I’m looking for a Pxxx that would replicate all the iterations of its embedded :

Pxxx(Pbind(\dur,Prand([1,0.5,2],)), 4)

If the durs of the Pbind are
[1, 1, 0.5, 2],

the durs would be
[1, 1, 0.5, 2,
1, 1, 0.5, 2,
1, 1, 0.5, 2,
1, 1, 0.5, 2.]

Does this exist ?

Or is there another approach to store the results of the Pbind and to resend them in the next iterations ?

Hi,

you could use a Pclump / Pdup / Pflatten combo, the methods flatten and clump can be used as well.

x = Pclump(4, Prand([1, 0.5, 2], inf)).asStream

x.nextN(5)


x = Pdup(2, Pclump(4, Prand([1, 0.5, 2], inf))).asStream

x.nextN(20)
		

x = Pflatten(1, Pdup(2, Pclump(4, Pseq([1, 0.5, 2], inf)))).asStream

x.nextN(20)

Also works with event patterns:

Pflatten(1, 
	Pdup(2, 
		Pclump(4,
			Pbind(
				\dur, Prand([1, 0.5, 2], inf) * 0.2,
				\midinote, Pwhite(60, 80)
			)
		),
	)
).play

There’s certainly a lot of combos that can accomplish such. Pn & Plazy is quite flexible as it allows to do whatever in a Function:

x = Pn(Plazy { { [1, 0.5, 2].choose } ! 4 ! 2 }.flatten).asStream

x.nextN(20)

There’s also PSloop in miSCellaneous_lib

1 Like

Thanks!
I managed do to something with Plazy with simple pattern but couldn’t make it work with Pbind. The Pflatten/Pclumb combo is a killer !

I had to make a little adaptation for it to work.
As such, the Pbind returned an error about a duplicate Synth at every repetition.

(
Pflatten(1, 
	Pdup(2, 
		Pclump(4,
			Pbind(
				\dur, Prand([1, 0.5, 2], inf) * 0.2,
				\midinote, Pwhite(60, 80)
			)
		),
	)
) <> (callback: { |e| e.id=nil; })
).play

Adding the <> (callback: { |e| e.id=nil; }) cleans the latest Synth of the previous occurrence and allows the EventStreamPlayer to build a new Synth for the new occurence.