Pattern variable exchange like Pkey for multiple patterns

Hello again, also got another questions to pattern.

I was wondering how it would be possible to exchange the variable of a pattern to another pattern. Similar to Pkey(\variable) within a single Pbind, just by exchanging it to another.

I try to clarify this in some code, i hope the comments make it clear:

TempoClock.tempo=1;
//b plays the same note as a, because its hard coded in it
(
l = [60,65,64,67,65,60,57,62];
a = Pbind(\dur, 1, \midinote, Pseq(l)-12).play;
b = Pbind(\dur,0.5,\midinote, Pstutter(2,Pseq(l))).play;
)
(
//now, there is no easy way to hard code it, is it possible for b to track the midi note of a?
l = [60,67,67,65,64,62,60,60];
a = Pbind(\midinote, Pseq(l)-12).play;
b = Pbind(
	\dur,Prand([Pseq([1/3],3),Pseq([1/2],2)],8),//randomized pattern
	\midinote,Pstutter(2,Pseq(l,inf)), //how to track a's midinote?
).play;
)
//i wish to make b let the same note play as a in the same time frame.

If something is unclear, maybe i can reformulate it, but basically, I want the pattern b to allways play the same note as pattern a, by some kind of information exchange from the a pattern.

Thanks for your help/reading.

[EDIT]: Changed the code formatting style

I want the pattern b to allways play the same note as pattern a, by some kind of information exchange from the a pattern.

i believe you’re after something like this…

(
l = [60,67,67,65,64,62,60,60];
a = Pbind(
	\midinote, Pseq(l)-12,
);
b = Pbindf(a,
	\dur,Prand([Pseq([1/3],3),Pseq([1/2],2)],8),//randomized pattern
	\midinote,Pstutter(2,Pkey(\midinote)).trace,
);
a.play;
b.play;
)

which can also be written like this if you prefer…

(
l = [60,67,67,65,64,62,60,60];
a = Pbind(
	\midinote, Pseq(l)-12,
);
Ppar([
	a,
	Pbindf(a,
		\dur,Prand([Pseq([1/3],3),Pseq([1/2],2)],8),//randomized pattern
		\midinote,Pstutter(2,Pkey(\midinote)).trace,
	)
]).play;
)

or perhaps like this - using a different technique…

(
l = [60,67,67,65,64,62,60,60];
a = Pbind(
	\midinote, Plet(\mynotes, Pseq(l)-12),
);
b = Pbind(
	\dur,Prand([Pseq([1/3],3),Pseq([1/2],2)],8),//randomized pattern
	\midinote, Pstutter(2,Pget(\mynotes).repeat).trace
);
Plambda(
	Ppar([a, b])
).play
)

in any case, read more in Pkey, Pbindf and Plambda helpfiles.
_f

#|
fredrikolofsson.com musicalfieldsforever.com

1 Like

Please use code formatting tags for code blocks. You’re currently using quotation blocks – they’re not the same thing.

It’s the </> formatting button in the toolbar.

This will solve the * problem that you mentioned in the other thread.

hjh

1 Like

Im not entirely sure, but i think the first two options do not work, because it converts the pattern to a stream. Since the randomized dur (duration) values, demand a repetition of the midinote, but the stream is only able to give the correct order, not the amount of repetition.
It would be interesting, if there is a way to implement this, to make it work with Pbindf, but I don’t see how.

Your third example however solves it mostly. I changed/simplified it a bit. However I feel like there might be a systematical mistake from a float issue. When the ‘a’-Pbind is running a note every 1 second, and lets say the ‘b’-Pbind does so, for every 1/3 (0.333333333) seconds. At some points they are not exactly on point anymore. I think this is why the b Pbind, might be a little bit faster than the ‘a’-Pbind, even though its not audiable. I fixxed it in the folloxing code, u need to uncomment one line in the b-Pbind, to see what i mean:

(
l = [60,67,67,65,64,62,60,60];
a = Pbind(
	\midinote, Plet(\mynotes, Pseq(l,inf)-12),
);
b = Pbind(
	\dur, 1/3, //stops working after a while
	//uncomment the next line!!!!!!
	// \dur,Pseq([0.000001,Pseq([1/3],inf)] //this works all the way
	//uncomment the previous line!!
	\midinote,12+Pget(\mynotes,repeats:inf)
);
Plambda(
	Ppar([a, b])
).play
)

Im wondering if it would be possible to quantize the b-Pbind within the Ppar, with a very tiny offset. ‘.play(quant:[0,0.0001,0])’ should’ve done the trick for the b-Pbind, but I’m not sure how to set a different offset for the quantization in the Ppar. Is that possible?

Anyhow, thank you very much, this was very helpful!!