|
DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
|
Fractional-position interpolation for delay lines, tables and buffers. More...


Go to the source code of this file.
Namespaces | |
| namespace | dspark |
| Main namespace for the DSPark framework. | |
Functions | |
| template<FloatType T> | |
| T | dspark::interpolateLinear (T y0, T y1, T frac) noexcept |
| Linear interpolation between two adjacent samples. | |
| template<FloatType T> | |
| T | dspark::interpolateLinear (const T *buffer, int length, T position) noexcept |
| Linear interpolation reading directly from a circular buffer. | |
| template<FloatType T> | |
| T | dspark::interpolateHermite (T y0, T y1, T y2, T y3, T frac) noexcept |
| 4-point, 3rd-order Hermite interpolation (optimized x-form). | |
| template<FloatType T> | |
| T | dspark::interpolateHermite (const T *buffer, int length, T position) noexcept |
| template<FloatType T> | |
| T | dspark::interpolateCubic (const T *buffer, int length, T position) noexcept |
| Alias of interpolateHermite (Catmull-Rom evaluated in Hermite form). Kept for backward compatibility. | |
| template<FloatType T> | |
| T | dspark::interpolateLagrange (T y0, T y1, T y2, T y3, T frac) noexcept |
| 4-point Lagrange interpolation from discrete samples. | |
| template<FloatType T> | |
| T | dspark::interpolateLagrange (const T *buffer, int length, T position) noexcept |
| template<FloatType T> | |
| T | dspark::interpolateAllpass (T currentSample, T previousSample, T frac, T &state) noexcept |
| Allpass interpolation (first-order Thiran) for fractional delay. | |
Fractional-position interpolation for delay lines, tables and buffers.
4-point Lagrange interpolation reading directly from a circular buffer.
4-point Hermite interpolation reading directly from a circular buffer.
Free-function interpolators used across the framework (RingBuffer's interpolated reads, modulated delay lines). All of them are small scalar helpers that inline into the caller's loop; none allocates or locks.
| Method | Points | Quality | CPU Cost | Use case |
|---|---|---|---|---|
| Linear | 2 | Low | Ultra-Low | LFOs, crossfades |
| Hermite | 4 | Good+ | Low | Modulated delays (default) |
| Lagrange | 4 | High | Low | Precision fractional reads |
| Allpass | 2 | Frequency-dep | Low | Static fractional delays |
Polynomial accuracy: Linear reconstructs degree-1 signals exactly, Hermite (Catmull-Rom) degree 2, Lagrange degree 3. Hermite is the recommended default for modulated delay lines (chorus, vibrato, reverb modulation): it is stateless and C1-continuous across segments, so fast frac changes never destabilise anything, unlike the recursive Allpass interpolator.
Two overload families:
Threading: all functions are pure and re-entrant; the Allpass state lives in the caller. Real-time safe: no allocation, no locks, no modulo; the only floating-point division is the Allpass coefficient (one per call).
Dependencies: DspMath.h (FloatType concept).
Interpolates between buffer[floor(position)] and the next sample; the two outer neighbours wrap around the buffer ends (circular contract, see notes).
| buffer | Pointer to the start of the audio buffer. |
| length | Size of the buffer in samples (must be > 0). |
| position | Absolute read position. |
Definition in file Interpolation.h.