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

Professional-grade pitch vibrato with LFO FM and parameter smoothing. More...

#include <Vibrato.h>

Public Types

enum class  Interpolation { Hermite , Sinc }
 Fractional read kernel of the modulated delay line. More...
 
enum class  Model { Digital , Analog }
 The engine. More...
 

Public Member Functions

void prepare (const AudioSpec &spec)
 Allocates delay lines and settles the parameter smoothing state.
 
void processBlock (AudioBufferView< T > buffer) noexcept
 Processes audio in-place, applying vibrato per channel.
 
void reset () noexcept
 Clears delay line memory and resets LFO phases.
 
void setRate (T hz) noexcept
 Sets the primary LFO rate. Parameter is smoothed internally.
 
void setDepth (T semitones) noexcept
 Sets the vibrato pitch depth. Parameter is smoothed internally.
 
void setModRate (T hz) noexcept
 Sets the rate of the secondary FM oscillator.
 
void setModDepth (T amount) noexcept
 Sets the intensity of the FM modulation on the primary LFO.
 
T getRate () const noexcept
 
T getDepth () const noexcept
 
T getModRate () const noexcept
 
T getModDepth () const noexcept
 
void setInterpolation (Interpolation mode) noexcept
 Selects the fractional read kernel. Thread-safe; a switch moves the sweep trough (see Interpolation), which the read-position slew turns into a glide of a few samples.
 
Interpolation getInterpolation () const noexcept
 Returns the fractional read kernel.
 
void setModel (Model m) noexcept
 Selects the engine (see Model). Thread-safe; the engines do not crossfade; out-of-range values are clamped.
 
Model getModel () const noexcept
 
void setAnalogNoise (T dbfs) noexcept
 Hiss of the analog line at the sweep's centre.
 
T getAnalogNoise () const noexcept
 
std::vector< uint8_t > getState () const
 Serializes the parameter state (setup/UI threads; allocates).
 
bool setState (const uint8_t *data, size_t size)
 Restores parameters from a blob (tolerant; rejects foreign ids).
 

Detailed Description

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

Professional-grade pitch vibrato with LFO FM and parameter smoothing.

The modulation depth is specified in semitones. A secondary oscillator (FM) can modulate the primary LFO rate. Internally applies block-based parameter smoothing to ensure artifact-free automation.

All per-channel LFOs share the same phase, so the effect stays mono-compatible. Channels beyond those passed to prepare() are left untouched (pass-through), as is the whole buffer before prepare().

Template Parameters
TSample type (float or double).

Definition at line 79 of file Vibrato.h.

Member Enumeration Documentation

◆ Interpolation

template<FloatType T>
enum class dspark::Vibrato::Interpolation
strong

Fractional read kernel of the modulated delay line.

Enumerator
Hermite 

4-point cubic (default).

Sinc 

32-tap Kaiser sinc: transparent to 15 kHz at 44.1/48 kHz, about 5x the read cost; the sweep trough sits 16 samples (0.33 ms at 48 kHz) behind the input instead of 4.

Definition at line 83 of file Vibrato.h.

◆ Model

template<FloatType T>
enum class dspark::Vibrato::Model
strong

The engine.

Enumerator
Digital 

Interpolated reads of a delay line (default).

Analog 

A bucket-brigade line per channel (see the file comment).

Definition at line 92 of file Vibrato.h.

Member Function Documentation

◆ getAnalogNoise()

template<FloatType T>
T dspark::Vibrato< T >::getAnalogNoise ( ) const
inlinenoexcept
Returns
The hiss level of the analog line in dBFS.

Definition at line 436 of file Vibrato.h.

◆ getDepth()

template<FloatType T>
T dspark::Vibrato< T >::getDepth ( ) const
inlinenoexcept

Definition at line 397 of file Vibrato.h.

◆ getInterpolation()

template<FloatType T>
Interpolation dspark::Vibrato< T >::getInterpolation ( ) const
inlinenoexcept

Returns the fractional read kernel.

Definition at line 411 of file Vibrato.h.

◆ getModDepth()

template<FloatType T>
T dspark::Vibrato< T >::getModDepth ( ) const
inlinenoexcept

Definition at line 399 of file Vibrato.h.

◆ getModel()

template<FloatType T>
Model dspark::Vibrato< T >::getModel ( ) const
inlinenoexcept
Returns
The engine.

Definition at line 423 of file Vibrato.h.

◆ getModRate()

template<FloatType T>
T dspark::Vibrato< T >::getModRate ( ) const
inlinenoexcept

Definition at line 398 of file Vibrato.h.

◆ getRate()

template<FloatType T>
T dspark::Vibrato< T >::getRate ( ) const
inlinenoexcept

Definition at line 396 of file Vibrato.h.

◆ getState()

template<FloatType T>
std::vector< uint8_t > dspark::Vibrato< T >::getState ( ) const
inline

Serializes the parameter state (setup/UI threads; allocates).

Definition at line 439 of file Vibrato.h.

◆ prepare()

template<FloatType T>
void dspark::Vibrato< T >::prepare ( const AudioSpec &  spec)
inline

Allocates delay lines and settles the parameter smoothing state.

The delay lines are sized for the deepest configuration the setters allow: 4 semitones at the 0.1 Hz rate floor. The peak delay request of that sweep is centre + deviation = 2 * deviation + offset (~35.4k samples at 48 kHz before the ring's power-of-two round-up), because the centre itself sits one deviation above the offset so the trough of the sweep never dips below it.

An invalid spec (non-positive or non-finite fields) is a no-op that keeps the previous state.

Parameters
specAudio environment specification. Defines num channels and sample rate.

Definition at line 113 of file Vibrato.h.

◆ processBlock()

template<FloatType T>
void dspark::Vibrato< T >::processBlock ( AudioBufferView< T >  buffer)
inlinenoexcept

Processes audio in-place, applying vibrato per channel.

Parameters
bufferAudio data (must match channels passed in prepare).

Definition at line 166 of file Vibrato.h.

◆ reset()

template<FloatType T>
void dspark::Vibrato< T >::reset ( )
inlinenoexcept

Clears delay line memory and resets LFO phases.

The smoothed parameter state is kept (no ramp is re-triggered).

Definition at line 325 of file Vibrato.h.

◆ setAnalogNoise()

template<FloatType T>
void dspark::Vibrato< T >::setAnalogNoise ( T  dbfs)
inlinenoexcept

Hiss of the analog line at the sweep's centre.

Parameters
dbfsRMS level in dBFS, clamped to [-140, -40]; -120 or less is silent. Non-finite values are ignored.

Definition at line 430 of file Vibrato.h.

◆ setDepth()

template<FloatType T>
void dspark::Vibrato< T >::setDepth ( T  semitones)
inlinenoexcept

Sets the vibrato pitch depth. Parameter is smoothed internally.

Parameters
semitonesModulation depth, clamped to [0, 4] semitones (the range the delay lines allocated in prepare() cover). Non-finite values are ignored.

Definition at line 357 of file Vibrato.h.

◆ setInterpolation()

template<FloatType T>
void dspark::Vibrato< T >::setInterpolation ( Interpolation  mode)
inlinenoexcept

Selects the fractional read kernel. Thread-safe; a switch moves the sweep trough (see Interpolation), which the read-position slew turns into a glide of a few samples.

Definition at line 404 of file Vibrato.h.

◆ setModDepth()

template<FloatType T>
void dspark::Vibrato< T >::setModDepth ( T  amount)
inlinenoexcept

Sets the intensity of the FM modulation on the primary LFO.

FM varies the speed of the vibrato LFO between (1 - amount) and (1 + amount) times the rate; the delay sweep keeps the width that depth and rate set, so the pitch excursion follows the instantaneous speed (up to twice the depth at full FM). Smoothed internally. While the depth is zero the FM oscillator holds its phase.

Parameters
amount0.0 (off) to 1.0 (full modulation), clamped. Non-finite values are ignored.

Definition at line 390 of file Vibrato.h.

◆ setModel()

template<FloatType T>
void dspark::Vibrato< T >::setModel ( Model  m)
inlinenoexcept

Selects the engine (see Model). Thread-safe; the engines do not crossfade; out-of-range values are clamped.

Definition at line 418 of file Vibrato.h.

◆ setModRate()

template<FloatType T>
void dspark::Vibrato< T >::setModRate ( T  hz)
inlinenoexcept

Sets the rate of the secondary FM oscillator.

Not smoothed by design: a rate change only alters the speed of the FM oscillator's continuous phase, which cannot produce a discontinuity.

Parameters
hzSecondary LFO rate in Hz (floored at 0). Set to 0 to disable FM. Non-finite values are ignored.

Definition at line 372 of file Vibrato.h.

◆ setRate()

template<FloatType T>
void dspark::Vibrato< T >::setRate ( T  hz)
inlinenoexcept

Sets the primary LFO rate. Parameter is smoothed internally.

Parameters
hzVibrato frequency in Hz (0.1 to 14 typical). Floored at 0.1 Hz, the minimum the delay-line sizing assumes; there is no upper clamp (higher rates shrink the deviation accordingly). Non-finite values are ignored.

Definition at line 345 of file Vibrato.h.

◆ setState()

template<FloatType T>
bool dspark::Vibrato< T >::setState ( const uint8_t *  data,
size_t  size 
)
inline

Restores parameters from a blob (tolerant; rejects foreign ids).

Definition at line 455 of file Vibrato.h.


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