Skip to content

Commit 73f7043

Browse files
committed
Update MIDI.hpp
1 parent ab3a004 commit 73f7043

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

src/MIDI.hpp

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -893,26 +893,20 @@ bool MidiInterface<Transport, Settings, Platform>::parse()
893893
if (mErrorCallback)
894894
mErrorCallback(mLastError);
895895
if ((pendingType != Undefined_F9) && (pendingType != Undefined_FD)) { // Dont reset for 0xFD & 0xF9 (Undefined Realtime)
896-
resetInput(); // Input reset for stray EOX and Undefined common F4/F5
896+
mPendingMessageIndex = 0; // Message reset for stray EOX and Undefined common F4/F5
897897
}
898898
return false;
899899
}
900-
mRunningStatus_RX = InvalidType; // Reset Running Status until valid channel message complete
901900
mPendingMessage[0] = extracted; // Status seems good so lets store in pending
902901
if (extracted != SystemExclusiveEnd) mPendingMessageIndex = 1; // Set PendingMessageIndex to 1 (needs to be unchanged for EOX)
903902

904903
} else {
905904
// Check Status
906905
if (mPendingMessageIndex == 0) {
907-
if (mRunningStatus_RX) {
908-
mPendingMessage[0] = mRunningStatus_RX;
909-
mPendingMessageIndex = 1;
910-
} else {
911-
mLastError |= 1UL << ErrorParse; // Error: No Status
912-
if (mErrorCallback)
913-
mErrorCallback(mLastError);
914-
return false;
915-
}
906+
mLastError |= 1UL << ErrorParse; // Error: No Status
907+
if (mErrorCallback)
908+
mErrorCallback(mLastError);
909+
return false;
916910
}
917911
// Add Data
918912
if (mPendingMessage[0] == SystemExclusive)
@@ -953,8 +947,8 @@ bool MidiInterface<Transport, Settings, Platform>::parse()
953947
if (mErrorCallback)
954948
mErrorCallback(1UL << WarningSplitSysEx); // Notify but no need to store this warning?
955949
}
956-
byte lastByte = mMessage.sysexArray[Settings::SysExMaxSize - 1]; // <--- change from Settings::SysExMaxSize to mPendingMessageIndex?
957-
mMessage.sysexArray[Settings::SysExMaxSize - 1] = SystemExclusiveStart; // <--- change from Settings::SysExMaxSize to mPendingMessageIndex?
950+
byte lastByte = mMessage.sysexArray[Settings::SysExMaxSize - 1];
951+
mMessage.sysexArray[Settings::SysExMaxSize - 1] = SystemExclusiveStart;
958952
mMessage.valid = false;
959953
launchCallback();
960954

@@ -968,20 +962,20 @@ bool MidiInterface<Transport, Settings, Platform>::parse()
968962
}
969963

970964
// Process message
971-
mMessage.type = getTypeFromStatusByte(mPendingMessage[0]);
972-
if (isChannelMessage(mMessage.type)) {
965+
if (mPendingMessage[0] < 0xF0) { // Channel message
966+
mMessage.type = MidiType(mPendingMessage[0] & 0xF0);
973967
mMessage.channel = (mPendingMessage[0] & 0x0F) + 1;
974-
mRunningStatus_RX = mPendingMessage[0];
975-
} else
968+
mPendingMessageIndex = 1; // Set to 1 for running status
969+
} else { // Common message
970+
mMessage.type = MidiType(mPendingMessage[0]);
976971
mMessage.channel = 0;
972+
mPendingMessageIndex = 0;
973+
}
977974
mMessage.data1 = mPendingMessage[1];
978975
mMessage.data2 = mPendingMessage[2];
979976
mMessage.length = mPendingMessageExpectedLength;
980977
mMessage.valid = true;
981978

982-
// Reset index for next message
983-
mPendingMessageIndex = 0;
984-
985979
return true;
986980
} else {
987981
// We need more input...

0 commit comments

Comments
 (0)