Class Track

Holds all data for a track.

Param

{type: number, data: array, size: array, events: array}

Returns

Hierarchy

  • Track

Implements

  • Chunk

Constructors

Properties

data: number[]
events: AbstractEvent[]
explicitTickEvents: NoteEvent[]
size: number[]
tickPointer: number
type: number[]

Methods

  • Adds copyright to MIDI file.

    Parameters

    • text: string

      Text of copyright line.

    Returns Track

  • Adds any event type to the track. Events without a specific startTick property are assumed to be added in order of how they should output. Events with a specific startTick property are set aside for now will be merged in during build process.

    TODO: Don't put startTick events in their own array. Just lump everything together and sort it out during buildData();

    Parameters

    • events: AbstractEvent | AbstractEvent[]

      Event object or array of Event objects.

    • Optional mapFunction: ((i, event) => object)

      Callback which can be used to apply specific properties to all events.

        • (i, event): object
        • Parameters

          • i: number
          • event: AbstractEvent

          Returns object

    Returns Track

  • Sets instrument name of track.

    Parameters

    • text: string

      Name of instrument.

    Returns Track

  • Adds a controller change event

    Parameters

    • number: number

      Control number.

    • value: number

      Control value.

    • Optional channel: number

      Channel to send controller change event on (1-based).

    • Optional delta: number

      Track tick offset for cc event.

    Returns Track

  • Merges a single event into this track's list of events based on event.tick property.

    Parameters

    • event: AbstractEvent

    Returns Track

  • Removes all events matching specified type.

    Parameters

    • eventName: string

      Event type

    Returns Track

  • Sets a pitch bend.

    Parameters

    • bend: number

      Bend value ranging [-1,1], zero meaning no bend.

    Returns Track

  • Sets tempo of the MIDI file.

    Parameters

    • bpm: number

      Tempo in beats per minute.

    • tick: number = 0

      Start tick.

    Returns Track

  • Sets time signature.

    Parameters

    • numerator: number

      Top number of the time signature.

    • denominator: number

      Bottom number of the time signature.

    • midiclockspertick: number

      Defaults to 24.

    • notespermidiclock: number

      Defaults to 8.

    Returns Track

Generated using TypeDoc