Class MidiClass

Midi is a primitive type for encoding Time values. Midi can be constructed with or without the new keyword. Midi can be passed into the parameter of any method which takes time as an argument.

Hierarchy (view full)

Constructors

Properties

context: BaseContext
debug: boolean = false

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

defaultUnits: "midi" = "midi"

The default units

name: string = "MidiClass"
version: string = version

The version number semver

Accessors

  • 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

Methods

  • Quantize the time by the given subdivision. Optionally add a percentage which will move the time value towards the ideal quantized value by that percentage.

    Parameters

    • subdiv: Unit.Time

      The subdivision to quantize to

    • percent: number = 1

      Move the time value towards the quantized value by a percentage.

    Returns MidiNote

    Example

    Tone.Time(21).quantize(2); // returns 22
    Tone.Time(0.6).quantize("4n", 0.5); // returns 0.55