# Interpolation with specified end derivatives

Started by January 2, 2009
```>dmnc, can you be a little more specific about what you're doing?  are
>you interpolating uniformly spaced points of an amplitude envelope?
>if so, what are the problems with using a big lookup table to get the
>weighting coefficients to combine adjacent samples?  are they non-
>uniformly spaced?  is there some reason you do not expect the
>interpolated value to be anything other than a linear combination of
>some set of  adjacent points on both sides of the interpolated
>location?
>
>we understand you want infinite resolution on the location of the
>interpolated point.  and that you want your interpolated function to
>be smooth. (why not more derivatives than just the 0th and 1st?)
>
>i don't think you are considering all of the issues when you repeat
>"no, no, ...".  i suspect you do not understand what we're saying.
>
>r b-j

Hi r-b-j,

somehow I think I understand :-). Anyway, so the usage is like this: I
want to create a really universal envelope editor, which could be used for
audio volume, pitch, oscilator shaping, just anything. It can contain any
number of control points and each segment between them may be interpolated
with different method. Maybe the user wants it to be a straight line, a
curve with adjustable shape, a smooth curve...

It can be addressed randomly. For volumes, it will be accessed from the
beggining to the end, but e.g. for pitch it may not. Moreover those
envelopes may be combined to generate even more complex shapes. And this is
just my first idea.

Loopup table would be good, but there is one problem - interpolating
adjacent samples from the table would not be very accurate and the table
must have been very very large. Imaging an envelope in range 0..1, where
0..0.49 is constant, 0.51..1 is constant and there are many points in
between. To represent this accurately you need the table to be very large
to represent all those points, becase it may e.g. be addressed with
precision of 0.00001 in X. And this would take a lot of time to generate
(which is not possible), the table would be very large and in therefore it
would take a lot of memory, which would be too slow in this case.

But I think everything is okay now ;-).
I hope this was understandable :-).

dmnc

```
```Btw. I just looked at the hermite interpolation and I have to say... I'm so
so stupid :-))).. When I write the equatations for the first time without
your help, I saw the derivatives and thought "ou differential equatations".
And I was so scared, that I rather start thinking about curving ellipses
and such nonsense :-)))...

Thanks guys once more!

dmnc
```
```jungledmnc wrote:

> I want to create a really universal envelope editor, which
> could be used for audio volume, pitch, oscilator shaping, just
> anything.

Negative values are inadmissible for some of those, and you want to
limit your envelopes' upward excursion too. If you use the shortest
polynomial to splice given endpoints and directions, you have no
control over the resulting peak value which gets larger the steeper
the directions.

You could add extremum equations to the interpolation constraints on
the polynomial, increasing its order to 5 or more. However, when you
have steep endpoint slopes (relative to distance from the excursion
limit) then it will be more stable and controllable to use low-order

Martin

--
Quidquid latine scriptum est, altum videtur.
```
```On Jan 5, 5:44&#2013266080;am, "jungledmnc" <jungled...@gmail.com> wrote:
> >dmnc, can you be a little more specific about what you're doing? &#2013266080;are
> >you interpolating uniformly spaced points of an amplitude envelope?

...

>
> somehow I think I understand :-). Anyway, so the usage is like this: I
> want to create a really universal envelope editor, which could be used for
> audio volume, pitch, oscilator shaping, just anything. It can contain any
> number of control points and each segment between them may be interpolated
> with different method. Maybe the user wants it to be a straight line, a
> curve with adjustable shape, a smooth curve...
>
> It can be addressed randomly.

i understand that as a specification.  random access addressing.  you
drop your point in time to be anywhere you want and you want to
compute the interpolated value at that point in time without have to
precompute a bunch of other filtered or interpolated values.

> For volumes, it will be accessed from the
> beggining to the end, but e.g. for pitch it may not. Moreover those
> envelopes may be combined to generate even more complex shapes. And this is
> just my first idea.
>
> Loopup table would be good, but there is one problem - interpolating
> adjacent samples from the table would not be very accurate and the table
> must have been very very large.

8K entries in the table is "very very" large?

points (that you are interpolating between) are equally spaced in
time, you can use a table that small (or even smaller, if you're
comparing to 3rd-order hermite) along with linear interpolation
between the finite number of fractional delay points that the table
hits.  you still have complete random addressing.  but you have to
divide your fractional delay address into two parts (which is easy if
you have the number of fractional delays in your table is a power of
two - you simply mask the bits).  the most-significant part is used to
decide which entries in you table to use to interpolate.  the least-
significant part is used to do linear interpolation between these very
closely spaced fractional delays.

now *that* works for data points that are equally (or "uniformly")
spaced.  are your data points uniformly spaced?  if so, your life can

> Imaging an envelope in range 0..1, where
> 0..0.49 is constant, 0.51..1 is constant and there are many points in
> between. To represent this accurately you need the table to be very large
> to represent all those points, because it may e.g. be addressed with
> precision of 0.00001 in X. And this would take a lot of time to generate
> (which is not possible), the table would be very large and in therefore it
> would take a lot of memory, which would be too slow in this case.

you're gonna have to re-explain this for me to understand you.

> But I think everything is okay now ;-).
> I hope this was understandable :-).

not all of it was.

r b-j
```
```emre wrote:
>> I need an interpolation between 2 points, where I can specify x1,y1,x2,y2
>> as usual and also derivatives at both ends. I need it to be computed
> fast
>> and accurate. It should be an interpolation with minimal (or small)
>> curvature.
>
> Hi,
>
> Could you elaborate a little more...
>
>    1) how fast?  (real time / offline?)  define "fast".
>    2) how accurate?  could you specify a cost function?
>    3) what is "small curvature"?
> is it a polynomial? is it random with a known pdf / power spectrum?... (the
> more prior information, the "better" you can interpolate.)
>
> The following quotation was displayed inside the physics lab at our high
> school: "He who doesn't know what he's looking for can not understand what
> he finds."  I'd hate to sound preachy, but I believe it applies here.

One of the signs I hung in my father's workshop read, "Tell me what you
need and I'll show you how to do without it." (Alright, I was a
disgustingly cocky kid.) It too may apply here. Have a look at
only allot matching the derivative at one end (or where segments join)
but that is often enough.

Jerry
--
Engineering is the art of making what you want from things you can get.
&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
```
```>*if* (and you haven't answered this "if" question yet), your data
>points (that you are interpolating between) are equally spaced in
>time, you can use a table that small (or even smaller, if you're
>comparing to 3rd-order hermite) along with linear interpolation
>between the finite number of fractional delay points that the table
>hits.  you still have complete random addressing.  but you have to
>divide your fractional delay address into two parts (which is easy if
>you have the number of fractional delays in your table is a power of
>two - you simply mask the bits).  the most-significant part is used to
>decide which entries in you table to use to interpolate.  the least-
>significant part is used to do linear interpolation between these very
>closely spaced fractional delays.
>
>now *that* works for data points that are equally (or "uniformly")
>spaced.  are your data points uniformly spaced?  if so, your life can

I'm not sure if I understand this. I want it to be accessed randomly, so
no equal spacing, any fractional number. And the control points (between
which are interpolating) may have absolutely any position.

>> Imaging an envelope in range 0..1, where
>> 0..0.49 is constant, 0.51..1 is constant and there are many points in
>> between. To represent this accurately you need the table to be very
large
>> to represent all those points, because it may e.g. be addressed with
>> precision of 0.00001 in X. And this would take a lot of time to
generate
>> (which is not possible), the table would be very large and in therefore
i=
>t
>> would take a lot of memory, which would be too slow in this case.

Imagine an A4 paper on desk in front of you directed horizontally. Take a
pen an paint some points. You can paint them anywhere. And now you have
several control points, one border of the paper is X axis, the second one
Y. And you want to be able to get Y value for any X. If you have painted
many control points let's say around the center X but with very different Y
(10 dots in the center top, 10 dots in the center bottom), the interpolated
function will look like a big mess in there and you will need at least some
values in the lookup table corresponding to the interval between them to
define the values correctly. Since there is teoretically no limit between
the distance of neighbouring points, there is no way you can create a look
table - except having a lookup table for each pair of neighbours and what
is the advantage of it then? (I mean against using cubic curve directly)

>you're gonna have to re-explain this for me to understand you.
>
>> But I think everything is okay now ;-).
>> I hope this was understandable :-).
>
>not all of it was.

Yeah, I couldn't be a teacher :-)))

dmnc.
```