ToneAudioNode
class Core ↳ extends ToneWithContext<Options>
ToneAudioNode is the base class for classes which process audio.
Properties
Section titled “Properties”input: InputNode | undefinedThe input node or nodes. If the object is a source, it does not have any input and this.input is undefined.
output
Section titled “output”output: OutputNode | undefinedThe output nodes. If the object is a sink, it does not have any output and this.output is undefined.
channelCount
Section titled “channelCount”channelCount: numberchannelCount 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
Section titled “channelCountMode”channelCountMode: ChannelCountModechannelCountMode 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
Section titled “channelInterpretation”channelInterpretation: ChannelInterpretationchannelInterpretation 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”.
numberOfInputs
Section titled “numberOfInputs”read-only
numberOfInputs: numberThe number of inputs feeding into the AudioNode. For source nodes, this will be 0.
const node = new Tone.Gain(); console.log(node.numberOfInputs);
numberOfOutputs
Section titled “numberOfOutputs”read-only
numberOfOutputs: numberThe number of outputs of the AudioNode.
const node = new Tone.Gain(); console.log(node.numberOfOutputs);
Methods
Section titled “Methods”chain()
Section titled “chain()”chain(...nodes: InputNode[]): thisConnect 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
- nodes
InputNode[]
Returns this
connect()
Section titled “connect()”connect(destination: InputNode, outputNum?: number, inputNum?: number): thisconnect the output of a ToneAudioNode to an AudioParam, AudioNode, or ToneAudioNode
Parameters
-
destination
InputNodeThe output to connect to
-
outputNum
numberoptional default0The output to connect from
-
inputNum
numberoptional default0The input to connect to
Returns this
disconnect()
Section titled “disconnect()”disconnect(destination?: InputNode, outputNum?: number, inputNum?: number): thisdisconnect the output
Parameters
- destination
InputNodeoptional - outputNum
numberoptional default0 - inputNum
numberoptional default0
Returns this
fan(...nodes: InputNode[]): thisconnect 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
- nodes
InputNode[]
Returns this
toDestination()
Section titled “toDestination()”toDestination(): thisConnect the output to the context’s destination node.
const osc = new Tone.Oscillator("C2").start();
osc.toDestination();Returns this
toMaster()
Section titled “toMaster()”toMaster(): thisConnect the output to the context’s destination node.
See also: toDestination
Returns this
Inherited members
Section titled “Inherited members”- From
ToneWithContext: constructor, context, blockTime, sampleTime, get(), immediate(), now(), set(), toFrequency(), toSeconds(), toTicks(), getDefaults() - From
Tone: debug, version, disposed, toString()