Further refactor of midiReadGetNextMessage() function