DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
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 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.
 
getRate () const noexcept
 
getDepth () const noexcept
 
getModRate () const noexcept
 
getModDepth () 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 63 of file Vibrato.h.

Member Function Documentation

◆ getDepth()

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

Definition at line 304 of file Vibrato.h.

◆ getModDepth()

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

Definition at line 306 of file Vibrato.h.

◆ getModRate()

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

Definition at line 305 of file Vibrato.h.

◆ getRate()

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

Definition at line 303 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 309 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 81 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 126 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 236 of file Vibrato.h.

◆ setDepth()

template<FloatType T>
void dspark::Vibrato< T >::setDepth ( 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 265 of file Vibrato.h.

◆ setModDepth()

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

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

Smoothed internally: the FM depth scales the instantaneous rate (and with it the deviation and centre of the delay sweep), so an unsmoothed step would jump the read position audibly. 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 297 of file Vibrato.h.

◆ setModRate()

template<FloatType T>
void dspark::Vibrato< T >::setModRate ( 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 280 of file Vibrato.h.

◆ setRate()

template<FloatType T>
void dspark::Vibrato< T >::setRate ( 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 253 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 322 of file Vibrato.h.


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