pub fn cubic_interpolate<F: Flt>(
    data: &[F],
    len: usize,
    index: usize,
    fract: F
) -> F
Expand description

Hermite / Cubic interpolation of a buffer full of samples at the given index. len is the buffer length to consider and wrap the index into. And fract is the fractional part of the index.

This function is generic over f32 and f64. That means you can use your preferred float size.

Commonly used like this:

 use synfx_dsp::cubic_interpolate;

 let buf : [f32; 9] = [1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2];
 let pos = 3.3_f32;

 let i = pos.floor() as usize;
 let f = pos.fract();

 let res = cubic_interpolate(&buf[..], buf.len(), i, f);
 assert!((res - 0.67).abs() < 0.2_f32);