Gradual Stretch Change between Pbindefs

Hello -

I’d like to do something relatively straightforward, but I’m not sure if there is a shortcut for doing it. I’d like to interpolate the stretch time between the following Pbindefs, when they are executed. Is there a convention for doing this?

Pbindef(\one,
	\dur, 0.3,
	\stretch, 1,
).play;

Pbindef(\one,
	\dur, 0.3,
	\stretch, 0.5,
).play;

I was thinking it might be possible to do something with Plazy, but the following requires re-executing the Pbindef and of course, the pattern doesn’t stay put after it finishes the adjustment.

~a = 0.9;

Pbindef(\one,
	\dur, 0.3,
	\stretch, Pn(Plazy(~a)),
).play;

~a = Pseq((0.9, 0.8..0.2), 1);

Thanks!

Not exactly answering your question but might want to have a look at the AlgaLib extension which focuses on interpolation.

Is the idea that every time you execute the Pbindef again, it uses a different stretch factor?
But over how much “executes” should this interpolation happen? The desired behavior is not entirely clear yet to me.

You could e.g. just generate a new Pbind every time you need one, e.g.

(
s.waitForBoot({
	var list_of_patterns = [];
	var pattern_maker = {
		| stretchtime |
		Pbind(
			\degree, Pseq([1,2,3,2], 1),
			\duration, 0.3,
			\stretch, stretchtime,
		).trace;
	};
	
	s.sync;
	
	list_of_patterns = (0.9, 0.8..0.2).collect({
		| stretchtime|
		pattern_maker.(stretchtime);
	});
	
	fork {
		
		// this wait statement is useful if calculating all the patterns takes a lot of time
		// to avoid that the first events are late
		wait(thisThread.clock.elapsedBeats - thisThread.clock.beats);
		
		Pseq(list_of_patterns).play;
	};
});
)