grimmdude / MidiPlayerJS

♬ MIDI parser & player engine for browser or Node. As a parser converts MIDI events into JSON. Works well with single or multitrack MIDI files.
https://grimmdude.com/MidiPlayerJS/
MIT License
357 stars 52 forks source link

[BUG] More duration issues #62

Closed Andrew-J-Larson closed 4 years ago

Andrew-J-Larson commented 4 years ago

This file, Death Waltz.mid, should show up of a duration around 3:32 (about 212 seconds), yet loads with a duration of about 2,077‬ seconds...

Hopefully it's not too hard too fix either.

grimmdude commented 4 years ago

Hi @TheAlienDrew,

I think the issue here is that there's a "Set Tempo" event for 20 at the beginning of the file and the player is using that as the default. So the song duration is being calculated based on that, hence the very long duration. I just pushed a change so that the player will actually change tempo when a tempo event is triggered which I think should also address the issue you mentioned in #61. Let me know your thoughts on that.

Ideally, the song duration should calculate with all tempo changes factored in but currently it's only being calculated based on the current tempo. Will try to address that shortly.

-Garrett

Andrew-J-Larson commented 4 years ago

Yes that fixed the issue, and it fixed duration time in #61.