DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
Loading...
Searching...
No Matches
dspark::Tremolo< T > Class Template Reference

LFO-driven amplitude modulation with stereo auto-pan option. More...

#include <Tremolo.h>

Public Types

enum class  Shape { Sine , Triangle , Square }
 

Public Member Functions

void prepare (const AudioSpec &spec)
 Prepares the tremolo processor and allocates internal states.
 
void processBlock (AudioBufferView< T > buffer) noexcept
 Processes an audio block in-place with SIMD-friendly dispatch.
 
void reset () noexcept
 Hard-resets the internal LFO phase to zero.
 
void setRate (T hz) noexcept
 Sets the LFO rate. Thread-safe (can be called from UI thread).
 
void setDepth (T depth) noexcept
 Sets the modulation depth. Thread-safe.
 
void setShape (Shape shape) noexcept
 Sets the LFO waveform shape. Thread-safe.
 
void setStereo (bool enabled) noexcept
 Enables auto-pan by offsetting the right channel LFO phase by 180 degrees.
 
getRate () const noexcept
 
getDepth () const noexcept
 
Shape getShape () const noexcept
 
bool isStereo () 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::Tremolo< T >

LFO-driven amplitude modulation with stereo auto-pan option.

Designed with a template-dispatch architecture to ensure zero branching inside the inner audio loops, maximizing L1 cache hits and SIMD autovectorization.

Template Parameters
TSample type (float or double).

Definition at line 52 of file Tremolo.h.

Member Enumeration Documentation

◆ Shape

template<FloatType T>
enum class dspark::Tremolo::Shape
strong
Enumerator
Sine 

Classic smooth tremolo (opto-isolator style)

Triangle 

Linear modulation, sharper peaks.

Square 

Slew-rate limited gating effect (analog-style, click-free)

Definition at line 55 of file Tremolo.h.

Member Function Documentation

◆ getDepth()

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

Definition at line 174 of file Tremolo.h.

◆ getRate()

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

Definition at line 173 of file Tremolo.h.

◆ getShape()

template<FloatType T>
Shape dspark::Tremolo< T >::getShape ( ) const
inlinenoexcept

Definition at line 175 of file Tremolo.h.

◆ getState()

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

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

Definition at line 180 of file Tremolo.h.

◆ isStereo()

template<FloatType T>
bool dspark::Tremolo< T >::isStereo ( ) const
inlinenoexcept

Definition at line 176 of file Tremolo.h.

◆ prepare()

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

Prepares the tremolo processor and allocates internal states.

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

Parameters
specAudio environment specification (sample rate and max channels).

Definition at line 70 of file Tremolo.h.

◆ processBlock()

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

Processes an audio block in-place with SIMD-friendly dispatch.

Parameters
bufferAudio buffer view to modulate.

Definition at line 98 of file Tremolo.h.

◆ reset()

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

Hard-resets the internal LFO phase to zero.

Note
Will cause an audible click if called while audio is actively passing.

Definition at line 126 of file Tremolo.h.

◆ setDepth()

template<FloatType T>
void dspark::Tremolo< T >::setDepth ( depth)
inlinenoexcept

Sets the modulation depth. Thread-safe.

Parameters
depthRange [0.0 (bypass), 1.0 (full amplitude cut)]. Non-finite values are ignored.

Definition at line 150 of file Tremolo.h.

◆ setRate()

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

Sets the LFO rate. Thread-safe (can be called from UI thread).

Parameters
hzModulation frequency in Hz (floored to 0; audio-rate AM is legitimate). Non-finite values are ignored.

Definition at line 139 of file Tremolo.h.

◆ setShape()

template<FloatType T>
void dspark::Tremolo< T >::setShape ( Shape  shape)
inlinenoexcept

Sets the LFO waveform shape. Thread-safe.

Parameters
shapeWaveform type (Sine, Triangle, Square; wild enum values clamp).

Definition at line 160 of file Tremolo.h.

◆ setState()

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

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

Definition at line 191 of file Tremolo.h.

◆ setStereo()

template<FloatType T>
void dspark::Tremolo< T >::setStereo ( bool  enabled)
inlinenoexcept

Enables auto-pan by offsetting the right channel LFO phase by 180 degrees.

Parameters
enabledTrue for stereo mode, false for synchronized mono modulation.

Definition at line 171 of file Tremolo.h.


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