|
DSPark 1.8.0
Header-only C++20 DSP for real-time and offline audio
|
32-tap Kaiser-windowed sinc reader for transparent fractional reads. More...
#include <Interpolation.h>
Public Member Functions | |
| SincInterpolator () | |
| Builds the kernel table (allocates: construct on a setup thread). | |
| T | read (const T *x, double frac) const noexcept |
| Interpolates kTaps consecutive samples at x[kBefore] + frac. | |
| T | readRing (const T *ring, int64_t mask, int64_t intPos, double frac) const noexcept |
| Reads a power-of-two ring buffer at intPos + frac. | |
Static Public Attributes | |
| static constexpr int | kTaps = 32 |
| Kernel length. | |
| static constexpr int | kBefore = kTaps / 2 - 1 |
| Samples needed before intPos. | |
| static constexpr int | kAfter = kTaps / 2 |
| Samples needed after intPos. | |
| static constexpr int | kPhases = 256 |
| Tabulated fractional phases. | |
32-tap Kaiser-windowed sinc reader for transparent fractional reads.
The reader for resampling a stream at a fixed or varying rate. Its worst-case error against the ideal fractional delay, over every fractional position, stays below -96 dB up to 15 kHz at 44.1 and 48 kHz (and 18 kHz at 48 kHz). A 4-point cubic (Hermite / Catmull-Rom) reader reaches -24 dB at 10 kHz and -12 dB at 15 kHz, and because its error changes with the fractional position, a moving read point turns it into modulation noise.
The kernel is a full-band sinc (cutoff at Nyquist) under a Kaiser window (beta 10), tabulated at 256 fractional phases, each normalized to unit DC gain, and linearly interpolated between phases. Integer positions are an exact identity. Near Nyquist the 32 taps cannot hold the band: at 20 kHz the error is -50 dB at 48 kHz and -17 dB at 44.1 kHz.
Reading position intPos + frac needs the samples intPos - 15 through intPos + 16.
| T | Sample type (float or double). |
Definition at line 322 of file Interpolation.h.
|
inline |
Builds the kernel table (allocates: construct on a setup thread).
Definition at line 331 of file Interpolation.h.
|
inlinenoexcept |
Interpolates kTaps consecutive samples at x[kBefore] + frac.
| x | Samples intPos - kBefore through intPos + kAfter. |
| frac | Fractional position in [0, 1). |
Definition at line 374 of file Interpolation.h.
|
inlinenoexcept |
Reads a power-of-two ring buffer at intPos + frac.
| ring | Ring storage. |
| mask | Ring size minus one (the size must be a power of two). |
| intPos | Integer read position (masked, so any value works). |
| frac | Fractional position in [0, 1). |
Definition at line 394 of file Interpolation.h.
|
staticconstexpr |
Samples needed after intPos.
Definition at line 327 of file Interpolation.h.
|
staticconstexpr |
Samples needed before intPos.
Definition at line 326 of file Interpolation.h.
|
staticconstexpr |
Tabulated fractional phases.
Definition at line 328 of file Interpolation.h.
|
staticconstexpr |
Kernel length.
Definition at line 325 of file Interpolation.h.