Sound Byte Libs 0.5.1-340-gab5b79a
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
sbl::dsp::BlepCorrector< Kernel > Class Template Reference

The correction buffer behind a band-limited edge, over a BLEP kernel. More...

Detailed Description

template<class Kernel>
class sbl::dsp::BlepCorrector< Kernel >

The correction buffer behind a band-limited edge, over a BLEP kernel.

Holds the pending corrections for the frames an event touches and emits each frame once its corrections are complete, so the output trails the naive waveform by Kernel::LATENCY frames. Corrections from events closer than the kernel's span add linearly, which is exact. History and pending corrections are rings, so a frame moves an index and not the buffers; the pending ring wraps by a mask, so a kernel's FRAMES is a power of two.

Per frame, in this order: step() or corner() for each event that fell in the frame, with its sub-frame time from math::polyblep_time(), then process() with the frame's naive sample. An oscillator core, a hard clipper or an audio-rate sample-and-hold owns one of these; it is below the signal transport and has no ports.

The kernel is a policy type (the contract is in dsp/math/polyblep.hpp and checked below): math::Sinc16, the cores' default, math::Bspline4 and math::Linear2.

Template Parameters
KernelA BLEP kernel whose FRAMES is a power of two

In a build with profiling, blep_correction_count() is the number of step() and corner() calls on every corrector, for an app that reports its events.

Definition at line 103 of file blep_corrector.hpp.

#include <blep_corrector.hpp>

Inheritance diagram for sbl::dsp::BlepCorrector< Kernel >:
[legend]

Public Member Functions

void step (float t, float height)
 A value step at a sub-frame time within the frame about to be pushed.
 
void corner (float t, float delta)
 A slope change at a sub-frame time within the frame about to be pushed.
 
float process (float naive)
 Push the frame's naive sample; return the corrected sample LATENCY frames back.
 
void reset ()
 Forget history and pending corrections.
 

Static Public Attributes

static constexpr uint8_t LATENCY = Kernel::LATENCY
 Frames the output trails the naive waveform.
 

Member Function Documentation

◆ step()

template<class Kernel >
void sbl::dsp::BlepCorrector< Kernel >::step ( float  t,
float  height 
)
inline

A value step at a sub-frame time within the frame about to be pushed.

Parameters
tFraction of a frame since the step, read at the frame about to be pushed, in [0, 1)
heightHeight of the step
Context
Audio thread; real-time safe.

Definition at line 126 of file blep_corrector.hpp.

◆ corner()

template<class Kernel >
void sbl::dsp::BlepCorrector< Kernel >::corner ( float  t,
float  delta 
)
inline

A slope change at a sub-frame time within the frame about to be pushed.

Parameters
tFraction of a frame since the corner, read at the frame about to be pushed, in [0, 1)
deltaChange of slope, per frame
Context
Audio thread; real-time safe.

Definition at line 135 of file blep_corrector.hpp.

◆ process()

template<class Kernel >
float sbl::dsp::BlepCorrector< Kernel >::process ( float  naive)
inline

Push the frame's naive sample; return the corrected sample LATENCY frames back.

The first LATENCY outputs after a reset are zero.

Parameters
naiveThe frame's naive sample
Returns
The corrected sample LATENCY frames back
Context
Audio thread; real-time safe.

Definition at line 146 of file blep_corrector.hpp.

◆ reset()

template<class Kernel >
void sbl::dsp::BlepCorrector< Kernel >::reset ( )
inline

Forget history and pending corrections.

Definition at line 161 of file blep_corrector.hpp.

Member Data Documentation

◆ LATENCY

template<class Kernel >
constexpr uint8_t sbl::dsp::BlepCorrector< Kernel >::LATENCY = Kernel::LATENCY
staticconstexpr

Frames the output trails the naive waveform.

Definition at line 117 of file blep_corrector.hpp.


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