DSPark 1.8.0
Header-only C++20 DSP for real-time and offline audio
Loading...
Searching...
No Matches
dspark::StretchedSincReader< T > Class Template Reference

Band-limited fractional reader for read rates from 1 to 4. More...

#include <Interpolation.h>

Public Member Functions

 StretchedSincReader ()
 Builds the kernel tables (allocates: construct on a setup thread).
 
T readRing (const T *ring, int64_t mask, int64_t intPos, double frac, int step) const noexcept
 Reads a power-of-two ring buffer at intPos + frac with the kernel of a rate step. It needs the samples intPos - reach(step) + 1 through intPos + reach(step).
 
int reach (int step) const noexcept
 

Static Public Member Functions

static int stepFor (double rate) noexcept
 The table for a read rate: the nearest tabulated rate at or above it. Costs a log2, so look it up once per constant rate.
 

Static Public Attributes

static constexpr int kSteps = 16
 Tabulated rates.
 
static constexpr int kStepsPerOctave = 8
 Rate resolution.
 
static constexpr int kPhases = 64
 Phases per rate.
 
static constexpr int kMaxTaps = 128
 Kernel length at rate 4.
 

Detailed Description

template<FloatType T>
class dspark::StretchedSincReader< T >

Band-limited fractional reader for read rates from 1 to 4.

A read point that advances by r > 1 samples per output sample decimates: content above Nyquist / r folds back unless the kernel's cutoff drops to Nyquist / r. This reader tabulates such kernels (the sinc stretched by r under a Kaiser window, beta 10, about 32 r taps) for 16 rates in eighth-octave steps from 2^(1/8) to 4, at 64 phases each, and reads with the kernel of the nearest tabulated rate at or above the requested one: nothing folds back from beyond the output Nyquist, and the band gives up at most an eighth of an octave at the top. Passband error stays below -76 dB up to three quarters of the cutoff. For rates at or below 1 use SincInterpolator.

Threading: the constructor builds about 60 k coefficients (allocates: setup thread); reads are const, allocation-free and safe from any thread.

Template Parameters
TSample type (float or double).

Definition at line 446 of file Interpolation.h.

Constructor & Destructor Documentation

◆ StretchedSincReader()

template<FloatType T>
dspark::StretchedSincReader< T >::StretchedSincReader ( )
inline

Builds the kernel tables (allocates: construct on a setup thread).

Definition at line 455 of file Interpolation.h.

Member Function Documentation

◆ reach()

template<FloatType T>
int dspark::StretchedSincReader< T >::reach ( int  step) const
inlinenoexcept
Returns
Samples a read of this step reaches on either side of intPos.

Definition at line 552 of file Interpolation.h.

◆ readRing()

template<FloatType T>
T dspark::StretchedSincReader< T >::readRing ( const T *  ring,
int64_t  mask,
int64_t  intPos,
double  frac,
int  step 
) const
inlinenoexcept

Reads a power-of-two ring buffer at intPos + frac with the kernel of a rate step. It needs the samples intPos - reach(step) + 1 through intPos + reach(step).

Parameters
ringRing storage.
maskRing size minus one (the size must be a power of two).
intPosInteger read position (masked, so any value works).
fracFractional position in [0, 1).
stepRate step from stepFor().
Returns
Interpolated value.

Definition at line 522 of file Interpolation.h.

◆ stepFor()

template<FloatType T>
static int dspark::StretchedSincReader< T >::stepFor ( double  rate)
inlinestaticnoexcept

The table for a read rate: the nearest tabulated rate at or above it. Costs a log2, so look it up once per constant rate.

Parameters
rateRead rate, clamped to [2^(1/8), 4].
Returns
Step index in [0, kSteps).

Definition at line 505 of file Interpolation.h.

Member Data Documentation

◆ kMaxTaps

template<FloatType T>
constexpr int dspark::StretchedSincReader< T >::kMaxTaps = 128
staticconstexpr

Kernel length at rate 4.

Definition at line 452 of file Interpolation.h.

◆ kPhases

template<FloatType T>
constexpr int dspark::StretchedSincReader< T >::kPhases = 64
staticconstexpr

Phases per rate.

Definition at line 451 of file Interpolation.h.

◆ kSteps

template<FloatType T>
constexpr int dspark::StretchedSincReader< T >::kSteps = 16
staticconstexpr

Tabulated rates.

Definition at line 449 of file Interpolation.h.

◆ kStepsPerOctave

template<FloatType T>
constexpr int dspark::StretchedSincReader< T >::kStepsPerOctave = 8
staticconstexpr

Rate resolution.

Definition at line 450 of file Interpolation.h.


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