Is there a quark that does PdefPreset-like multi-segment morphing (i.e. Env-like)?

This isn’t too big of a deal to adapt/extend, but PdefPreset (from the JITlib extension quark) only does morphing (and xfading) between a pair of [pre]settings, even though it can store more than two such settings sets.

I was wondering if someone hasn’t already implemented an Env-like present morphing, i.e. a multi-segment PdefPreset “morph”, preferably one that is known to work with Pdef.envir, although one for plain Environments would be useful to to me as well.

If I’m understanding what you’re looking for correctly, I think you can do that with this:

It allows you to crossfade between a list of value streams or event streams, using several algorithms for blending values.

Pdef(\a, Pbind(
	\octave, 3, \degree, 0,
	\amp, 0.5
Pdef(\b, Pbind(
	\octave, 4, \degree, 0,
	\amp, 1
Pdef(\c, Pbind(
	\octave, 5, \degree, Pseq([3, 5], inf),
	\legato, 2,
	\amp, 0.1

	Pbind(\dur, 1/6) 
	<> Pxfade(
		Pseg([0, 2], [20]),  // envelope morphing through the three event streams

Word of warning - there’s a lot packed into this class, and I’ve used it on exactly one project, so it has seen only limited testing. Enjoy :slight_smile:


I see a limitation in Pxfade that it seems to assume “equally spaced” time points; I see there’s Pseg in the standard library (which allows any spacing of the time points), but it doesn’t really do “keyframe interpolation” (as interpolating/morphing between different presets/envirs might be called in a graphics context) but Pseg only interpolates between single numerical values or apparently arrays too. I suppose one can do a envir conversion to/from arrays, but it would be rather annoying.

I see there’s mmPresetInterpolator too

It looks like it has all the bells and whistles one could possibly want… except a notion of interpolating over time :frowning: So yeah, it’s more of a Pxfade alternative.

Fairly off-topic aside: interesting paper on interpolating drum beat patterns, although not done in SC.

It doesn’t assume equally spaced points in time - it doesn’t have any notion of time at all, that’s the responsibility of the caller. It simply takes an xfade parameter and interpolates between N event streams based on this parameter (plus a function that tells it how to interpolate). You can drive the xfade parameter with a Pseg if you want interpolation over time - or drive it with a knob, a server bus value, a pattern, etc.

That’s a good point. One can turn any interpolator into an Env-style interpolator that way.

I’m having a bit of trouble with Pxfade expecting isSymbol to be defined seemingly for a lot of things. I guess it’s defined in some other quark/extension of yours. It seems to work with the obvious thing for that

+Object {
    isSymbol { ^false }

+Symbol {
	isSymbol { ^true }

I’m guessing the degreeToKey overrides (e.g. to SimpleNumber) in are so that the interpolation steps are smaller…