3.1.0 • Published 9 years ago

lfo v3.1.0

Weekly downloads
3
License
ISC
Repository
github
Last release
9 years ago

lfo

Low frequency oscillator for automating Web Audio API AudioParams.

Install

$ npm install lfo

API

var LFO = require('lfo')

LFO(audioContext)

Returns an LFO AudioNode instance.

node.value (AudioParam)

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 = require('lfo')

var audioContext = new AudioContext()
var oscillator = audioContext.createOscillator()
var gain = audioContext.createGain()

oscillator.connect(gain)
gain.connect(audioContext.destination)

var lfoModulator = LFO(audioContext)
gain.value = 2 // set oscillation centre value

lfoModulator.rate = 4 // hz
lfoModulator.shape = 'sine'
lfoModulator.connect(gain.gain)

lfoModulator.start(audioContext.currentTime)
oscillator.start(audioContext.currentTime)

lfoModulator.stop(audioContext.currentTime + 1)
oscillator.stop(audioContext.currentTime + 1)
3.1.0

9 years ago

3.0.0

9 years ago

2.0.0

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.2.0

10 years ago

0.1.0

10 years ago

0.0.1

10 years ago