craffel / pretty-midi

Utility functions for handling MIDI data in a nice/intuitive way.
MIT License
873 stars 151 forks source link

Tempo changes not loaded properly #204

Open lucasnfe opened 2 years ago

lucasnfe commented 2 years ago

I think there is a bug with the get_tempo_changes() function. It is not loading the tempo changes properly. Here is an example:

mid = pretty_midi.PrettyMIDI(midi_file="Undertale_PC_Undertale_Snowy.mid")
mid.get_tempo_changes() 

output:
(array([ 0.        , 15.73798337, 15.73894393]), array([60.99519764, 60.99966247, 60.99519764]))

But when I open the midi file on a midi player (e.g. GarageBand), the first ~60bpm tempo change only happens around the 5th bar. Here is a screenshot:

Screen Shot 2021-11-12 at 3 01 21 PM

If I save the midi file with pretty_midi (mid.write("Undertale_PC_Undertale_Snowy._copy.mid")) and open it with the same midi player, this is the output:

Screen Shot 2021-11-12 at 3 09 14 PM

Here are the midi file and the screenshots for reproduction: reproduce.zip

pretty_midi 0.2.9 and python 3.7