More types of interpolation

Started by Rakib, October 20, 2009, 20:44:18

Previous topic - Next topic

Rakib

Today we can interpolate linear on the effects, can we have logaritmic/expontetial/Polynomial interpolation also.
^^

Sam_Zen

I maybe support this, but I first want to know the ins and outs of the different algoritms.
0.618033988

Rakib

Look at renoise and se how its done there.
^^

Paul Legovitch

Discussion continued from http://forum.openmpt.org/index.php?msg=32279.0&sid=416a0ad8b215a1f739ba3d56053afd95#32279

To do this you have to consider your 2 points you want to interpolate :
(X0,Y0) and (X1,Y1)
X being the row and Y the value of the parameter.
Each param value Yi between row X0 and row X1 is given by :
for i=0 to i=X1-X0
Yi = Y0 + f(i/(X1-X0))*(Y1-Y0)

This will work for any function f with 0<f<1 and f(0)=0 , f(1)=1 :
linear : f(x) = x
cubic : f(x) = x²(3-2x)
cosinus : f(x) = 0.5*(1 + cos(pi(1+x)))
exp : f(x) = (exp(a(2x-1)) - exp(-a)) / (exp(a) - exp(-a))
exp inverted : (exp(a) - exp(a(1-2x))) / (exp(a) - exp(-a))

For exp the higher a is,  the more flat the curve is.

This is from my notes so it could be wrong and needs to be verified (with a graphic calculator f.e.)
This should be easy to implement (at least it was for me).

Really Weird Person

The linear and cubic ones look right as far as I can tell. I took advanced algebra last year, but I do not recall how all of those functions are formatted (at least, not simply off the top of my head). It is odd though how I do not see at least the quadratic function (f(x) = x²) is not there though. Perhaps that one was forgotten.

Paul Legovitch

Quote from: "Really Weird Person"It is odd though how I do not see at least the quadratic function (f(x) = x²) is not there though. Perhaps that one was forgotten.
Like I said any function f with 0<f<1 and f(0)=0 , f(1)=1 will work so f(x)=power(x,n) will work for any real value of n>0.

The x²(3-2x) and the cosinus ones have 0.5 as a symmetrical center, so they make the interpolation of several points very smooth.
In the last version of VolFX I've been working on, you can have a custom function to interpolate values. You can f.e. enter a sinus like function that will oscillate several times while sliding from the first to the last value.

Harbinger

Would you all be in support of a separate dialog in which you can assign different interpolation algorithms/methods/filters, or do you want to keep it in the contextual menu (one-click and it's done)?

Paul Legovitch

I'm for sub-menus of the contextual menu with a list of interpolation types (a sub-menu for "Interpolate Effect" and another one for "interpolate Vol Col").
The last used type would be marked as "(current)" in the list and remembered by the interpolation shortcuts (Ctrl+K and Ctrl+J).

It would be nice to use interpolation also in the param editor (press shift to interpolate values between two clicks) but that's another story.

Saga Musix

well, as rewbs has pointed out before, there are probably dozens of desired interpolation algorithms, pattern transformations etc. that could be added, so it would probably better to go with some kind of scripting system or formula evaluation instead of adding yet another context menu with 100 types of interpolation.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.