Midi playback recreates midi events when song ends for no reason
When a song finishes playing, it "seeks" back to the start. The first time you play the song it also clears all the midi events and recreates them for no reason. The second, third, ... times the song is played the events are not recreated (which is correct). So something strange is happening the first time through.
Recreating all the midi events is a very expensive operation.
To reproduce this, create a song with just a few notes and push the "play" button. Put a breakpoint in rendermidi.cpp in playNote(). You should see the note events get created before the song is played and immediately after it finishes playing (the first time). The second, third... times the song is played it uses the existing midi event list as it should.