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

Song plays way too fast than it should be #67

Open Andrew-J-Larson opened 4 years ago

Andrew-J-Larson commented 4 years ago

Here's the sample midi file: 72257.mid

It's like 2-4 times faster than it should be.

grimmdude commented 3 years ago

Hey @TheAlienDrew,

Thanks for your message. When I play this file in the demo it to plays at 120bpm which seems correct. Should it be playing at a different tempo?

https://grimmdude.com/MidiPlayerJS/

Andrew-J-Larson commented 3 years ago

Hey @TheAlienDrew,

Thanks for your message. When I play this file in the demo it to plays at 120bpm which seems correct. Should it be playing at a different tempo?

https://grimmdude.com/MidiPlayerJS/

It's not necessarily the tempo that's wrong, at least I don't remember for sure. I think there was some issues where tempo wouldn't play correctly for portions of the song. And, there was definitely an issue with it calculating the correct amount of time.

jdlee022 commented 1 year ago

I'm also having this issue, specifically with midi files that i export from Ableton. I haven't had this issue with midi files i export from Musescore so far.

Andrew-J-Larson commented 1 year ago

I'm also having this issue, specifically with midi files that i export from Ableton. I haven't had this issue with midi files i export from Musescore so far.

That's actually some pretty specific and possibly useful information... I wonder what the difference is between the two that export midis...

jdlee022 commented 1 year ago

So apparently midi files exported from Ableton do not include a tempo map, and will default to some bpm (i think 120). I searched quite a bit and the only solution to this that I've found is to import my midi file to a 3rd party program such as Musescore, edit the bpm, and export it from there. After that, I get the expected tempo and runtime when using MidiPlayerJS.

I'm not sure where you got your midi file from @TheAlienDrew, but i suspect other DAWs might lack tempo data from their midi file exports. IMO this does not seem like a bug on MidiPlayerJS's side, but rather the file that is fed into it.

Andrew-J-Larson commented 1 year ago

So apparently midi files exported from Ableton do not include a tempo map, and will default to some bpm (i think 120). I searched quite a bit and the only solution to this that I've found is to import my midi file to a 3rd party program such as Musescore, edit the bpm, and export it from there. After that, I get the expected tempo and runtime when using MidiPlayerJS.

I'm not sure where you got your midi file from @TheAlienDrew, but i suspect other DAWs might lack tempo data from their midi file exports. IMO this does not seem like a bug on MidiPlayerJS's side, but rather the file that is fed into it.

Doing some research myself, I think the difference between Ableton and DAWs like it, vs something like MuseScore, Ableton likes to use a master BPM/tempo (used throughout the song where no tempo change is marked in the file format). I assume when there's a temporary tempo change in Ableton, there is nothing marked at the end to suggest a new tempo (aka, midi should look for the master tempo again) whereas MuseScore likely puts the master tempo as another tempo change between temporary tempo changes. Assumably, this might mean that any files exported from you score are going to be a little bigger than other midi files, due to the addition of redundant tempo changes.

This would explain why some midi is act faster than others and why exporting a new score works just fine versus something like Ableton... In which case maybe has another functionality in that it doesn't need tempo changes back to the master tempo as long as some identifier is seen (of which I don't know because I can't reverse engineer any midi files myself) but I'm sure there is something there, given MIDI files from both will still play normally in things such as VLC and other music programs that support midi files.