Fixed a bug on MIDI playback where tempo changed lead to undefined behaviour