Skip to content

duration is calculated incorrectly...do not use end of last note to calculate duration of clip... #182

@rchrdnsh

Description

@rchrdnsh

Right now the duration of the midi clip is derived from the end of the last note, which works if the last note ends at the end of the clip. But if the last note does NOT end at the end of the clip, for example, if it ends early, then the duration of the midi clip will be incorrect:

Here is something I found in regards to midi files:

FF 2F 00 End of Track
This event is not optional. It is included so that an exact ending point may be specified for the track, so that an exact length is defined, which is necessary for tracks which are looped or concatenated.

I have no idea how to parse a midi file, but with a midi file where the last note stops before the end of the clip the duration is correct. Here is an example:

Screenshot 2023-07-03 at 5 27 14 PM

The midi file is 4 measures long, and it should come out as an 8 for the duration, but the duration is calculated based on the ending of the last note, rather than the clip length, so the duration that tone js midi ends up with is 7.5, which is incorrect:

Screenshot 2023-07-03 at 5 28 29 PM

so, I do not know how to figure out the end of the clip, although FF 2F 00 might be it? but the current approach is incorrect with any midi file where the last note does not extend to the end of the clip.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions