Skip to content
Tone.js

CrossFade

class Component ↳ extends ToneAudioNode<CrossFadeOptions>

Tone.Crossfade provides equal power fading between two inputs. More on crossfading technique here.

+---------+
+> input a +>--+
+-----------+ +---------------------+ | | |
| 1s signal +>--> stereoPannerNode L +>----> gain | |
+-----------+ | | +---------+ |
+-> pan R +>-+ | +--------+
| +---------------------+ | +---> output +>
+------+ | | +---------+ | +--------+
| fade +>----+ | +> input b +>--+
+------+ | | |
+--> gain |
+---------+
const crossFade = new Tone.CrossFade().toDestination();
// connect two inputs Tone.to a/b
const inputA = new Tone.Oscillator(440, "square").connect(crossFade.a).start();
const inputB = new Tone.Oscillator(440, "sine").connect(crossFade.b).start();
// use the fade to control the mix between the two
crossFade.fade.value = 0.5;
new CrossFade(fade?: number)

Parameters

  • fade number optional

    The initial fade value [0, 1].

new CrossFade(options?: Partial<CrossFadeOptions>)

Parameters

read-only

a: Gain

The input which is at full level when fade = 0

read-only

b: Gain

The input which is at full level when fade = 1

read-only

fade: Signal<"normalRange">

The mix between the two inputs. A fade value of 0 will output 100% crossFade.a and a value of 1 will output 100% crossFade.b.

read-only

input: undefined

CrossFade has no input, you must choose either a or b

read-only

name: string

The name of the class

Default: "CrossFade"

read-only

output: Gain

The output is a mix between a and b at the ratio of fade

dispose(): this

Dispose and disconnect

Returns this

static

getDefaults(): CrossFadeOptions

Returns all of the default options belonging to the class.

Returns CrossFadeOptions