Skip to content
Tone.js

ToneAudioNode

class Core ↳ extends ToneWithContext<Options>

ToneAudioNode is the base class for classes which process audio.

input: InputNode | undefined

The input node or nodes. If the object is a source, it does not have any input and this.input is undefined.

read-only

name: string

The name of the class

output: OutputNode | undefined

The output nodes. If the object is a sink, it does not have any output and this.output is undefined.

channelCount: number

channelCount is the number of channels used when up-mixing and down-mixing connections to any inputs to the node. The default value is 2 except for specific nodes where its value is specially determined.

channelCountMode: ChannelCountMode

channelCountMode determines how channels will be counted when up-mixing and down-mixing connections to any inputs to the node. The default value is “max”. This attribute has no effect for nodes with no inputs.

  • “max” - computedNumberOfChannels is the maximum of the number of channels of all connections to an input. In this mode channelCount is ignored.
  • “clamped-max” - computedNumberOfChannels is determined as for “max” and then clamped to a maximum value of the given channelCount.
  • “explicit” - computedNumberOfChannels is the exact value as specified by the channelCount.
channelInterpretation: ChannelInterpretation

channelInterpretation determines how individual channels will be treated when up-mixing and down-mixing connections to any inputs to the node. The default value is “speakers”.

read-only

numberOfInputs: number

The number of inputs feeding into the AudioNode. For source nodes, this will be 0.

const node = new Tone.Gain();
console.log(node.numberOfInputs);

read-only

numberOfOutputs: number

The number of outputs of the AudioNode.

const node = new Tone.Gain();
console.log(node.numberOfOutputs);
chain(...nodes: InputNode[]): this

Connect the output of this node to the rest of the nodes in series.

const player = new Tone.Player("https://tonejs.github.io/audio/drum-samples/handdrum-loop.mp3");
player.autostart = true;
const filter = new Tone.AutoFilter(4).start();
const distortion = new Tone.Distortion(0.5);
// connect the player to the filter, distortion and then to the master output
player.chain(filter, distortion, Tone.Destination);

Parameters

Returns this

connect(destination: InputNode, outputNum?: number, inputNum?: number): this

connect the output of a ToneAudioNode to an AudioParam, AudioNode, or ToneAudioNode

Parameters

  • destination InputNode

    The output to connect to

  • outputNum number optional default 0

    The output to connect from

  • inputNum number optional default 0

    The input to connect to

Returns this

disconnect(destination?: InputNode, outputNum?: number, inputNum?: number): this

disconnect the output

Parameters

  • destination InputNode optional
  • outputNum number optional default 0
  • inputNum number optional default 0

Returns this

dispose(): this

Dispose and disconnect

Returns this

fan(...nodes: InputNode[]): this

connect the output of this node to the rest of the nodes in parallel.

const player = new Tone.Player("https://tonejs.github.io/audio/drum-samples/conga-rhythm.mp3");
player.autostart = true;
const pitchShift = new Tone.PitchShift(4).toDestination();
const filter = new Tone.Filter("G5").toDestination();
// connect a node to the pitch shift and filter in parallel
player.fan(pitchShift, filter);

Parameters

Returns this

toDestination(): this

Connect the output to the context’s destination node.

const osc = new Tone.Oscillator("C2").start();
osc.toDestination();

Returns this

toMaster(): this

Connect the output to the context’s destination node.

See also: toDestination

Returns this