ModPlug Central

OpenMPT Development (Archive) => Feature Requests => Topic started by: Rakib on October 20, 2009, 20:44:18

Title: More types of interpolation
Post by: Rakib on October 20, 2009, 20:44:18
Today we can interpolate linear on the effects, can we have logaritmic/expontetial/Polynomial interpolation also.
Title: More types of interpolation
Post by: Sam_Zen on October 20, 2009, 22:45:52
I maybe support this, but I first want to know the ins and outs of the different algoritms.
Title: More types of interpolation
Post by: Rakib on October 20, 2009, 22:54:08
Look at renoise and se how its done there.
Title: More types of interpolation
Post by: Paul Legovitch on March 22, 2010, 22:45:01
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).
Title: Mathematical Algorithms
Post by: Really Weird Person on March 23, 2010, 04:34:27
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.
Title: Re: Mathematical Algorithms
Post by: Paul Legovitch on March 23, 2010, 09:22:55
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.
Title: More types of interpolation
Post by: Harbinger on March 25, 2010, 20:16:25
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)?
Title: More types of interpolation
Post by: Paul Legovitch on March 25, 2010, 21:58:01
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.
Title: More types of interpolation
Post by: Saga Musix on March 25, 2010, 22:13:47
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.