lfo
Low frequency oscillator for automating Web Audio API AudioParams.
Install
$ npm install lfo
API
var LFO =
LFO(audioContext)
Returns an LFO AudioNode instance.
AudioParam)
node.value (Modulate this base value
based on operation specified by node.mode
.
node.rate (AudioParam)
Oscillation rate in cycles per second (Hz).
node.amp (AudioParam)
Amplitude of the oscillation.
node.mode (get/set)
The operation to apply to node.value
. Defaults to `'multiply'.
node.shape (get/set)
The waveform shape: 'sine', 'triangle', 'sawtooth', 'sawtooth_i' or 'square'
node.phaseOffset (get/set)
node.sync (get/set)
When true
, the oscillation rate is multiplied by node.tempo / 60
to allow beat sync.
node.tempo (get/set)
Set the tempo (BPM) for use when node.sync
is true
.
node.connect(destinationAudioParam)
Connect the modulator to the desired destination audio param.
node.disconnect()
Disconnect from any target AudioParams.
node.start(at)
Starts the LFO at specified time. This method can only be called once. Create new instances of LFO for each scheduled events.
node.stop(at)
Stops the LFO at specified time.
Example
Create tremolo effect
var LFO = var audioContext = var oscillator = audioContextvar gain = audioContext oscillatorgain var lfoModulator = gainvalue = 2 // set oscillation centre value lfoModulatorrate = 4 // hzlfoModulatorshape = 'sine'lfoModulator lfoModulatorstartaudioContextcurrentTimeoscillatorstartaudioContextcurrentTime lfoModulatoroscillator