Csound Csound-dev Csound-tekno Search About

Re (II): Interpolation schemes and SB Live!

Date1998-10-22 15:39
FromJosep M Comajuncosas
SubjectRe (II): Interpolation schemes and SB Live!
Gabriel Maldonado wrote:

> Where is it possble to get the algorithm to implement 8 point interpolation? If I could
> see an example of it I will implement it in Csound.

Hi,
as I see you´re interested in the subject,
here it is the general formula for a Nth order Lagrange interpolator,
it works as a FIR structure and has an inherent lowpass behaviour,
but implements very accurately the fractional delay,
further references in T.Tolonen & Vesa Välimäky works.

Josep M Comajuncosas


This is a PS to text translation of their Thesis:

h(n) = mult (from k=0, k=!n to N) [(D-k)/(n-k)] for n= 0,1,2,...N (3.63)
where D is the fractional delay and N the order of the FIR filter.

Computation of Coefficients for a Lagrange Interpolator

The first­order Lagrange interpolator corresponds to the well­known
linear interpola­
tion. The coefficients are obtained from Eq. (3.63) with N = 1 as
h(0) = 1- D , h(1) = D
(3.72)
Note that in the first­order case D = d since the integer part of D is
zero.

The formulas for the filter coefficients of the Lagrange interpolator
with N = 2 are
h(0) = (1/2)(D -1)(D - 2)
h(1) = -D(D - 2)
h(2) = (1/2)D(D -1)
(3.73)

and with N = 3,
h(0) = -(1/6)(D -1)(D - 2)(D - 3)
h(1) = (1/2)D(D - 2)(D - 3)
h(2) = -(1/2)D(D -1)(D - 3)
h(3) = (1/6)D(D -1)(D - 2)
(3.74)

In general, the coefficients h(n) of the Lagrange interpolator are
determined by an
Nth­order polynomial in D. This implies that N additions and N
multiplications per
coefficient are required to evaluate its value for a given D.
Altogether, it takes
N(N +1) = N 2 + N additions and N 2 + N multiplications to update all
the N coeffi­
cients. An efficient procedure to update the coefficients of a Lagrange
interpolator was
introduced in Välimäki (1992, Appendix A):

1) evaluate the differences D -- 1, D -- 2, ..., D -- N;
2) evaluate the products D(D -- 1), (D -- 2)(D -- 3), ..., (D -- N +
1)(D -- N);
3) evaluate the coefficients h(0), h(1), ..., h(N) by multiplying the
results of Steps 1
and 2 and constant coefficients.

Using this technique, the computational burden of evaluating the
coefficients of an Nth­
order interpolator consists of N additions (subtractions) and less than
N 2 + N multipli­
cations.
For example, computing the values of the four coefficients of a
third­order Lagrange
interpolator using this method requires 3 additions and 10
multiplications. This is a
remarkable saving when compared to 12 additions and 12 multiplications
that would be
required were the straightforward polynomial evaluation used.
The most efficient practical solution to the updating of interpolating
coefficients is to
use table lookup. In software implementations this is usually the
fastest way, and thus
most recommendable, provided that the required memory space is
available.

> > Another question related to waveguide opcodes. Does deltapi (and delayw
> > btw) accept fractional sample delay lengths (well, fractional 1/kr
> > units) ?
>
> Yes it does.
>
> The problem is that the first order filters that are implemented in the waveguide opcodes
> don't use fractional delay, so the pitch of high notes is not precise.

Hmm a serious handicap.