SoundFontInfoLib  2.21.6
Library for parsing and rendering SF2 files
SF2::Render::LFO Class Reference

Implementation of a low-frequency triangular oscillator. More...

#include <LFO.hpp>

Classes

struct  Config
 Configures an LFO via a "fluent" interface. More...
 
struct  State
 

Public Member Functions

 LFO (Float sampleRate, Float frequency, Float delay)
 Create a new instance. More...
 
void initialize (Float sampleRate, Float frequency, Float delay)
 Initialize the LFO with the given parameters. More...
 
void setFrequency (Float frequency)
 Set the frequency of the oscillator. More...
 
void setDelay (Float delay)
 Set the delay of the oscillator in seconds. More...
 
void reset ()
 Restart from a known zero state. More...
 
State saveState () const
 Save the state of the oscillator. More...
 
void restoreState (const State &state)
 Restore the oscillator to a previously-saved state. More...
 
void increment ()
 Increment the oscillator to the next value. More...
 
Float valueAndIncrement ()
 Obtain the next value of the oscillator. More...
 
Float value ()
 Obtain the current value of the oscillator. More...
 

Detailed Description

Implementation of a low-frequency triangular oscillator.

By design, this LFO emits bipolar values from -1.0 to 1.0 in order to be useful in SF2 processing. One can obtain unipolar values via the DSP::bipolarToUnipolar method. An LFO will start emitting with value 0.0, again by design, in order to smoothly transition from a paused LFO into a running one.

Constructor & Destructor Documentation

◆ LFO()

SF2::Render::LFO::LFO ( Float  sampleRate,
Float  frequency,
Float  delay 
)
inline

Create a new instance.

Parameters
sampleRatenumber of samples per second
frequencythe frequency of the oscillator
delaythe number of seconds to wait before starting the LFO.

References initialize().

Referenced by SF2::Render::LFO::Config::make().

Member Function Documentation

◆ increment()

void SF2::Render::LFO::increment ( )
inline

Increment the oscillator to the next value.

Referenced by valueAndIncrement().

◆ initialize()

void SF2::Render::LFO::initialize ( Float  sampleRate,
Float  frequency,
Float  delay 
)
inline

Initialize the LFO with the given parameters.

Parameters
sampleRatenumber of samples per second
frequencythe frequency of the oscillator
delaythe number of seconds to wait before starting the LFO.

References reset().

Referenced by LFO().

◆ reset()

void SF2::Render::LFO::reset ( )
inline

Restart from a known zero state.

Referenced by initialize(), and setDelay().

◆ restoreState()

void SF2::Render::LFO::restoreState ( const State state)
inline

Restore the oscillator to a previously-saved state.

Parameters
statethe state to restore to

References SF2::Render::LFO::State::counter_, and SF2::Render::LFO::State::delaySampleCount_.

◆ saveState()

State SF2::Render::LFO::saveState ( ) const
inline

Save the state of the oscillator.

Returns
current internal state

◆ setDelay()

void SF2::Render::LFO::setDelay ( Float  delay)
inline

Set the delay of the oscillator in seconds.

NOTE: resets the counter.

Parameters
delaythe number of seconds to wait before starting the LFO.

References reset().

◆ setFrequency()

void SF2::Render::LFO::setFrequency ( Float  frequency)
inline

Set the frequency of the oscillator.

NOTE: it does not reset the counter.

Parameters
frequencythe frequency to operate at

◆ value()

Float SF2::Render::LFO::value ( )
inline

Obtain the current value of the oscillator.

Returns
current waveform value

◆ valueAndIncrement()

Float SF2::Render::LFO::valueAndIncrement ( )
inline

Obtain the next value of the oscillator.

Advances counter before returning, so this is not idempotent.

Returns
current waveform value

References increment().

Referenced by SF2::Render::Voice::Voice::render().


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