LittleJS 1.30.0

AudioEffects

AudioEffect

Base class for audio effects, an input and output with a wet/dry mix between them

  • Sounds connect to input, output goes to the master gain until connect() moves it
  • Subclasses put their nodes between input and the wet gain with connectEffect

Extended by AudioCompressor, AudioDelay, AudioDistortion, AudioFilter, AudioReverb

Constructor

new AudioEffect(mix)audioEffects.js:23

Create an audio effect

mix number optional, default 1

Wet/dry balance, 0 is fully dry and 1 is fully wet

const cave = new AudioReverb(3, 2);
footstep.output = cave; // every play of this sound is in the cave

Members

Methods

Members

dryGain : GainNodeaudioEffects.js:41

Level of the unprocessed signal

input : GainNodeaudioEffects.js:36

Connect sounds to this node

mix : numberaudioEffects.js:32

Wet/dry balance, 0 is fully dry and 1 is fully wet

output : GainNodeaudioEffects.js:39

This node carries the mixed result, send it somewhere with connect(), never by assigning here

  • Unlike sound.output, which is where a sound's audio goes and can be set to an effect
wetGain : GainNodeaudioEffects.js:43

Level of the processed signal

Methods

connect(target) → TaudioEffects.js:87

Send this effect's output into another effect or audio node instead of the speakers

target T

The next effect in the chain, or any audio node

Returns
  • The target, so chains read left to right
connectEffect(first, last)audioEffects.js:106

Wire nodes between the input and the wet gain, for subclasses

first AudioNode

Node the input connects to

last AudioNode optional, default first

Node that connects to the wet gain

Stop sending this effect's output anywhere

rampParam(param, value, fadeTime)audioEffects.js:72

Ramp one of this effect's params, keeping the effect running until the ramp is done

  • The browser drops an effect from rendering while nothing plays through it, which would freeze a ramp partway, so a silent source feeds the input for the ramp's length
param AudioParam

The param to ramp

value number

Where to ramp to

fadeTime number optional, default 0

Seconds to ramp over, 0 sets the value at once

setMix(mix, fadeTime)audioEffects.js:56

Set the wet/dry balance

mix number

0 is fully dry and 1 is fully wet

fadeTime number optional, default 0

Seconds to ramp over so the change doesn't click