xfading between exprs..

lysdexic's icon

Having one of those, "this could be a really simple solution that I can't see" problems.

Is there a [jit.xfade] type solution to interpolate between mathematical expressions (outside of jitter)?

Say i have two [expr] objects and I want to interpolate between these expressions using another value (ie: crossfading between two expressions..

Is this possible?

Roman Thilenius's icon

how exactly do you want to crossfade between, say, [expr $f1+5] and [expr tanh($i3/$i4)]?

lysdexic's icon

over in the FB group someone suggested using scale which is a great solution if only using two exprs:

maybe you were trying to be cheeky Roman - but does this work for your edge case? (i'm not using any tanh operations in my desired outcome.)

Max Patch
Copy patch and select New From Clipboard in Max.

Roman Thilenius's icon

if it is the input or output values which you want to crossfade between (you cant crossfade between expressions themselves :) ) and [scale] does what you want, you can probably also combine the two expressions into one - and include the expression which the scale objects performs as well.

scaling an input value can be done like that:

expr ((($f1-$f2)/($f3-$f2))*($f5-$f4))+$f4 (input, input min, input max, output min, output max)

then integrate you expressions in question by replacing $f2 and $f4 (i think, i am tired) with them.

mizu's icon

Hi all
i use to make things like that ( vexpr is nice too ) . The question for me is what happens if a value to interpolate needs to change in the middle of a fade. Depending of the context: not allways so simple.

Max Patch
Copy patch and select New From Clipboard in Max.

zzz

lysdexic's icon

Thanks Mizu & Roman :)

I'm interested in what occurs in the middle of a fade also. I think another layer of interpolation would need to occur for this to be smooth!

I'm also interested in keeping everything in expression form (like roman says) as I'd like to keep this in a script instead of objects. Thanks for your advice Roman - experimenting with this in JS