Gin
Loading...
Searching...
No Matches
LFO Class Reference

Low-Frequency Oscillator with 18 waveform shapes and modulation features. More...

#include <gin_lfo.h>

Classes

struct  Parameters

Public Types

enum class  WaveShape : int {
  none , sine , triangle , sawUp ,
  sawDown , square , squarePos , sampleAndHold ,
  noise , stepUp3 , stepUp4 , stepup8 ,
  stepDown3 , stepDown4 , stepDown8 , pyramid3 ,
  pyramid5 , pyramid9
}

Public Member Functions

 LFO ()
void setSampleRate (double sr)
void setParameters (Parameters p)
void reset ()
void noteOn (float phase_=-1.0f)
float process (int numSamples)
float getOutput ()
float getOutputUnclamped ()
float getCurrentPhase ()

Static Public Attributes

static constexpr int maxRandomPhase = 1000

Detailed Description

Low-Frequency Oscillator with 18 waveform shapes and modulation features.

LFO provides a versatile modulation source with many waveforms, phase control, fade-in, delay, and depth/offset parameters. It supports both smooth waveforms (sine, triangle) and stepped waveforms (sample-and-hold, pyramids, steps).

Key Features:

  • 18 waveform shapes including classic and exotic types
  • Phase offset control
  • Delay before LFO starts
  • Fade-in over time
  • Depth and offset controls
  • Note-on retriggering with optional phase
  • Sample-and-hold with interpolated noise

Waveform Types:

  • Classic: sine, triangle, sawUp, sawDown, square
  • Random: sampleAndHold (stepped), noise (interpolated)
  • Stepped: stepUp/Down (3/4/8 steps)
  • Pyramids: pyramid3/5/9 (symmetrical steps)
  • Positive: squarePos (0 to 1 instead of -1 to 1)

Parameters:

  • waveShape: Which waveform to use
  • frequency: LFO rate in Hz
  • phase: Phase offset (0 to 1)
  • depth: Output scaling
  • offset: DC offset added to output
  • delay: Time before LFO starts (seconds)
  • fade: Fade-in time (seconds)

Usage:

LFO lfo;
lfo.setSampleRate(44100.0);
params.frequency = 2.0f; // 2 Hz
params.phase = 0.0f;
params.depth = 1.0f;
params.offset = 0.0f;
params.delay = 0.0f;
params.fade = 0.1f; // 100ms fade-in
lfo.setParameters(params);
lfo.noteOn();
float modValue = lfo.process(blockSize);
float output = lfo.getOutput(); // Clamped to -1..1
float getOutput()
Definition gin_lfo.h:206
@ sine
Definition gin_lfo.h:79
void noteOn(float phase_=-1.0f)
Definition gin_lfo.h:141
void setParameters(Parameters p)
Definition gin_lfo.h:118
void setSampleRate(double sr)
Definition gin_lfo.h:117
LFO()
Definition gin_lfo.h:108
float process(int numSamples)
Definition gin_lfo.h:170
Definition gin_lfo.h:102
float fade
Definition gin_lfo.h:104
WaveShape waveShape
Definition gin_lfo.h:103
float frequency
Definition gin_lfo.h:104
float delay
Definition gin_lfo.h:104
float phase
Definition gin_lfo.h:104
float offset
Definition gin_lfo.h:104
float depth
Definition gin_lfo.h:104
See also
StepLFO, MSEG

Member Enumeration Documentation

◆ WaveShape

enum class LFO::WaveShape : int
strong
Enumerator
none 
sine 
triangle 
sawUp 
sawDown 
square 
squarePos 
sampleAndHold 
noise 
stepUp3 
stepUp4 
stepup8 
stepDown3 
stepDown4 
stepDown8 
pyramid3 
pyramid5 
pyramid9 

Constructor & Destructor Documentation

◆ LFO()

LFO::LFO ( )

References maxRandomPhase.

Member Function Documentation

◆ setSampleRate()

void LFO::setSampleRate ( double sr)

◆ setParameters()

void LFO::setParameters ( Parameters p)

References maxRandomPhase, noise, and sampleAndHold.

◆ reset()

void LFO::reset ( )

◆ noteOn()

void LFO::noteOn ( float phase_ = -1.0f)

References maxRandomPhase, noise, and sampleAndHold.

◆ process()

float LFO::process ( int numSamples)

References maxRandomPhase, noise, and sampleAndHold.

◆ getOutput()

float LFO::getOutput ( )

◆ getOutputUnclamped()

float LFO::getOutputUnclamped ( )

◆ getCurrentPhase()

float LFO::getCurrentPhase ( )

Member Data Documentation

◆ maxRandomPhase

int LFO::maxRandomPhase = 1000
staticconstexpr

Referenced by LFO(), noteOn(), process(), and setParameters().


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