class: mSineLFO
efficient floating point sine LFO
Description
Efficiently generates a bipolar sinusoids.
Only guaranteed to be stable at low frequencies so it is intended to be used as an LFO; at high frequencies there may be slight deviations in amplitude between different frequencies. Peak amplitude can be set to any floating point value, however it should not be changed on the fly. Oscillator design has the side effect of generating a quadrature (with a phase offset of 90 degrees or a quarter cycle) sine wave which can be used at no additional performance cost. Design is the Second Modified Coupled-Form Oscillator outlined in Jon Dattoro - Effect Design Part 3 Oscillators: Sinusoidal and Pseudonoise
Template Parameters
template <uint32_t UPDATE_RATE>UPDATE_RATE: how often the .next() function will be called. Defaults to CONTROL_RATE
Class Methods
Constructor
mSineLFO(float freq, float peak_amplitude = 1.0)freq: frequency (in Hz) of oscillator
peak_amplitude: peak amplitude of oscillator. Oscillator is centered around zero so will oscillate between -peak_amplitude and peak_amplitude
void setFreq(float freq)sets frequency of oscillator
float quadratureOutput()After calling .next(), you can retrieve the output from the second LFO, which is in quadrature with the main one.
float next()Calculates oscillators and returns output from first LFO. Should be called at rate specified by UPDATE_RATE
Example
// global declaration
mSineLFO<CONTROL_RATE> my_lfo(1.5, 500);
// in updateControl
my_osc.setFreq(my_lfo.next() + 200); // use lfo to set frequency of some other oscillator between 200Hz and 700Hz