Merge branch 'dev' of https://github.com/FortySevenEffects/arduino_midi_library into dev
This commit is contained in:
commit
70ff97886c
51
src/MIDI.hpp
51
src/MIDI.hpp
|
|
@ -545,29 +545,11 @@ bool MidiInterface<SerialPort>::parse()
|
||||||
// Else: well, we received another status byte,
|
// Else: well, we received another status byte,
|
||||||
// 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.
|
||||||
|
|
||||||
if (mPendingMessageIndex >= (mPendingMessageExpectedLenght - 1))
|
|
||||||
{
|
|
||||||
mMessage.type = getTypeFromStatusByte(mPendingMessage[0]);
|
|
||||||
mMessage.channel = getChannelFromStatusByte(mPendingMessage[0]);
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (getTypeFromStatusByte(mPendingMessage[0]))
|
switch (getTypeFromStatusByte(mPendingMessage[0]))
|
||||||
{
|
{
|
||||||
// 1 byte messages
|
// 1 byte messages
|
||||||
case Start:
|
case Start:
|
||||||
case Continue:
|
case Continue:
|
||||||
case Stop:
|
case Stop:
|
||||||
|
|
@ -627,17 +609,38 @@ bool MidiInterface<SerialPort>::parse()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then update the index of the pending message.
|
if (mPendingMessageIndex >= (mPendingMessageExpectedLenght - 1))
|
||||||
mPendingMessageIndex++;
|
{
|
||||||
|
// Reception complete
|
||||||
|
mMessage.type = getTypeFromStatusByte(mPendingMessage[0]);
|
||||||
|
mMessage.channel = getChannelFromStatusByte(mPendingMessage[0]);
|
||||||
|
mMessage.data1 = mPendingMessage[1];
|
||||||
|
|
||||||
#if USE_1BYTE_PARSING
|
// 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;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Waiting for more data
|
||||||
|
mPendingMessageIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if USE_1BYTE_PARSING
|
||||||
// Message is not complete.
|
// Message is not complete.
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
// Call the parser recursively
|
// Call the parser recursively
|
||||||
// to parse the rest of the message.
|
// to parse the rest of the message.
|
||||||
return parse();
|
return parse();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue