Baxandall tone control — bass/treble shelving with reciprocal characteristics
Listen
// "Local Forecast" by Kevin MacLeod (incompetech.com), CC BY 4.0, incompetech.com/music/royalty-free/faq.html
audio('/samples/music/modern/local-forecast.mp3').baxandall()
// "Local Forecast" by Kevin MacLeod (incompetech.com), CC BY 4.0, incompetech.com/music/royalty-free/faq.html
Parameters
bass- 0 dB
- −15 to 15 dB
treble- 0 dB
- −15 to 15 dB
fBass- 250 Hz
- 60 to 1000 Hz
fTreble- 4000 Hz
- 1000 to 12000 Hz
import baxandall from '@audio/eq-baxandall'
The canonical two-knob tone control found in amplifiers, mixers, and guitar pedals — a low-shelf at fBass and a high-shelf at fTreble (both fixed Q 0.707), cascaded. Each shelf tracks its own frequency/gain/fs independently, so bass and treble move without disturbing each other.
let params = { bass: 3, treble: -2, fs: 44100 }
for (let buf of stream) baxandall(buf, params)
| Param | Default | |
|---|---|---|
bass |
0 |
Bass shelf gain, dB (positive boosts, negative cuts) |
treble |
0 |
Treble shelf gain, dB (positive boosts, negative cuts) |
fBass |
250 |
Bass shelf corner frequency, Hz |
fTreble |
4000 |
Treble shelf corner frequency, Hz |
fs |
44100 |
Sample rate, Hz |
Pass the same params object across successive calls — both shelves' coefficients and filter memory are cached on it and only rebuilt when their own gain/frequency/fs change, so state carries across block boundaries automatically.
The /audio processor holds fBass and fTreble at 0.49 of the sample rate: past Nyquist a shelf has poles outside the unit circle, and every /audio processor of @audio/filter and @audio/eq keeps this one rule. bass and treble are each smoothed (20 ms) and glided sample by sample: a host's ramp of it is one line, the same however the host cuts its calls (it hands each call the value at its first frame, so the line is played 32 frames late); held, it is the value itself: while one moves, its shelf is designed for each frame's gain. fBass and fTreble are smoothed (20 ms): a host ramps them, the shelves retuned at each call's values. The shelves are written by @audio/biquad's arithmetic in the processor itself, so a block allocates nothing whichever @audio/biquad is installed.
Use when: a simple two-knob tone stack — mixer channel strip, guitar amp voicing, quick "warmer/brighter" macro control.
Part of @audio/eq — the eq family umbrella.
MIT © audiojs