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 Namespace Reference

The audio stack. More...

Detailed Description

The audio stack.

Namespaces

namespace  math
 Math for the audio stack.
 
namespace  sinc_upsampler
 Generated coefficients of the SincUpsampler's kernel.
 
namespace  types
 Conversion at the DMA boundary.
 

Classes

class  BlepCorrector
 The correction buffer behind a band-limited edge, over a BLEP kernel. More...
 
class  BlepOsc
 The BLEP oscillator core: one phase, three waveform parts, band-limited edges. More...
 
class  DcBlock
 A one-pole high-pass with its zero at DC. More...
 
class  DryWet
 A dry/wet mix of two signals, the mix a port. More...
 
class  OnePole
 A one-pole low-pass, exact for an input that holds through the frame. More...
 
class  PhaseAccumulator
 A phase advanced by a signed step each frame, held as a 32-bit count of the cycle. More...
 
class  PhasePulse
 A band-limited pulse driven by a signed phase, its width placed by a bipolar anchor. More...
 
class  PhaseSaw
 A band-limited slope shape driven by a signed phase, from a falling saw through a triangle to a rising saw. More...
 
class  PhaseWalk
 A modulated phase walked frame by frame as segments, and the crossings of moving thresholds on them. More...
 
class  PmInput
 The PM signal, a sample a frame in and PM_SUBSTEPS values a frame out. More...
 
class  PmPulse
 A pulse oscillator with phase modulation: pitch, width, anchor, index and the PM signal over a PhasePulse. More...
 
class  Ramp
 A linear ramp to a target over a fixed number of frames. More...
 
class  SincUpsampler
 A frame-rate signal interpolated at FACTOR steps through each frame, LATENCY frames late. More...
 
class  Slew
 One-pole slew toward a target, with separate rise and fall time constants. More...
 
class  SoftLimiter
 A soft-knee limiter: the input under a knee, a tanh bend under a ceiling above it. More...
 
class  Svf
 A trapezoidal state-variable filter with five responses from one section. More...
 
class  Vca
 An amplifier: gain, Level and Mod Amt as ports over a linear multiply. More...
 
class  Vco
 An oscillator: Tune, and pitch, Wave and Shape as ports over a BlepOsc. More...
 

Functions

uint32_t blep_correction_count ()
 Corrections added by every BlepCorrector since the start.
 
float pm_frequency (float tune, float pitch)
 The step for a pitch in octaves over a tune.
 
float pm_depth (float index)
 Cycles of phase offset per unit of the PM signal for a bipolar index.
 
float pm_taming (float octaves_above_corner)
 The share of the depth kept at a pitch over PM_TAMING_CORNER.
 

Variables

constexpr float PM_MAX_FREQUENCY = 0.25f
 
constexpr float PM_MAX_INDEX = 0.5f
 
constexpr float PM_TAMING_CORNER = 1046.5f / 48000.0f
 Cycles per frame: where pm_taming()'s reduction starts, 1.05 kHz at 48 kHz.
 
constexpr float PM_TAMING_PER_OCTAVE = 0.3f
 
constexpr uint8_t PM_SUBSTEPS = SincUpsampler::FACTOR
 
constexpr uint8_t PM_LATENCY = SincUpsampler::LATENCY
 

Function Documentation

◆ blep_correction_count()

uint32_t sbl::dsp::blep_correction_count ( )
inline

Corrections added by every BlepCorrector since the start.

One for each step() and each corner(): an edge or a slope change that a core band-limited. Wraps at 2^32. Always 0 in a build without profiling.

Returns
The count
Context
Any thread; a plain, non-atomic read of a count the audio thread writes.

Definition at line 52 of file blep_corrector.hpp.

◆ pm_frequency()

float sbl::dsp::pm_frequency ( float  tune,
float  pitch 
)
inline

The step for a pitch in octaves over a tune.

Parameters
tuneTune in cycles per frame
pitchPitch in octaves over the tune
Returns
Step in cycles per frame, in [0, PM_MAX_FREQUENCY]; a NaN gives 0

Definition at line 38 of file pm.hpp.

References sbl::math::clamp(), sbl::dsp::math::frequency(), and PM_MAX_FREQUENCY.

◆ pm_depth()

float sbl::dsp::pm_depth ( float  index)
inline

Cycles of phase offset per unit of the PM signal for a bipolar index.

Quadratic, so most of the control's travel is the shallow end.

Parameters
indexIndex, nominally [-1, 1], not clamped; a non-finite index counts as 0
Returns
PM_MAX_INDEX * index * |index|, in cycles per unit of PM

Definition at line 50 of file pm.hpp.

References sbl::math::finite_or(), and PM_MAX_INDEX.

Referenced by sbl::dsp::PmPulse::index_cycles().

◆ pm_taming()

float sbl::dsp::pm_taming ( float  octaves_above_corner)
inline

The share of the depth kept at a pitch over PM_TAMING_CORNER.

The reduction of the depth with pitch that PmPulse applies, as Plaits reduces its FM amount (plaits/dsp/engine/fm_engine.cc:76-78). Without one, the PM's sidebands pass the Nyquist frequency at high pitch and fold. A component multiplies it in, or a curve of its own.

Parameters
octaves_above_cornerPitch in octaves over PM_TAMING_CORNER
Returns
(1 - PM_TAMING_PER_OCTAVE * octaves)^2 with the base clamped to [0, 1]: 1 at and under the corner, 0 from 40 semitones up; a NaN gives 0

Definition at line 67 of file pm.hpp.

References sbl::math::clamp(), and PM_TAMING_PER_OCTAVE.

Referenced by sbl::dsp::PmPulse::index_cycles().

Variable Documentation

◆ PM_MAX_FREQUENCY

constexpr float sbl::dsp::PM_MAX_FREQUENCY = 0.25f
inlineconstexpr

cycles per frame: fs/4, as BlepOsc caps it

Definition at line 23 of file pm.hpp.

Referenced by pm_frequency().

◆ PM_MAX_INDEX

constexpr float sbl::dsp::PM_MAX_INDEX = 0.5f
inlineconstexpr

cycles of offset per unit of PM at index 1

Definition at line 24 of file pm.hpp.

Referenced by pm_depth().

◆ PM_TAMING_CORNER

constexpr float sbl::dsp::PM_TAMING_CORNER = 1046.5f / 48000.0f
inlineconstexpr

Cycles per frame: where pm_taming()'s reduction starts, 1.05 kHz at 48 kHz.

Definition at line 26 of file pm.hpp.

◆ PM_TAMING_PER_OCTAVE

constexpr float sbl::dsp::PM_TAMING_PER_OCTAVE = 0.3f
inlineconstexpr

the reduction's slope before squaring: zero 40 semitones up

Definition at line 27 of file pm.hpp.

Referenced by pm_taming().

◆ PM_SUBSTEPS

constexpr uint8_t sbl::dsp::PM_SUBSTEPS = SincUpsampler::FACTOR
inlineconstexpr

offsets a frame

Definition at line 28 of file pm.hpp.

◆ PM_LATENCY

constexpr uint8_t sbl::dsp::PM_LATENCY = SincUpsampler::LATENCY
inlineconstexpr

frames the PM signal trails

Definition at line 29 of file pm.hpp.