Interpolation functions. More...
Classes | |
struct | Trunc |
Truncating random-access interpolation strategy. More... | |
struct | Round |
Nearest neighbor random-access interpolation strategy. More... | |
struct | Linear |
Linear random-access interpolation strategy. More... | |
struct | Cubic |
Cubic random-access interpolation strategy. More... | |
struct | AllPass |
Allpass random-access interpolation strategy. More... | |
struct | Any |
Dynamically switchable random-access interpolation strategy. More... | |
Enumerations | |
enum | Type { TRUNC = 0, ROUND, LINEAR, CUBIC, ALLPASS } |
Interpolation types. More... | |
Functions | |
template<class Tf , class Tv > | |
Tv | allpass (Tf frac, const Tv &x, const Tv &y, Tv &o1) |
First order allpass interpolation. | |
template<class T > | |
void | lagrange (T *h, T delay, int order) |
Computes FIR coefficients for Waring-Lagrange interpolation. | |
template<class T > | |
void | lagrange1 (T *h, T delay) |
Optimized lagrange() for first order. | |
template<class T > | |
void | lagrange2 (T *h, T delay) |
Optimized lagrange() for second order. | |
template<class T > | |
void | lagrange3 (T *h, T delay) |
Optimized lagrange() for third order. | |
template<class T > | |
T | parabolic (T xm1, T x, T xp1) |
Simplified parabolic interpolation of 3 points. | |
template<class Tf , class Tv > | |
Tv | cubic (Tf frac, const Tv &w, const Tv &x, const Tv &y, const Tv &z) |
Cubic interpolation. | |
template<class Tf , class Tv > | |
Tv | linear (Tf frac, const Tv &x, const Tv &y) |
Linear interpolation. Identical to first order Lagrange. | |
template<class Tf , class Tv > | |
Tv | linear (Tf frac, const Tv &x, const Tv &y, const Tv &z) |
Linear interpolation between three elements. | |
template<class Tf , class Tv > | |
Tv | nearest (Tf frac, const Tv &x, const Tv &y) |
Nearest neighbor interpolation. | |
template<class Tf , class Tv > | |
Tv | quadratic (Tf frac, const Tv &x, const Tv &y, const Tv &z) |
Quadratic interpolation. |
Interpolation functions.
The naming convention for values is that their alphabetical order is equivalent to their sequence order (oldest to newest). The interpolated value lies 'frac' distance between 'x' and 'y' where 'frac' lies in [0, 1).
enum Type |
Tv allpass | ( | Tf | frac, |
const Tv & | x, | ||
const Tv & | y, | ||
Tv & | o1 | ||
) |
First order allpass interpolation.
Allpass interpolation preserves the spectral magnitude of the interpolated sequence. It should only be used for interpolating at a regular speed across a sequence. It will fail miserably at random access.
Tv cubic | ( | Tf | frac, |
const Tv & | w, | ||
const Tv & | x, | ||
const Tv & | y, | ||
const Tv & | z | ||
) |
Cubic interpolation.
This is a Cardinal spline with a tension of 0 (AKA a Catmull-Rom spline). The resulting value will never exceed the range of the interpolation points.
void lagrange | ( | T * | h, |
T | delay, | ||
int | order | ||
) |
Computes FIR coefficients for Waring-Lagrange interpolation.
'h' are the FIR coefficients and should be of size ('order' + 1).
'delay' is a fractional delay in samples.
As order increases, this converges to sinc interpolation.
T parabolic | ( | T | xm1, |
T | x, | ||
T | xp1 | ||
) |
Simplified parabolic interpolation of 3 points.
This assumes the points are spaced evenly on the x axis from [-1, 1]. The output is an offset from 0.