EZ Web Audio / createLFO
Function: createLFO()
createLFO(
options?):LFO
Defined in: packages/core/src/index.ts:949
Create a Low Frequency Oscillator (LFO) for modulating audio parameters.
An LFO produces a slow oscillation that can be connected to any audio parameter (gain, pan, frequency, filter cutoff, etc.) to create effects like tremolo, vibrato, auto-pan, and auto-filter.
The LFO does not require an AudioContext upfront — it infers the context from the first target connected via connect().
Parameters
options?
Optional LFO configuration (frequency, depth, waveform type)
Returns
LFO instance ready to connect to audio targets
Example
typescript
import { createLFO, createOscillator } from 'ez-web-audio'
// Tremolo: modulate gain at 5 Hz
const synth = await createOscillator({ frequency: 440 })
const tremolo = createLFO({ frequency: 5, depth: 0.3, type: 'sine' })
tremolo.connect(synth, 'gain')
tremolo.start()
synth.play()
// Vibrato: modulate frequency in cents
const vibrato = createLFO({ frequency: 6, depth: 50, type: 'sine' })
vibrato.connect(synth, 'frequency') // depth=50 cents by default for frequency
vibrato.start()
// Auto-pan: modulate pan position
const autoPan = createLFO({ frequency: 0.5, depth: 0.8, type: 'triangle' })
autoPan.connect(synth, 'pan')
autoPan.start()
// BPM sync: set LFO rate to match quarter notes at 120 BPM
tremolo.syncToBPM(120, '1/4') // sets frequency to 2 Hz