Effects
Tone.js also has a bunch of stereo and mono effects.
To add an effect to your audio signal, simply connect the effect in between your source and destination. Here is an example which routes a Tone.Synth through a Tone.BitCrusher.
// create an effect and connect it to the destination (the speakers)
const bitCrusher = new Tone.BitCrusher(4).toDestination();
// create a synth and connect it to the effect
const synth = new Tone.Synth().connect(bitCrusher);
// and play a note to hear the effect
synth.triggerAttackRelease("C4", "8n");dry/wet
Section titled “dry/wet”All effects have a dry/wet control called wet which controls how much of the effected (“wet”) signal is output compared to the unaffected (“dry”) signal. The default value for most effects is 100% wet (1).
// 50/50 mixeffect.wet.value = 0.5;Async effects
Section titled “Async effects”Some effects (Tone.Reverb, for example) need to generate an impulse response before they produce sound. Reverb exposes a ready promise which resolves once it’s done:
const reverb = new Tone.Reverb(2).toDestination(); await reverb.ready;
Starting and stopping effects
Section titled “Starting and stopping effects”Effects that are modulated by an LFO, Tone.AutoFilter, Tone.AutoPanner, Tone.Chorus and Tone.Tremolo, need to be started with .start() before you will hear the modulation:
const tremolo = new Tone.Tremolo(9, 0.75).toDestination().start();
const synth = new Tone.Synth().connect(tremolo);
synth.triggerAttackRelease("C4", "2n");stop() stops the modulation, and both take an optional time, like sources. To keep the modulation in time with the Transport, see Syncing to the Transport.