commit
a44d1e7c1c
|
|
@ -37,8 +37,8 @@ BEGIN_MIDI_NAMESPACE
|
||||||
data you want to send.
|
data you want to send.
|
||||||
\param inData The data to encode.
|
\param inData The data to encode.
|
||||||
\param outSysEx The output buffer where to store the encoded message.
|
\param outSysEx The output buffer where to store the encoded message.
|
||||||
\param inLength The lenght of the input buffer.
|
\param inLength The length of the input buffer.
|
||||||
\return The lenght of the encoded output buffer.
|
\return The length of the encoded output buffer.
|
||||||
@see decodeSysEx
|
@see decodeSysEx
|
||||||
Code inspired from Ruin & Wesen's SysEx encoder/decoder - http://ruinwesen.com
|
Code inspired from Ruin & Wesen's SysEx encoder/decoder - http://ruinwesen.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -74,8 +74,8 @@ unsigned encodeSysEx(const byte* inData, byte* outSysEx, unsigned inLength)
|
||||||
your received message.
|
your received message.
|
||||||
\param inSysEx The SysEx data received from MIDI in.
|
\param inSysEx The SysEx data received from MIDI in.
|
||||||
\param outData The output buffer where to store the decrypted message.
|
\param outData The output buffer where to store the decrypted message.
|
||||||
\param inLength The lenght of the input buffer.
|
\param inLength The length of the input buffer.
|
||||||
\return The lenght of the output buffer.
|
\return The length of the output buffer.
|
||||||
@see encodeSysEx @see getSysExArrayLength
|
@see encodeSysEx @see getSysExArrayLength
|
||||||
Code inspired from Ruin & Wesen's SysEx encoder/decoder - http://ruinwesen.com
|
Code inspired from Ruin & Wesen's SysEx encoder/decoder - http://ruinwesen.com
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -234,7 +234,7 @@ private:
|
||||||
StatusByte mRunningStatus_RX;
|
StatusByte mRunningStatus_RX;
|
||||||
StatusByte mRunningStatus_TX;
|
StatusByte mRunningStatus_TX;
|
||||||
byte mPendingMessage[3];
|
byte mPendingMessage[3];
|
||||||
unsigned mPendingMessageExpectedLenght;
|
unsigned mPendingMessageExpectedLength;
|
||||||
unsigned mPendingMessageIndex;
|
unsigned mPendingMessageIndex;
|
||||||
unsigned mCurrentRpnNumber;
|
unsigned mCurrentRpnNumber;
|
||||||
unsigned mCurrentNrpnNumber;
|
unsigned mCurrentNrpnNumber;
|
||||||
|
|
@ -250,8 +250,8 @@ private:
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
unsigned encodeSysEx(const byte* inData, byte* outSysEx, unsigned inLenght);
|
unsigned encodeSysEx(const byte* inData, byte* outSysEx, unsigned inLength);
|
||||||
unsigned decodeSysEx(const byte* inSysEx, byte* outData, unsigned inLenght);
|
unsigned decodeSysEx(const byte* inSysEx, byte* outData, unsigned inLength);
|
||||||
|
|
||||||
END_MIDI_NAMESPACE
|
END_MIDI_NAMESPACE
|
||||||
|
|
||||||
|
|
|
||||||
28
src/MIDI.hpp
28
src/MIDI.hpp
|
|
@ -36,7 +36,7 @@ inline MidiInterface<SerialPort, Settings>::MidiInterface(SerialPort& inSerial)
|
||||||
, mInputChannel(0)
|
, mInputChannel(0)
|
||||||
, mRunningStatus_RX(InvalidType)
|
, mRunningStatus_RX(InvalidType)
|
||||||
, mRunningStatus_TX(InvalidType)
|
, mRunningStatus_TX(InvalidType)
|
||||||
, mPendingMessageExpectedLenght(0)
|
, mPendingMessageExpectedLength(0)
|
||||||
, mPendingMessageIndex(0)
|
, mPendingMessageIndex(0)
|
||||||
, mCurrentRpnNumber(0xffff)
|
, mCurrentRpnNumber(0xffff)
|
||||||
, mCurrentNrpnNumber(0xffff)
|
, mCurrentNrpnNumber(0xffff)
|
||||||
|
|
@ -95,7 +95,7 @@ void MidiInterface<SerialPort, Settings>::begin(Channel inChannel)
|
||||||
mRunningStatus_RX = InvalidType;
|
mRunningStatus_RX = InvalidType;
|
||||||
|
|
||||||
mPendingMessageIndex = 0;
|
mPendingMessageIndex = 0;
|
||||||
mPendingMessageExpectedLenght = 0;
|
mPendingMessageExpectedLength = 0;
|
||||||
|
|
||||||
mCurrentRpnNumber = 0xffff;
|
mCurrentRpnNumber = 0xffff;
|
||||||
mCurrentNrpnNumber = 0xffff;
|
mCurrentNrpnNumber = 0xffff;
|
||||||
|
|
@ -746,7 +746,7 @@ bool MidiInterface<SerialPort, Settings>::parse()
|
||||||
// Do not reset all input attributes, Running Status must remain unchanged.
|
// Do not reset all input attributes, Running Status must remain unchanged.
|
||||||
// We still need to reset these
|
// We still need to reset these
|
||||||
mPendingMessageIndex = 0;
|
mPendingMessageIndex = 0;
|
||||||
mPendingMessageExpectedLenght = 0;
|
mPendingMessageExpectedLength = 0;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
|
|
@ -756,7 +756,7 @@ bool MidiInterface<SerialPort, Settings>::parse()
|
||||||
case AfterTouchChannel:
|
case AfterTouchChannel:
|
||||||
case TimeCodeQuarterFrame:
|
case TimeCodeQuarterFrame:
|
||||||
case SongSelect:
|
case SongSelect:
|
||||||
mPendingMessageExpectedLenght = 2;
|
mPendingMessageExpectedLength = 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// 3 bytes messages
|
// 3 bytes messages
|
||||||
|
|
@ -766,13 +766,13 @@ bool MidiInterface<SerialPort, Settings>::parse()
|
||||||
case PitchBend:
|
case PitchBend:
|
||||||
case AfterTouchPoly:
|
case AfterTouchPoly:
|
||||||
case SongPosition:
|
case SongPosition:
|
||||||
mPendingMessageExpectedLenght = 3;
|
mPendingMessageExpectedLength = 3;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SystemExclusive:
|
case SystemExclusive:
|
||||||
// The message can be any lenght
|
// The message can be any length
|
||||||
// between 3 and MidiMessage::sSysExMaxSize bytes
|
// between 3 and MidiMessage::sSysExMaxSize bytes
|
||||||
mPendingMessageExpectedLenght = MidiMessage::sSysExMaxSize;
|
mPendingMessageExpectedLength = MidiMessage::sSysExMaxSize;
|
||||||
mRunningStatus_RX = InvalidType;
|
mRunningStatus_RX = InvalidType;
|
||||||
mMessage.sysexArray[0] = SystemExclusive;
|
mMessage.sysexArray[0] = SystemExclusive;
|
||||||
break;
|
break;
|
||||||
|
|
@ -785,7 +785,7 @@ bool MidiInterface<SerialPort, Settings>::parse()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPendingMessageIndex >= (mPendingMessageExpectedLenght - 1))
|
if (mPendingMessageIndex >= (mPendingMessageExpectedLength - 1))
|
||||||
{
|
{
|
||||||
// Reception complete
|
// Reception complete
|
||||||
mMessage.type = getTypeFromStatusByte(mPendingMessage[0]);
|
mMessage.type = getTypeFromStatusByte(mPendingMessage[0]);
|
||||||
|
|
@ -794,7 +794,7 @@ bool MidiInterface<SerialPort, Settings>::parse()
|
||||||
mMessage.data2 = 0; // Completed new message has 1 data byte
|
mMessage.data2 = 0; // Completed new message has 1 data byte
|
||||||
|
|
||||||
mPendingMessageIndex = 0;
|
mPendingMessageIndex = 0;
|
||||||
mPendingMessageExpectedLenght = 0;
|
mPendingMessageExpectedLength = 0;
|
||||||
mMessage.valid = true;
|
mMessage.valid = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -882,7 +882,7 @@ bool MidiInterface<SerialPort, Settings>::parse()
|
||||||
mPendingMessage[mPendingMessageIndex] = extracted;
|
mPendingMessage[mPendingMessageIndex] = extracted;
|
||||||
|
|
||||||
// Now we are going to check if we have reached the end of the message
|
// Now we are going to check if we have reached the end of the message
|
||||||
if (mPendingMessageIndex >= (mPendingMessageExpectedLenght - 1))
|
if (mPendingMessageIndex >= (mPendingMessageExpectedLength - 1))
|
||||||
{
|
{
|
||||||
// "FML" case: fall down here with an overflown SysEx..
|
// "FML" case: fall down here with an overflown SysEx..
|
||||||
// This means we received the last possible data byte that can fit
|
// This means we received the last possible data byte that can fit
|
||||||
|
|
@ -903,11 +903,11 @@ bool MidiInterface<SerialPort, Settings>::parse()
|
||||||
mMessage.data1 = mPendingMessage[1];
|
mMessage.data1 = mPendingMessage[1];
|
||||||
|
|
||||||
// Save data2 only if applicable
|
// Save data2 only if applicable
|
||||||
mMessage.data2 = mPendingMessageExpectedLenght == 3 ? mPendingMessage[2] : 0;
|
mMessage.data2 = mPendingMessageExpectedLength == 3 ? mPendingMessage[2] : 0;
|
||||||
|
|
||||||
// Reset local variables
|
// Reset local variables
|
||||||
mPendingMessageIndex = 0;
|
mPendingMessageIndex = 0;
|
||||||
mPendingMessageExpectedLenght = 0;
|
mPendingMessageExpectedLength = 0;
|
||||||
|
|
||||||
mMessage.valid = true;
|
mMessage.valid = true;
|
||||||
|
|
||||||
|
|
@ -996,7 +996,7 @@ template<class SerialPort, class Settings>
|
||||||
inline void MidiInterface<SerialPort, Settings>::resetInput()
|
inline void MidiInterface<SerialPort, Settings>::resetInput()
|
||||||
{
|
{
|
||||||
mPendingMessageIndex = 0;
|
mPendingMessageIndex = 0;
|
||||||
mPendingMessageExpectedLenght = 0;
|
mPendingMessageExpectedLength = 0;
|
||||||
mRunningStatus_RX = InvalidType;
|
mRunningStatus_RX = InvalidType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1047,7 +1047,7 @@ inline const byte* MidiInterface<SerialPort, Settings>::getSysExArray() const
|
||||||
return mMessage.sysexArray;
|
return mMessage.sysexArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Get the lenght of the System Exclusive array.
|
/*! \brief Get the length of the System Exclusive array.
|
||||||
|
|
||||||
It is coded using data1 as LSB and data2 as MSB.
|
It is coded using data1 as LSB and data2 as MSB.
|
||||||
\return The array's length, in bytes.
|
\return The array's length, in bytes.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue