Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rchrdnsh opened this issue Jul 4, 2023 · 1 comment

Comments

@rchrdnsh
Copy link

rchrdnsh commented Jul 4, 2023

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!

@allandiego
Copy link

I dont know if my issue is related but I got some midi files parsing duration ticks 0 for notes
Example:
drums 0 duration ticks.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants