Added detection of channel messages to fix running status.
This commit is contained in:
parent
5a55f715da
commit
6f0535be90
|
|
@ -109,7 +109,8 @@ public:
|
||||||
inline void setInputChannel(Channel inChannel);
|
inline void setInputChannel(Channel inChannel);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static inline MidiType getTypeFromStatusByte(const byte inStatus);
|
static inline MidiType getTypeFromStatusByte(byte inStatus);
|
||||||
|
static inline bool isChannelMessage(MidiType inType);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool inputFilter(Channel inChannel);
|
bool inputFilter(Channel inChannel);
|
||||||
|
|
|
||||||
|
|
@ -514,16 +514,9 @@ bool MidiInterface<SerialPort>::parse(Channel inChannel)
|
||||||
mPendingMessage[0] = extracted;
|
mPendingMessage[0] = extracted;
|
||||||
|
|
||||||
// Check for running status first
|
// Check for running status first
|
||||||
switch (getTypeFromStatusByte(mRunningStatus_RX))
|
if (isChannelMessage(getTypeFromStatusByte(mRunningStatus_RX)))
|
||||||
{
|
{
|
||||||
// Only these types allow Running Status:
|
// Only these types allow Running Status
|
||||||
case NoteOff:
|
|
||||||
case NoteOn:
|
|
||||||
case AfterTouchPoly:
|
|
||||||
case ControlChange:
|
|
||||||
case ProgramChange:
|
|
||||||
case AfterTouchChannel:
|
|
||||||
case PitchBend:
|
|
||||||
|
|
||||||
// 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
|
||||||
|
|
@ -554,10 +547,6 @@ bool MidiInterface<SerialPort>::parse(Channel inChannel)
|
||||||
mMessage.valid = true;
|
mMessage.valid = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// No running status
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (getTypeFromStatusByte(mPendingMessage[0]))
|
switch (getTypeFromStatusByte(mPendingMessage[0]))
|
||||||
|
|
@ -717,8 +706,11 @@ bool MidiInterface<SerialPort>::parse(Channel inChannel)
|
||||||
}
|
}
|
||||||
|
|
||||||
mMessage.type = getTypeFromStatusByte(mPendingMessage[0]);
|
mMessage.type = getTypeFromStatusByte(mPendingMessage[0]);
|
||||||
// Don't check if it is a Channel Message
|
|
||||||
|
if (isChannelMessage(mMessage.type))
|
||||||
mMessage.channel = (mPendingMessage[0] & 0x0F)+1;
|
mMessage.channel = (mPendingMessage[0] & 0x0F)+1;
|
||||||
|
else
|
||||||
|
mMessage.channel = 0;
|
||||||
|
|
||||||
mMessage.data1 = mPendingMessage[1];
|
mMessage.data1 = mPendingMessage[1];
|
||||||
|
|
||||||
|
|
@ -908,7 +900,7 @@ void MidiInterface<SerialPort>::setInputChannel(Channel inChannel)
|
||||||
made public so you can handle MidiTypes more easily.
|
made public so you can handle MidiTypes more easily.
|
||||||
*/
|
*/
|
||||||
template<class SerialPort>
|
template<class SerialPort>
|
||||||
MidiType MidiInterface<SerialPort>::getTypeFromStatusByte(const byte inStatus)
|
MidiType MidiInterface<SerialPort>::getTypeFromStatusByte(byte inStatus)
|
||||||
{
|
{
|
||||||
if ((inStatus < 0x80) ||
|
if ((inStatus < 0x80) ||
|
||||||
(inStatus == 0xF4) ||
|
(inStatus == 0xF4) ||
|
||||||
|
|
@ -919,6 +911,18 @@ MidiType MidiInterface<SerialPort>::getTypeFromStatusByte(const byte inStatus)
|
||||||
else return (MidiType)inStatus;
|
else return (MidiType)inStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class SerialPort>
|
||||||
|
bool MidiInterface<SerialPort>::isChannelMessage(MidiType inType)
|
||||||
|
{
|
||||||
|
return (inType == NoteOff ||
|
||||||
|
inType == NoteOn ||
|
||||||
|
inType == ControlChange ||
|
||||||
|
inType == AfterTouchPoly ||
|
||||||
|
inType == AfterTouchChannel ||
|
||||||
|
inType == PitchBend ||
|
||||||
|
inType == ProgramChange);
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if MIDI_USE_CALLBACKS
|
#if MIDI_USE_CALLBACKS
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue