Tone.js
    Preparing search index...

    Interface DestinationInstance

    A single master output that is connected to the AudioDestinationNode (i.e. your speakers).

    It provides useful conveniences, such as the ability to set the volume and mute the entire application.

    It also gives you the ability to apply master effects to your application.

    const oscillator = new Tone.Oscillator().start();
    // The audio will go from the oscillator to the speakers.
    oscillator.connect(Tone.getDestination());
    // A convenience for connecting to the master output is also provided:
    oscillator.toDestination();
    interface DestinationInstance {
        context: BaseContext;
        debug: boolean;
        input: Volume;
        name: string;
        output: Gain;
        volume: Param<"decibels">;
        get blockTime(): number;
        get channelCount(): number;
        set channelCount(channelCount: number): void;
        get channelCountMode(): ChannelCountMode;
        set channelCountMode(channelCountMode: ChannelCountMode): void;
        get channelInterpretation(): ChannelInterpretation;
        set channelInterpretation(
            channelInterpretation: ChannelInterpretation,
        ): void;
        get disposed(): boolean;
        get maxChannelCount(): number;
        get mute(): boolean;
        set mute(mute: boolean): void;
        get numberOfInputs(): number;
        get numberOfOutputs(): number;
        get sampleTime(): number;
        chain(...args: (AudioNode | ToneAudioNode<ToneWithContextOptions>)[]): this;
        connect(
            destination: InputNode,
            outputNum?: number,
            inputNum?: number,
        ): this;
        disconnect(
            destination?: InputNode,
            outputNum?: number,
            inputNum?: number,
        ): this;
        dispose(): this;
        fan(...nodes: InputNode[]): this;
        get(): DestinationOptions;
        immediate(): number;
        now(): number;
        set(props: RecursivePartial<Options>): this;
        toDestination(): this;
        toFrequency(freq: Unit.Frequency): number;
        toMaster(): this;
        toSeconds(time?: Unit.Time): number;
        toString(): string;
        toTicks(time?: Unit.Time | TimeClass<number, TimeBaseUnit>): number;
    }

    Hierarchy (View Summary)

    Index

    Properties

    context: BaseContext

    The context belonging to the node.

    debug: boolean = false

    Set this debug flag to log all events that happen in this class.

    input: Volume = ...

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

    name: string = "Destination"

    The name of the class

    output: Gain = ...

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

    volume: Param<"decibels"> = ...

    The volume of the master output in decibels.

    -Infinity is silent, and 0 is no change.

    const osc = new Tone.Oscillator().toDestination();
    osc.start();
    // Ramp the volume down to silent over 10 seconds.
    Tone.getDestination().volume.rampTo(-Infinity, 10);

    Accessors

    • get blockTime(): number

      The number of seconds of 1 processing block (128 samples)

      Returns number

      console.log(Tone.Destination.blockTime);
      
    • get 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.

      Returns ChannelCountMode

    • set channelCountMode(channelCountMode: ChannelCountMode): void

      Parameters

      • channelCountMode: ChannelCountMode

      Returns void

    • get disposed(): boolean

      Indicates if the instance was disposed. 'Disposing' an instance means that all of the Web Audio nodes that were created for the instance are disconnected and freed for garbage collection.

      Returns boolean

    • get maxChannelCount(): number

      The maximum number of channels the system can output.

      Returns number

      console.log(Tone.Destination.maxChannelCount);
      
    • get mute(): boolean

      Mute the output.

      Returns boolean

      const oscillator = new Tone.Oscillator().start().toDestination();
      setTimeout(() => {
      // Mute the output.
      Tone.Destination.mute = true;
      }, 1000);
    • set mute(mute: boolean): void

      Parameters

      • mute: boolean

      Returns void

    • get numberOfInputs(): number

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

      Returns number

      const node = new Tone.Gain();
      console.log(node.numberOfInputs);
    • get numberOfOutputs(): number

      The number of outputs of the AudioNode.

      Returns number

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

    Methods

    • Add a master effects chain.

      NOTE: This will disconnect any nodes that were previously chained in the master effects chain.

      Parameters

      • ...args: (AudioNode | ToneAudioNode<ToneWithContextOptions>)[]

        All arguments will be connected in a row, and the master output will be routed through it.

      Returns this

      // Route all audio through a filter and compressor.
      const lowpass = new Tone.Filter(800, "lowpass");
      const compressor = new Tone.Compressor(-18);
      Tone.Destination.chain(lowpass, compressor);
    • connect the output of a ToneAudioNode to an AudioParam, AudioNode, or ToneAudioNode

      Parameters

      • destination: InputNode

        The output to connect to

      • outputNum: number = 0

        The output to connect from

      • inputNum: number = 0

        The input to connect to

      Returns this

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

      Parameters

      Returns this

      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);
    • Set multiple properties at once with an object.

      Parameters

      • props: RecursivePartial<Options>

      Returns this

      const filter = new Tone.Filter().toDestination();
      // set values using an object
      filter.set({
      frequency: "C6",
      type: "highpass"
      });
      const player = new Tone.Player("https://tonejs.github.io/audio/berklee/Analogsynth_octaves_highmid.mp3").connect(filter);
      player.autostart = true;