Documentation
    Preparing search index...

    Class Emitter<EventType>

    Emitter gives classes which extend it the ability to listen for and emit events. Inspiration and reference from Jerome Etienne's MicroEvent. MIT (c) 2011 Jerome Etienne.

    Type Parameters

    • EventType extends string = string

    Hierarchy (View Summary)

    Implemented by

    Index
    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 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

    • Clean up

      Returns this

    • Invoke all of the callbacks bound to the event with any arguments passed in.

      Parameters

      • event: EventType

        The name of the event.

      • ...args: any[]

        The arguments to pass to the functions listening.

      Returns this

    • 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();
    • Remove the event listener.

      Parameters

      • event: EventType

        The event to stop listening to.

      • Optionalcallback: (...args: any[]) => void

        The callback which was bound to the event with Emitter.on. If no callback is given, all callbacks events are removed.

      Returns this

    • Bind a callback to a specific event.

      Parameters

      • event: EventType

        The name of the event to listen for.

      • callback: (...args: any[]) => void

        The callback to invoke when the event is emitted

      Returns this

    • Bind a callback which is only invoked once

      Parameters

      • event: EventType

        The name of the event to listen for.

      • callback: (...args: any[]) => void

        The callback to invoke when the event is emitted

      Returns this

    • Convert the class to a string

      Returns string

      const osc = new Tone.Oscillator();
      console.log(osc.toString());
    • Returns all of the default options belonging to the class.

      Returns BaseToneOptions

    • Add Emitter functions (on/off/emit) to the object

      Parameters

      • constr: any

      Returns void