Documentation
    Preparing search index...

    Class ToneWithContext<Options>Abstract

    The Base class for all nodes that have an AudioContext.

    Type Parameters

    Hierarchy (View Summary)

    Index
    context: BaseContext

    The context belonging to the node.

    debug: boolean

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

    name: string

    The name of the class

    version: string

    The version number semver

    • get blockTime(): number

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

      Returns number

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

      The duration in seconds of one sample.

      Returns number

    • Get a subset of the properties which are in the partial props

      Parameters

      Returns Partial<Options>

    • disconnect and dispose.

      Returns this

    • Get the object's attributes.

      Returns Options

      const osc = new Tone.Oscillator();
      console.log(osc.get());
    • Return the current time of the Context clock without any lookAhead.

      Returns number

      setInterval(() => {
      console.log(Tone.immediate());
      }, 100);
    • Prints the outputs to the console log for debugging purposes. Prints the contents only if either the object has a property called debug set to true, or a variable called TONE_DEBUG_CLASS is set to the name of the class.

      Parameters

      • ...args: any[]

      Returns void

      const osc = new Tone.Oscillator();
      // prints all logs originating from this oscillator
      osc.debug = true;
      // calls to start/stop will print in the console
      osc.start();
    • Return the current time of the Context clock plus the lookAhead.

      Returns number

      setInterval(() => {
      console.log(Tone.now());
      }, 100);
    • Set multiple properties at once with an object.

      Parameters

      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;
    • Convert the input to a frequency number

      Parameters

      Returns number

      const gain = new Tone.Gain();
      console.log(gain.toFrequency("4n"));
    • Convert the incoming time to seconds. This is calculated against the current TransportClass bpm

      Parameters

      Returns number

      const gain = new Tone.Gain();
      setInterval(() => console.log(gain.toSeconds("4n")), 100);
      // ramp the tempo to 60 bpm over 30 seconds
      Tone.getTransport().bpm.rampTo(60, 30);
    • Convert the class to a string

      Returns string

      const osc = new Tone.Oscillator();
      console.log(osc.toString());
    • Convert the input time into ticks

      Parameters

      Returns number

      const gain = new Tone.Gain();
      console.log(gain.toTicks("4n"));