Pbindef and incremental parallel modification of one "template" Pbind

I have been using Pbindef to experiment with different key pattern combinations for the controls of a SynthDef by updating the keys while the player is running.

What I would like to be able to do is experiment with some of these combinations in parallel. So have several streams of one “template” Pbind playing that I can individually interact with like when using Pbindef on one Pbind.

Is there a way to achieve something like this without copying and renaming the “template” Pbind?

I have been trying many combinations of Pbind, Pdef, Pbindf, Pbindef and PbindProxy but can’t find the right workflow.

I hope this question makes sense.

Thanks
David

You could use the patternpairs method

p = Pbind(\midinote, 60, \dur, 0.5);
q = p.patternpairs;

// * "de-arrays" into items
Pbindef(\x, *q).play(quant: 1);

Pbindef(\y, *q);

Pbindef(\y, \midinote, 70).play(quant: 1)

Maybe there are also some jitlib shortcuts I’m not aware of.

Aside from that, you could also check out PLbindefPar from miSCellaneous_lib. Like its simpler cousin PLbindef, it’s a Pbindef wrapper with syntax shortcuts etc. PLbindefPar has additional features that allow for massive parallel streaming.

If often use a combination of Pdefs and Pchains for these scenarios (if I understand you correctly):

(
SynthDef(\a, {
	var sig = LFSaw.ar(\freq.kr(220)) * 0.1;
	var env = Env.asr(\atk.kr(0.1), 1, \rel.kr(1)).kr(2, \gate.kr(1));
	sig = Pan2.ar(sig, \pan.kr(0));
	Out.ar(\out.kr(0), sig * \amp.kr(1) *  env ! 2)
}).add;

SynthDef(\b, {
	var sig = LFPulse.ar(\freq.kr(220)) * 0.2;
	var env = Env.asr(\atk.kr(0.1), 1, \rel.kr(1)).kr(2, \gate.kr(1));
	sig = Pan2.ar(sig, \pan.kr(0));
	Out.ar(\out.kr(0), sig * \amp.kr(1) * env)	
}).add
)

(
Pdef(\aPat, Pbind(\instrument, \a, \pan, -1, \amp, Pseq([0.1, 1], inf)));
Pdef(\bPat, Pbind(\instrument, \b, \pan, 1, \amp, Pseq([1, 0.1], inf)));
Pdef(\basePat, Pbind(\dur, Prand([0.25, 0.5, 0.75, 1], inf), \midinote, Prand([50, 53, 55, 57, 60], inf, \amp, 1)));
Pdef(\test, Pchain(Ppar([Pdef(\aPat), Pdef(\bPat)]), Pdup(2, Pdef(\basePat)))).play
// Alternative shorter syntax for Pchain using <>
// Pdef(\test, Ppar([Pdef(\aPat), Pdef(\bPat)]) <> Pdup(2, Pdef(\basePat))).play
)

// Now you can change all 3 patterns while playing as you wish
// note that because of Pdup, the randomly chosen values of the basePat is propagated to both \aPat and \bPat
// note also that because the \basePat is before \aPat and \bPat (the Pchain reads right-to-left), the \amp keys in 
// \aPat and \bPat overrides the \amp key in the \basePat
Pdef(\aPat, Pbind(\atk, 0.1, \rel, 0.1, \pan, Pwhite(-1, 1), \amp, Pwhite(0.1, 0.5)))
Pdef(\bPat, Pbind(\atk, 0.1, \rel, Pwhite(0.1, 0.5), \pan, Pwhite(-1, 1), \amp, Pwhite(0.1, 0.5)))
// change the basePat
Pdef(\basePat, Pbind(\dur, Prand([0.25, 0.5, 0.75, 1], inf), \midinote, Prand([50, 53, 55, 57, 60] + 3, inf, \amp, 1)));
// override the \midinote of the basePat
Pdef(\bPat, Pbind(\atk, 0.1, \rel, 0.1, \midinote, 69))

Pdef(\test).stop

Thanks a lot @dkmayer and @Thor_Madsen !

The .patternpairs method is a neat quick fix for copying the keys. I couldn’t find it explained anywhere in the documentation but it’s self-explanatory.

The PLbindefPar option blew my socks off though, that is a sketch tool with perhaps too much power in the hands of a pattern novice. Really great, especially because I am experimenting with pattern based granular sound.

The Pdefs and Pchain combo is also a great tool for trying out combinations of patterns, even though it doesn’t fit this particular workflow, which I had not properly detailed also.

Thanks again.