Questions about Pbind

Hi guys,

I have one sequence(seq1) i.e. [60, 62, 64, 65, 67, 69, 71] , I want it to repeat certain times according to another array(seq2) i.e. [4, 3, 2] , and the length of seq1 is affected by the third sequence(seq3) i.e. [3, 5, 6] , the result would be like this:

60, 62, 64 (length = 3) repeat four times
60, 62, 64, 65, 67 (length = 5) repeat three times
60, 62, 64, 65, 67, 69 (length = 6) repeat two times

By the way so glad to see this forum born, to me Discourse is nicer.

Yeah this should be easier than it is. Ideally you should be able to pass a pattern as a repeat value. Probably the easiest way atm is to put your array in a variable, then reference it with multiple Pser patterns.

Something like:
a = #[60, 62, 64, 65, 67, 69, 71];
Pseq(Pn (Pser(a, 3), 4),
Pn (Pser(a, 5), 3),
Pn (Pser(a, 6), 2))

Obviously this is terrible and hopefully somebody else has a better solution.

Long term would be to update the pattern library so that repeat values can take patterns in some way. That would require some thought though.

All right I have a solution, which I don’t like, but is technically the right way to do this at the moment.

When I get a moment I’ll post some working code.

Never mind. Just when I think I get patterns.

As a pattern:

(
var repeats = [3,5,6];
var a1 = Pn(Pser(#[60, 62, 64, 65, 67, 69, 71], Pstutter(Pseq([4, 3, 5]), Pseq(repeats)).asStream), repeats.sum);
var b1 = a1.asStream;
70.do{
	b1.next.postln;
};
)

As a Pbind:

(
var repeats = [3,5,6];
Pbind(
	\midinote, Pn(Pser(#[50, 52, 54, 55, 57, 59, 51], Pstutter(Pseq([4, 3, 5]), Pseq(repeats)).asStream), repeats.sum),
	\dur, 1).play
)
1 Like

Thanks @cian! With your help now I know more about Pser and Pstutter!