Effects Chain
Press Play to hear a four-note plucked pattern. Bypass the delay to hear which notes are echoes, then try the sustained oscillator or looping audio file through the same chain.
Build, reorder, and hear an effects chain.
How It Works
The pattern uses a gain node to open and close each pluck before it reaches the first effect. The delay can repeat a note after the pluck ends, and the reverb can ring into the next step.
Source → Effect 1 → Effect 2 → Effect 3 → Effect 4 → OutputThe library connects effects in the order you add them. Put the compressor before the reverb to compress the incoming notes, or after it to compress the notes and their reflections together.
Building a Chain
Call startChain() from a Play button’s click handler. Keep the returned source and effects for the bypass, reorder and cleanup operations below.
import {
createCompressor,
createDelay,
createEQ,
createOscillator,
createReverb,
} from 'ez-web-audio'
export async function startChain() {
const source = await createOscillator({ frequency: 440, type: 'sawtooth', gain: 0.12 })
const delay = createDelay({ time: 0.3, feedback: 0.4, mix: 0.3 })
const reverb = createReverb({ decay: 2.5, mix: 0.35 })
const compressor = createCompressor({ threshold: -24, ratio: 4 })
const eq = createEQ({ low: 0, mid: 0, high: 2 })
// Effects are connected in array order
source.addEffects([delay, reverb, compressor, eq])
await source.play()
return { source, delay, reverb, compressor, eq }
}Bypassing an Effect
delay.bypass = true // Dry signal passes through unaffected
delay.bypass = false // Effect re-enters the signal chainReordering Effects
To move one effect, remove it and insert it at its new index.
// The delay stays first, followed by compressor, reverb and EQ.
source.removeEffect(compressor)
source.addEffect(compressor, 1)Cleanup
source.dispose() // Stops playback and disposes the effects attached to the sourceEffect Parameters
| Effect | Key Parameters | Notes |
|---|---|---|
| Delay | time (0.05–1s), feedback (0–0.9), mix (0-1) | Higher feedback = longer echo tail |
| Reverb | decay (seconds), damping (0–1), mix (0–1) | Simulates room reflections |
| Compressor | threshold (dBFS), ratio (N:1) | Reduces dynamic range |
| EQ | low, mid, high (dB gain) | Three-band shelving/peak EQ |
Further Reading
- LFO — One Knob, Three Effects -- add tremolo or filter sweep to a signal in the chain
- Audio Routing -- custom routing beyond the linear chain
- Effects -- individual effect deep-dives