Pstutter of a Pstutter in Patterns?

Hey, I would like to do something of a nested Pstutter in Patterns.

The basic idea is to use this for a high hat which hits on every first stroke. But makes a random amount of repeat until the next stroke. To archive this i thought that some kind of nested Pstutter would help.

I elaborate this in another further example, i hope my question becomes clear:

(
SynthDef(\hat,{
	var sig;
	sig = GrayNoise.ar()* Line.kr(1,0,0.1,\amp.kr(0.2),doneAction:2);
	Out.ar(\out.kr(0),sig!2);
}).add;
)
//this is what it is supposed to do:
(
Pbind(
	\instrument, \hat,
	\stutter, Pstutter(Pseq([1,2,3,4],inf),Pseq([1,2,3,4],inf)),
	\dur, 1/Pkey(\stutter).trace,
).play
)
//this is the theortical way i want to have it done, but it doesnt work:
(
Pbind(
	\instrument, \hat,
	\stutter_reference,Pseq([1,2,3,4],inf), //here is some possibly later random reference for the \stutter key
	\stutter, Pstutter(Pkey(\stutter_reference),Pkey(\stutter_reference)), //this does not get the right stutter reference, because its moving independetly
	\dur, 1/Pkey(\stutter).trace,
).play
)

Basically in the second Pattern i want to archive the same as in the first, when considering the \stutter_reference to be also possibly random or something like this. Could this be done somehow?

Thank you very much!

What about a Prout ?

(
Pbind(
	\instrument, \hat,
	\stutter, Pn(Prout({ var n=1.rrand(4).debug("n"); n.do{ n.yield}})),
	\dur, 1/Pkey(\stutter).trace,
).play
) 

Could also have your repetition amount controlled by a pattern itself:

(

~ctrl=Pseq([4,1,2,3],inf).asStream;

Pbind(
	\instrument, \hat,
	\stutter, Pn(Prout({ var n=~ctrl.next.debug("n"); n.do{ n.yield}})),
	\dur, 1/Pkey(\stutter).trace,
).play
) 
1 Like

Yeah thats already really good!

However is it still somehow possible to use a Pattern within this routine?
Like: Pseq([1,2,3,4],inf); instead of n=1.rrand(4); n.do{ n.yield};?

Thank you very much!

You saw my update with the controling pattern ?

Yes, now i did :smiley:
Thanks for the edit, learned a lot!

You may also want to check out Psubdivide.

(
Pbind(
    \instrument, \hat,
    \dur, Psubdivide(Pseq([1,2,3,4], inf), 1)
).play;
)
1 Like

Oh cool, that’s also a good one, makes it even more convenient to use!