Class Utils

Static utility functions used throughout the library.

Hierarchy

  • Utils

Constructors

Methods

  • Converts velocity to value 0-127

    Parameters

    • velocity: number

      Velocity value 1-100

    Returns number

  • Gets what to multiple ticks/quarter note by to get the specified duration. Note: type=='note' defaults to quarter note, type==='rest' defaults to 0

    Parameters

    • duration: string

    Returns number

  • Due to low precision of MIDI, we need to keep track of rounding errors in deltas. This function will calculate the rounding error for a given duration.

    Parameters

    • tick: number

    Returns number

    Static

  • Due to rounding errors in JavaScript engines, it's safe to round when we're very close to the actual tick number

    Parameters

    • tick: number

    Returns number

    Static

  • Gets the total number of ticks of a specified duration. Note: type=='note' defaults to quarter note, type==='rest' defaults to 0

    Parameters

    • duration: string | number | string[]

    Returns number

  • Checks if argument is a valid number.

    Parameters

    • n: any

      Value to check

    Returns boolean

  • Get an int from an array of bytes.

    Parameters

    • bytes: number[]

    Returns number

  • Takes a number and splits it up into an array of bytes. Can be padded by passing a number to bytesNeeded

    Parameters

    • number: number
    • bytesNeeded: number

    Returns number[]

    • Array of bytes
  • Translates number of ticks to MIDI timestamp format, returning an array of hex strings with the time values. Midi has a very particular time to express time, take a good look at the spec before ever touching this function. Thanks to https://github.com/sergi/jsmidi

    Parameters

    • ticks: number

      Number of ticks to be translated

    Returns number[]

    • Bytes that form the MIDI time value
  • Counts number of bytes in string

    Parameters

    • s: string

    Returns number

  • Convert a string to an array of bytes

    Parameters

    • string: string

    Returns number[]

  • Converts value to array if needed.

    Parameters

    • value: any

    Returns any[]

  • Gets MidiWriterJS version number.

    Returns string

Generated using TypeDoc