DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
Loading...
Searching...
No Matches
dspark::MinBlepTable< T > Class Template Reference

Shared minimum-phase band-limited step (minBLEP) residual table. More...

#include <MinBlepTable.h>

Public Member Functions

residual (T t) const noexcept
 Residual of the minimum-phase band-limited step at position t.
 

Static Public Member Functions

static const MinBlepTableinstance () noexcept
 Returns the process-wide shared table, building it on first call.
 

Static Public Attributes

static constexpr int kTaps = 64
 Correction span in base-rate samples (power of two, ring-buffer friendly).
 
static constexpr int kOversample = 64
 
static constexpr int kTableSize = kTaps * kOversample + 1
 Total table entries (one guard point at the end for interpolation).
 

Detailed Description

template<typename T>
class dspark::MinBlepTable< T >

Shared minimum-phase band-limited step (minBLEP) residual table.

A discontinuity rendered naively into a sample stream aliases. The classic fix is to replace the ideal step with a band-limited one; the minimum-phase variant (Brandt, ICMC 2001) concentrates all of its energy at and after the discontinuity, which has two practical consequences:

  • Causal correction – the residual is zero before the event, so no look-ahead, no pre-ringing, and no kernel halves that must be predicted or un-queued when events collide (the failure mode that makes 2-point PolyBLEP hard-sync bookkeeping delicate).
  • Long kernel for free – since nothing precedes the event, the kernel can be dozens of samples long without adding latency, pushing alias rejection from the ~-40 dB envelope of a 2-point polynomial kernel to the stopband of a properly windowed sinc (~-90 dB).

The table is built once per process from first principles (no baked-in magic data): a Blackman-Harris windowed sinc cutting at the base-rate Nyquist is converted to minimum phase via the real cepstrum, integrated into a step, and stored as the residual minBlepStep(t) - unitStep(t) at kOversample sub-sample positions per output sample.

Usage – for a discontinuity of amplitude jump occurring frac samples before output sample n (frac in [0, 1)), add jump * residual(j + frac) to output sample n + j for j = 0 .. kTaps - 1. The naive signal must already contain the raw step.

Note
instance() builds the table on first call (FFT work and temporary heap allocations of ~1.6 MB). Call it once from a control thread – e.g. inside prepare() – never from the audio thread. After construction the table is immutable and lock-free to read from any thread. The build is noexcept by design: an allocation failure during it terminates (fail-fast; the only caller path is a noexcept prepare() anyway).
Template Parameters
TSample type (float or double). Table generation always runs in double precision internally.

Definition at line 71 of file MinBlepTable.h.

Member Function Documentation

◆ instance()

template<typename T >
static const MinBlepTable & dspark::MinBlepTable< T >::instance ( )
inlinestaticnoexcept

Returns the process-wide shared table, building it on first call.

Thread-safe (C++11 magic static). The one-time build performs FFTs and temporary allocations – touch it from prepare(), not the audio thread.

Definition at line 90 of file MinBlepTable.h.

◆ residual()

template<typename T >
T dspark::MinBlepTable< T >::residual ( t) const
inlinenoexcept

Residual of the minimum-phase band-limited step at position t.

Parameters
tTime since the discontinuity, in samples (fractional). Must be >= 0; values beyond the table return 0 (the step has settled).
Returns
minBlepStep(t) - 1 – starts near -1 right at the event (the band-limited transition has barely begun) and decays to exactly 0 at the end of the table.

Definition at line 105 of file MinBlepTable.h.

Member Data Documentation

◆ kOversample

template<typename T >
constexpr int dspark::MinBlepTable< T >::kOversample = 64
staticconstexpr

Sub-sample table resolution. Linear interpolation between entries keeps the sampling error near -80 dB, matching the window's stopband class.

Definition at line 80 of file MinBlepTable.h.

◆ kTableSize

template<typename T >
constexpr int dspark::MinBlepTable< T >::kTableSize = kTaps * kOversample + 1
staticconstexpr

Total table entries (one guard point at the end for interpolation).

Definition at line 82 of file MinBlepTable.h.

◆ kTaps

template<typename T >
constexpr int dspark::MinBlepTable< T >::kTaps = 64
staticconstexpr

Correction span in base-rate samples (power of two, ring-buffer friendly).

Definition at line 77 of file MinBlepTable.h.


The documentation for this class was generated from the following file: