Key e.g \freq pattern to follow the constraint of the dur pattern

What I am after is a constraint that locks e.g freq pattern to a given duration pattern.
Let’s say you have a dur pattern that doesn’t add to even beat counts 4,8,16 etc
I know that Pconst can tame the an uneven dur value pattern to lock to a choosen beat count.
But what if I want the another key e.g \freq pattern to follow the constraint of the dur pattern so
that the \freq pattern wraps to the start of its own sequence whatever the content is.
Tried to use Pfindur but I can’t get it to work

(
// metronome
Pbind(\instrument,\default,
        \dur, 1,
        \freq,2000,
        \amp,Pseq([0.02,0.001,0.001,0.001],inf),
\out, 0,
).play;

// pattern
~pattern= Pbind(\instrument,\default,
        \dur, Pn(Pconst(8,Pseq([3.4,0.2,2.1],inf)),inf),
        \freq, Pn(
Pfindur(4,Pseq([
                          Pseq([50,150,75,50],1),
                          Pseq([50,150,75,50]*1.5,1)
],inf).asStream,0.01),inf),
\amp,0.02,
\out, 0,
).play;
)

Not sure if this is an optimal example…
I prefer to work with my patterns within Pdefs so finding a solution that would work playing around with
Pdefs would be great.

I am not sure I understand exactly what you are after, is this anything like it?

Pdef(\test, 
	Pbind(\instrument,\default,
		\dur, Pn(Pconst(8, Pseq([3.4,0.2,2.1],inf))),
		\freq, Pseq([Pseq([50,150,75,50], 1), Pseq([50,150,75,50] *1.5, 1)], inf),
		\amp, 0.2,
		\out, 0,
	)
).play

Not sure if the \freq pattern restart when Pconst has reached its limit 8. I always find it hard to find away
to evaluate what a pattern is doing in detail i.e posting when the pattern restarts

It does not start over in my first example. If you want both the dur and freq to start over after 8 beats you can do this:

Pdef(\test, 
	Pn(Pfindur(8, 
		Pbind(\instrument,\default,
			\p, Pstep(Pfunc{"start over".postln}, 8),
			\dur, Pseq([3.4,0.2,2.1],inf),
			\freq, Pseq([Pseq([50,150,75,50], 1), Pseq([50,150,75,50] *1.5, 1)], inf),
			\amp, 0.2,
			\out, 0,
)))).play
1 Like

This works great! wasn’t aware of this method before. I’d forgot that you could combine pbind and patterns this way! Thanks
Thanks also for the Pstep(Pfunc{“start over”.postln },8) key. Really nice!

1 Like