DSPark 1.9.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.
 
static constexpr double kCutoff = 0.85
 Kernel cutoff, fraction of the output Nyquist.
 

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. The kernel's cutoff sits at kCutoff = 0.85 of the output Nyquist, so its transition band ends near the output Nyquist: content at the output Nyquist folds back at about -46 dB and content from 1.05x upward below -100 dB. (With the cutoff AT the output Nyquist the fold was -6 dB at Nyquist, -13 dB at 1.05x and -26 dB at 1.1x.) The response is flat to 0.7 of the output Nyquist and -2 dB at 0.8, and the band gives up at most a further eighth of an octave to the rate table. 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 450 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 460 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 558 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 528 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 511 of file Interpolation.h.

Member Data Documentation

◆ kCutoff

template<FloatType T>
constexpr double dspark::StretchedSincReader< T >::kCutoff = 0.85
staticconstexpr

Kernel cutoff, fraction of the output Nyquist.

Definition at line 457 of file Interpolation.h.

◆ kMaxTaps

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

Kernel length at rate 4.

Definition at line 456 of file Interpolation.h.

◆ kPhases

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

Phases per rate.

Definition at line 455 of file Interpolation.h.

◆ kSteps

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

Tabulated rates.

Definition at line 453 of file Interpolation.h.

◆ kStepsPerOctave

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

Rate resolution.

Definition at line 454 of file Interpolation.h.


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