Tone.js Filter Real-Time Modulatable Parameters

This article provides a quick overview of the specific parameters within the Tone.Filter class in Tone.js that can be modulated in real-time. By understanding these parameters—namely frequency, Q, gain, and detune—you can leverage LFOs, envelopes, and scheduling methods to create dynamic, evolving soundscapes and classic synthesizer effects in the browser.

In Tone.js, real-time modulatable parameters are represented as Tone.Signal objects. This allows them to be scheduled with precision or connected directly to other audio-rate sources (such as an LFO or an envelope) for automatic modulation.

The following four parameters on a Tone.Filter can be modulated in real-time:

1. Frequency (filter.frequency)

The frequency parameter represents the cutoff frequency for lowpass and highpass filters, or the center frequency for bandpass, notch, peaking, and shelving filters. Modulating this parameter is the primary way to create classic filter sweeps, “wah-wah” effects, and dynamic timbral transitions. Because it is a Tone.Signal, you can smoothly ramp its value over time using methods like rampTo() or connect an LFO to automate the sweep.

2. Q-Factor (filter.Q)

The Q parameter controls the quality factor or resonance of the filter. In lowpass and highpass filters, higher Q values create a sharp peak at the cutoff frequency, making the sound more resonant or “buzzy.” In bandpass and notch filters, Q determines the width of the frequency band. Modulating the Q-factor in real-time allows you to dynamically shift from a subtle, smooth filter to a highly resonant, whistling sound.

3. Gain (filter.gain)

The gain parameter controls the boost or attenuation applied to the target frequencies. This parameter is only active and functional when using specific filter types, such as peaking, lowshelf, and highshelf. Modulating the gain in real-time allows you to create dynamic equalization effects, such as a pulsating bass boost or an automated treble swell.

4. Detune (filter.detune)

The detune parameter modulates the filter’s cutoff or center frequency in cents (where 100 cents equal one semitone). Modulating detune is highly useful for introducing subtle pitch-based vibrato to the filter itself, or for offsetting the filter’s frequency precisely relative to an incoming MIDI note frequency.

How to Modulate a Filter Parameter

To modulate any of these parameters in real-time, you can connect an LFO directly to the parameter. For example, to modulate the filter’s cutoff frequency with an LFO:

const filter = new Tone.Filter(1000, "lowpass").toDestination();
const lfo = new Tone.LFO("2hz", 400, 2000).start();

// Connect the LFO to modulate the filter frequency in real-time
lfo.connect(filter.frequency);

By connecting modulation sources to frequency, Q, gain, or detune, you can create highly interactive and responsive audio environments.