Lume
    Preparing search index...

    Class TimeTracker

    TimeTracker stores and calculates time-related information of a MIDI file, acting as both a data class and a "stopwatch" that returns information about the current state of a MIDI file, such as the measure it's on.

    TimeTracker does not run in real-time, but calculates the state of a MIDI file based on a given start time, and how long it has been running. TimeTracker uses milliseconds to calculate information,

    Index

    Accessors

    • get endTime(): number

      Gets the end time, which is either the point in time that the MIDI file stopped playing, the current time (via Date.now()) if the file is still playing.

      Returns number

      Internally, endTime is set to a negative value if the MIDI file is still playing, but this property will return Date.now().

    • get startTime(): number

      Returns the start time, which is the point in time when the MIDI file has begun playing.

      Returns number

      StartTime is set by using Date.now(), and is consequently stored in milliseconds since the epoch (12:00 AM January 1, 1970, UTC).

    • get timeSignature(): string

      Returns the time signature of the track as a string.

      Returns string

      "4/4", "6/8".
      

    Constructors

    • Creates a new instance of TimeTracker.

      Parameters

      • bpm: number

        Beats per minute.

      • beatsPerMeasure: number

        The amount of beats per measure. In a time signature, this would be the upper number.

      • timeSignatureNoteValue: number

        The note value of individual beats in a measure. In a time signature, this would be the lower number.

      Returns TimeTracker

    Methods

    • Returns the amount of beats that have been completed since startTime.

      This method starts at 0, as when startTime is equal to the current time, no beats would have been completed.

      Returns number

      1, 2, 3, 4, 5, 6, 7, 8, 9, 10...
      
    • Returns the current beat.

      This method covers a range between 1 and the beats per measure (both inclusive). It will loop continously within this range.

      Returns number

      1, 2, 3, 4, 1, 2, 3, 4, 1, 2...
      
    • Returns the current measure number.

      This method is one-indexed, meaning the first measure is 1, not 0.

      Returns number

      1, 2, 3, 4, 5, 6, 7, 8, 9, 10...
      
    • Returns the amount of time (in seconds) that has passed since the startTime.

      Returns number

    • Gets the current time, and marks it as the start time.

      If this method is never invoked, startTime will use it's default value of when the instance was created (set in the constructor).

      Returns void