Audio filters
Apply named presets or raw FFmpeg filtergraphs to a queue.
queue.node.filters changes the sound of the current session. It accepts named presets and raw FFmpeg filtergraphs.
const filters = queue.node.filters;
await filters.set(['bassboost', 'nightcore']); // Replace all filters
await filters.toggle('8d'); // Turn one preset on or off
await filters.remove('nightcore');
await filters.clear();
console.log(filters.enabled); // ['bassboost', '8d']
console.log(filters.graph); // The combined FFmpeg graph, or nullMethods
| Method | Description |
|---|---|
set(nameOrNames) | Replace the active filters with one or more presets |
toggle(name, enabled?) | Turn a preset on or off. Returns the new state |
remove(nameOrNames) | Remove presets |
get(name) | true if the preset is enabled |
get() | The combined filtergraph, or null |
setRaw(graph) | Replace everything with a raw FFmpeg filtergraph |
clear() | Remove all filters |
Presets
The built-in presets include 8d, bassboost, bassboost_low, bassboost_high, nightcore, vaporwave, lofi, karaoke, mono, reverse, treble, chorus, flanger, and phaser. The complete list is in the preset source.
Raw filtergraphs
await queue.node.filters.setRaw('aecho=0.8:0.9:1000:0.3');A raw graph is opaque. toggle() and remove() only work with presets, and they do not parse a raw graph. Call setRaw() again or clear() to change it.
Filtergraphs are trusted input because FFmpeg filters can reach external resources. Do not pass user-provided text to setRaw().
Before and after connecting
You can set filters before the queue connects. They apply when the session starts.
On a connected session, an invalid graph rejects and the previous filters stay active.
Filters can change timing
Filters that change speed or pitch, such as nightcore and vaporwave, change how fast playbackTime advances. Use
queue.node.getTimestamp() for progress displays instead of your own timer.
Continue reading
Crossfade between tracks