refactored _midiReadVarLen() function