Jamoma API  0.6.0.a19
TTInterpolate.h File Reference

Interpolation Utilities. More...

#include "TTBase.h"
+ Include dependency graph for TTInterpolate.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<class T >
TTInterpolateLinear (const T &x0, const T &x1, const double &delta)
 Isolate the fractional part from a double. More...
 
template<class T >
TTInterpolateCosine (const T &x, const T &y, const double &a)
 Cosine interpolation. More...
 
template<class T >
TTInterpolateCubic (const T &x0, const T &x1, const T &x2, const T &x3, const double &aDelta)
 Cubic interpolation. More...
 
template<class T >
TTInterpolateSpline (const T &w, const T &x, const T &y, const T &z, const double &a)
 Spline interpolation based on the Breeuwsma catmull-rom spline. More...
 
template<class T >
TTInterpolateHermite (const T &w, const T &x, const T &y, const T &z, const double &a, const double &bias, const double &tension)
 Hermite interpolation. More...
 

Detailed Description

Interpolation Utilities.

Defines several functions for interpolating between discrete data points such as those found in an array or matrix. These methods are commonly used in digital audio whenever we alter the rate at which a signal is read. These functions require known discrete values to be passed by reference along with a double between 0 and 1 representing the fractional location desired. They return the interpolated value.

Author
Timothy Place

Definition in file TTInterpolate.h.

Function Documentation

template<class T >
T TTInterpolateCosine ( const T &  x,
const T &  y,
const double &  a 
)

Cosine interpolation.

Parameters
xSample value at prior integer index
ySample value at next integer index
aFractional location between x (0) and y (1)
Returns
The interpolated value.

TTInterpolateLinear TTInterpolateHermite TTInterpolateCubic TTInterpolateSpline

Definition at line 65 of file TTInterpolate.h.

References kTTPi.

Referenced by InterpolateAndTestCosine().

template<class T >
T TTInterpolateCubic ( const T &  x0,
const T &  x1,
const T &  x2,
const T &  x3,
const double &  aDelta 
)

Cubic interpolation.

This interpolation algorithms calculate the coefficients a, b, c, d of the 3rd order polynomial

f(delta) = a*aDelta^3 + b*aDelta^2 + c*aDelta + d = ( (a*aDelta + b )*aDelta + c)*aDelta + d)

so that the function fulfill the following four conditions:

  1. f(0) = x1
  2. f(1) = x2
  3. f'(0) = (x2-x0)/2
  4. f'(1) = (x3-x1)/2

The two last conditions use a symetric estimate of the difference at the end points of the region to interpolate over: 0 ≤ aDelta ≤ 1

These asumptions ensure that the resulting interpolated function, when moving over several subsequent sections, is:

  1. Continuous (no sudden jump)
  2. Has a continuous derivative (no break pints with hard edges)

However, the 2nd order derivate will generally be discontinuous on the points connecting two sections.

Parameters
x0Sample value at integer index prior to x0
x1Sample value at prior integer index
x2Sample value at next integer index
x3Sample value at integer index after x2
aDeltaFractional location where we want to do the interpolation.
aDelta = 0 => interpolatedeValue = x1
aDelta = 1 => interpolatedeValue = x2
Returns
The interpolated value.

TTInterpolateLinear TTInterpolateCosine TTInterpolateHermite TTInterpolateSpline

Definition at line 115 of file TTInterpolate.h.

Referenced by InterpolateAndTestCubic().

template<class T >
T TTInterpolateHermite ( const T &  w,
const T &  x,
const T &  y,
const T &  z,
const double &  a,
const double &  bias,
const double &  tension 
)

Hermite interpolation.

Parameters
wSample value at integer index prior to x
xSample value at prior integer index
ySample value at next integer index
zSample value at integer index after y
aFractional location between x (0) and y (1)
Returns
The interpolated value.

TTInterpolateLinear TTInterpolateCosine TTInterpolateCubic TTInterpolateSpline

Definition at line 167 of file TTInterpolate.h.

template<class T >
T TTInterpolateLinear ( const T &  x0,
const T &  x1,
const double &  delta 
)

Isolate the fractional part from a double.

Essentially wraps the modf() function, but protects Jamoma in case it ever prooves uneven in implementation. NW: FAILS TO BUILD but Xcode can't find error.

Parameters
aaDouble whose fractional part you would like.
Returns
The fractional portion of aa.

double TTSplitFractional(double& aa) { double discard; return modf(aa,&discard); } Linear interpolation.

Parameters
x0Sample value at prior integer index
x1Sample value at next integer index
deltaLinear interpolation between x0 (delta=0) and x1 (delta=1)
Returns
The interpolated value.

TTInterpolateCosine TTInterpolateCubic TTInterpolateSpline TTInterpolateHermite

Definition at line 47 of file TTInterpolate.h.

Referenced by InterpolateAndTestLinear(), and TTSoundfile::peeki().

template<class T >
T TTInterpolateSpline ( const T &  w,
const T &  x,
const T &  y,
const T &  z,
const double &  a 
)

Spline interpolation based on the Breeuwsma catmull-rom spline.

Parameters
wSample value at integer index prior to x
xSample value at prior integer index
ySample value at next integer index
zSample value at integer index after y
aFractional location between x (0) and y (1)
Returns
The interpolated value.

TTInterpolateLinear TTInterpolateCosine TTInterpolateCubic TTInterpolateHermite

Definition at line 143 of file TTInterpolate.h.