Signalsmith Audio's DSP Library  1.6.0
Useful C++ classes/templates for audio effects
Methods
signalsmith::envelopes::CubicLfo Class Reference

#include <envelopes.h>

Detailed Description

An LFO based on cubic segments.

You can randomise the rate and/or the depth. Randomising the depth past 0.5 means it no longer neatly alternates sides:

Some example LFO curves.

Without randomisation, it is approximately sine-like:

Methods

 CubicLfo (long seed)
 
void reset ()
 Resets the LFO state, starting with random phase. More...
 
void set (float low, float high, float rate, float rateVariation=0, float depthVariation=0)
 Smoothly updates the LFO parameters. More...
 
float next ()
 Returns the next output sample. More...
 

Method Details

◆ next()

float signalsmith::envelopes::CubicLfo::next ( )
inline

Returns the next output sample.

◆ reset()

void signalsmith::envelopes::CubicLfo::reset ( )
inline

Resets the LFO state, starting with random phase.

◆ set()

void signalsmith::envelopes::CubicLfo::set ( float  low,
float  high,
float  rate,
float  rateVariation = 0,
float  depthVariation = 0 
)
inline

Smoothly updates the LFO parameters.

If called directly after .reset(), oscillation will immediately start within the specified range. Otherwise, it will remain smooth and fit within the new range after at most one cycle:

The LFO will complete a full oscillation in (approximately) 1/rate samples. rateVariation can be any number, but 0-1 is a good range.

depthVariation must be in the range [0, 1], where ≤ 0.5 produces random amplitude but still alternates up/down.

Spectra for the two types of randomisation - note the jump as depth variation goes past 50%