What is the Wet Parameter in Tone.js Effects?

In web audio development using Tone.js, the “wet” parameter is a fundamental control found on almost all effect nodes, such as reverbs, delays, choruses, and phasers. This article explains how the wet parameter functions, how it controls the balance between processed and unprocessed audio signals, and how to implement and automate it within your digital audio projects.

Understanding Dry vs. Wet Audio

To understand the wet parameter, you must first understand the concept of “dry” and “wet” audio signals: * Dry Signal: The original, unaffected input audio (e.g., a clean synthesizer note or a raw vocal sample). * Wet Signal: The audio after it has been processed by the effect (e.g., the sound with reverb or delay applied).

The wet parameter in Tone.js determines the mix ratio between these two signals at the output of the effect node.

How the Wet Parameter Works

The wet parameter accepts a value of type NormalRange, which is a floating-point number between 0 and 1.

Code Implementation in Tone.js

In Tone.js, the wet parameter is not just a simple number; it is a Tone.Signal object. This means you must access and modify its value using the .value property.

Here is a basic example of how to instantiate an effect and adjust its wet parameter:

// Create a Feedback Delay effect
const delay = new Tone.FeedbackDelay("8n", 0.5).toDestination();

// Set the wet parameter to 30% wet, 70% dry
delay.wet.value = 0.3;

// Connect a synthesizer to the delay
const synth = new Tone.Synth().connect(delay);
synth.triggerAttackRelease("C4", "8n");

Automating the Wet Parameter

Because the wet parameter is a Tone.Signal, you can schedule changes to it over time. This is highly useful for creating dynamic transitions, such as slowly washing out a sound with reverb at the end of a musical phrase.

You can use standard Tone.js signal automation methods like linearRampToValueAtTime or rampTo:

// Smoothly ramp the wet mix to 100% over 4 seconds
delay.wet.rampTo(1, 4);