Fixed bug when receiving 2 byte messages with running status.
This commit is contained in:
parent
efd72f9df6
commit
5bda959405
20
src/MIDI.cpp
20
src/MIDI.cpp
|
|
@ -528,6 +528,8 @@ bool MIDI_Class::parse(byte inChannel)
|
||||||
case ProgramChange:
|
case ProgramChange:
|
||||||
case AfterTouchChannel:
|
case AfterTouchChannel:
|
||||||
case PitchBend:
|
case PitchBend:
|
||||||
|
case ProgramChange:
|
||||||
|
case AfterTouchChannel:
|
||||||
|
|
||||||
// If the status byte is not received, prepend it
|
// If the status byte is not received, prepend it
|
||||||
// to the pending message
|
// to the pending message
|
||||||
|
|
@ -541,8 +543,24 @@ bool MIDI_Class::parse(byte inChannel)
|
||||||
// so the running status does not apply here.
|
// so the running status does not apply here.
|
||||||
// It will be updated upon completion of this message.
|
// It will be updated upon completion of this message.
|
||||||
|
|
||||||
break;
|
if (mPendingMessageIndex >= (mPendingMessageExpectedLenght-1))
|
||||||
|
{
|
||||||
|
mMessage.type = getTypeFromStatusByte(mPendingMessage[0]);
|
||||||
|
mMessage.channel = (mPendingMessage[0] & 0x0F)+1;
|
||||||
|
mMessage.data1 = mPendingMessage[1];
|
||||||
|
|
||||||
|
// Save data2 only if applicable
|
||||||
|
if (mPendingMessageExpectedLenght == 3)
|
||||||
|
mMessage.data2 = mPendingMessage[2];
|
||||||
|
else
|
||||||
|
mMessage.data2 = 0;
|
||||||
|
|
||||||
|
mPendingMessageIndex = 0;
|
||||||
|
mPendingMessageExpectedLenght = 0;
|
||||||
|
mMessage.valid = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// No running status
|
// No running status
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue