Helper method.
This commit is contained in:
parent
240cd22021
commit
b041abaca3
|
|
@ -130,6 +130,7 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static inline MidiType getTypeFromStatusByte(byte inStatus);
|
static inline MidiType getTypeFromStatusByte(byte inStatus);
|
||||||
|
static inline Channel getChannelFromStatusByte(byte inStatus);
|
||||||
static inline bool isChannelMessage(MidiType inType);
|
static inline bool isChannelMessage(MidiType inType);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
16
src/MIDI.hpp
16
src/MIDI.hpp
|
|
@ -550,9 +550,9 @@ bool MidiInterface<SerialPort>::parse()
|
||||||
|
|
||||||
if (mPendingMessageIndex >= (mPendingMessageExpectedLenght - 1))
|
if (mPendingMessageIndex >= (mPendingMessageExpectedLenght - 1))
|
||||||
{
|
{
|
||||||
mMessage.type = getTypeFromStatusByte(mPendingMessage[0]);
|
mMessage.type = getTypeFromStatusByte(mPendingMessage[0]);
|
||||||
mMessage.channel = (mPendingMessage[0] & 0x0f) + 1;
|
mMessage.channel = getChannelFromStatusByte(mPendingMessage[0]);
|
||||||
mMessage.data1 = mPendingMessage[1];
|
mMessage.data1 = mPendingMessage[1];
|
||||||
|
|
||||||
// Save data2 only if applicable
|
// Save data2 only if applicable
|
||||||
if (mPendingMessageExpectedLenght == 3)
|
if (mPendingMessageExpectedLenght == 3)
|
||||||
|
|
@ -725,7 +725,7 @@ bool MidiInterface<SerialPort>::parse()
|
||||||
mMessage.type = getTypeFromStatusByte(mPendingMessage[0]);
|
mMessage.type = getTypeFromStatusByte(mPendingMessage[0]);
|
||||||
|
|
||||||
if (isChannelMessage(mMessage.type))
|
if (isChannelMessage(mMessage.type))
|
||||||
mMessage.channel = (mPendingMessage[0] & 0x0f) + 1;
|
mMessage.channel = getChannelFromStatusByte(mPendingMessage[0]);
|
||||||
else
|
else
|
||||||
mMessage.channel = 0;
|
mMessage.channel = 0;
|
||||||
|
|
||||||
|
|
@ -948,6 +948,14 @@ MidiType MidiInterface<SerialPort>::getTypeFromStatusByte(byte inStatus)
|
||||||
return (MidiType)inStatus;
|
return (MidiType)inStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! \brief Returns channel in the range 1-16
|
||||||
|
*/
|
||||||
|
template<class SerialPort>
|
||||||
|
inline Channel MidiInterface<SerialPort>::getChannelFromStatusByte(byte inStatus)
|
||||||
|
{
|
||||||
|
return (inStatus & 0x0f) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
template<class SerialPort>
|
template<class SerialPort>
|
||||||
bool MidiInterface<SerialPort>::isChannelMessage(MidiType inType)
|
bool MidiInterface<SerialPort>::isChannelMessage(MidiType inType)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue