Is this the easiest way to interpolate between 3 signals?

Laurin Baumann's icon

Hi,

I'm trying to find a easy way to implement interpolation/mixing between 3 or more signals. Between 2 it's straight forward, but anything more than 2 gets kinda tricky, unless I'm missing something.

In this patch I used function objects to map the X value of the slider to the Y values of each individual function, which then sets the multiplication factor for each signal.

I saw the matrix~ object which makes it easier to interpolate between two signals but it doesn't solve the problem for 3 or more. I thought there was some kind of mix~ object but seems like I was wrong. Any answers would be appreciated!

(also: does the function object not take curvature into consideration when sending a list of values. Do i have to do that separately with "setcurve" ?

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

bertrandfraysse's icon

you can make a sort of chain of interpolations.

value4 = interpolation between value1 and value 2

value5 = interpolation between value2 and value 3

finaleValue = interpolation between value4 and value5

This way you have a two dimension interpolation

x controls the interpolation to both values 4 & 5

y controls the finalValue interpolation

so if :

x=0 & y=0 finalValue is value1

x=1 & y=0 finalValue is value2

x=1 & y=1 finalValue is value3

PS : in gen~ you have two functions to make interpolation, mix and interp, they are the same, just the inlets order is different

Roman Thilenius's icon

the "mix~" object is called [line~] and [*~].

to test and experiment do not use music signals or envelopes, use sig~ 3, sig~ 4 and sig~ 17, this will always tell you what actually happens when you monitor the output on the bottom.

Laurin Baumann's icon

thank you, that's a fair approach! Asking myself though if I wanted to interpolate over several e.g. 50 different signals/values, and have some sort of drag to one value, how you'd do that. anyway! now i see where i got that mix object from. It's from gen!! Gotta check that out too:)

Laurin Baumann's icon

oh I see so instead of creating e.g. 3 functions as I did I can also use only one single line object maybe? Gotta wrap my head around it but I think i'm getting there

bertrandfraysse's icon

I may do something like

you take a float number going from 1 to 50, let's call it your input

if it's 1 you get the value 1, but if it's 1.25 you create an interpolation between the value 1 and 2 with the fractional part of your input number, in this case 0.25 (the fractional part of a number is x-floor(x), or there's a fract object in gen)

in gen codebox, with values coming from a buffer, it gives

mix (peek(buffer,floor(input)), peek(buffer,ceil(input), fract(input))

This will give interpolation from value to value in one dimension, sequentially.

You can adapt it to work in more than one dimension using the previous example.

Source Audio's icon

you are talking about levels of nn number of signals

similar to multichannel panning.

it is as simple as a decision what level in control range min - max

should each signal get.

linear, log ... whatever blend.

matrix~ is ideal choice anyway