Helper method.
This commit is contained in:
parent
240cd22021
commit
b041abaca3
|
|
@ -130,6 +130,7 @@ public:
|
|||
|
||||
public:
|
||||
static inline MidiType getTypeFromStatusByte(byte inStatus);
|
||||
static inline Channel getChannelFromStatusByte(byte inStatus);
|
||||
static inline bool isChannelMessage(MidiType inType);
|
||||
|
||||
private:
|
||||
|
|
|
|||
12
src/MIDI.hpp
12
src/MIDI.hpp
|
|
@ -551,7 +551,7 @@ bool MidiInterface<SerialPort>::parse()
|
|||
if (mPendingMessageIndex >= (mPendingMessageExpectedLenght - 1))
|
||||
{
|
||||
mMessage.type = getTypeFromStatusByte(mPendingMessage[0]);
|
||||
mMessage.channel = (mPendingMessage[0] & 0x0f) + 1;
|
||||
mMessage.channel = getChannelFromStatusByte(mPendingMessage[0]);
|
||||
mMessage.data1 = mPendingMessage[1];
|
||||
|
||||
// Save data2 only if applicable
|
||||
|
|
@ -725,7 +725,7 @@ bool MidiInterface<SerialPort>::parse()
|
|||
mMessage.type = getTypeFromStatusByte(mPendingMessage[0]);
|
||||
|
||||
if (isChannelMessage(mMessage.type))
|
||||
mMessage.channel = (mPendingMessage[0] & 0x0f) + 1;
|
||||
mMessage.channel = getChannelFromStatusByte(mPendingMessage[0]);
|
||||
else
|
||||
mMessage.channel = 0;
|
||||
|
||||
|
|
@ -948,6 +948,14 @@ MidiType MidiInterface<SerialPort>::getTypeFromStatusByte(byte 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>
|
||||
bool MidiInterface<SerialPort>::isChannelMessage(MidiType inType)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue