MIDI decoder sketch

Yes, that is more or less what I deduced from observing the data streams. You can tell a "command" byte by the fact that it has the high bit set, and then other (parameter) bytes follow in fixed amounts (eg. two, for note and velocity). So it makes sense to omit repeated commands.