Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
sinc_resampler.hpp File Reference

Fractional-delay resampling by a Kaiser-windowed sinc kernel. More...

#include <pulp/signal/checked_allocation.hpp>
#include <algorithm>
#include <cmath>
#include <cstddef>
#include <vector>

Go to the source code of this file.

Classes

class  pulp::signal::SincResamplerT< SampleType >

Namespaces

namespace  pulp
namespace  pulp::signal

Typedefs

using pulp::signal::SincResampler = SincResamplerT<float>
using pulp::signal::SincResampler64 = SincResamplerT<double>

Detailed Description

Fractional-delay resampling by a Kaiser-windowed sinc kernel.

Reading a buffer at an arbitrary fractional position is an interpolation problem. Cubic (Catmull-Rom) interpolation is cheap but its stopband rejection is poor, so resampling a signal — e.g. the resample step of phase-vocoder pitch shifting — folds high-frequency energy back as audible aliasing, worst on large shifts and bright material. A windowed-sinc kernel is the band-limited reconstruction filter: an ideal sinc (the perfect interpolator) truncated to a finite half-width and tapered by a Kaiser window to trade transition width against stopband depth (Smith, "Digital Audio Resampling," CCRMA; Kaiser & Schafer 1980 for the β/attenuation relation).

Implementation: a precomputed table of the windowed sinc, oversampled in the fractional-phase dimension and read with linear interpolation between phase entries (the standard table-driven resampler). For a fractional source position p, the output is the sum over 2*half neighboring input samples weighted by the kernel evaluated at their distance from p. Real-time-safe after build(); no allocation in read().

RT contract: build() allocates the kernel table and is not audio-thread safe. apply(), read(), and accessors are allocation-free after build().