replaced ActiveSensing with Sender Active Sensing

Receiver active Sensing is not implemented (yet)
This commit is contained in:
lathoub 2020-02-04 10:46:14 +01:00
parent 7f9934b1aa
commit 5fab6b3fc3
3 changed files with 25 additions and 31 deletions

View File

@ -86,8 +86,6 @@ public:
DataByte inPressure, DataByte inPressure,
Channel inChannel); Channel inChannel);
inline void sendActiveSensing();
inline void sendSysEx(unsigned inLength, inline void sendSysEx(unsigned inLength,
const byte* inArray, const byte* inArray,
bool inArrayContainsBoundaries = false); bool inArrayContainsBoundaries = false);
@ -242,9 +240,10 @@ private:
unsigned mCurrentNrpnNumber; unsigned mCurrentNrpnNumber;
bool mThruActivated : 1; bool mThruActivated : 1;
Thru::Mode mThruFilterMode : 7; Thru::Mode mThruFilterMode : 7;
unsigned long mLastMessageSentTime;
bool mSenderActiveSensingActivated;
MidiMessage mMessage; MidiMessage mMessage;
unsigned long mLastSendMessageTime;
bool mActiveSensingActivated;
private: private:
inline StatusByte getStatus(MidiType inType, inline StatusByte getStatus(MidiType inType,

View File

@ -40,8 +40,8 @@ inline MidiInterface<SerialPort, Settings>::MidiInterface(SerialPort& inSerial)
, mPendingMessageIndex(0) , mPendingMessageIndex(0)
, mCurrentRpnNumber(0xffff) , mCurrentRpnNumber(0xffff)
, mCurrentNrpnNumber(0xffff) , mCurrentNrpnNumber(0xffff)
, mActiveSensingActivated(false) , mSenderActiveSensingActivated(false)
, mLastSendMessageTime(0) , mLastMessageSentTime(0)
, mThruActivated(true) , mThruActivated(true)
, mThruFilterMode(Thru::Full) , mThruFilterMode(Thru::Full)
{ {
@ -102,15 +102,15 @@ void MidiInterface<SerialPort, Settings>::begin(Channel inChannel)
mCurrentRpnNumber = 0xffff; mCurrentRpnNumber = 0xffff;
mCurrentNrpnNumber = 0xffff; mCurrentNrpnNumber = 0xffff;
mActiveSensingActivated = false;
mLastSendMessageTime = millis();
mMessage.valid = false; mMessage.valid = false;
mMessage.type = InvalidType; mMessage.type = InvalidType;
mMessage.channel = 0; mMessage.channel = 0;
mMessage.data1 = 0; mMessage.data1 = 0;
mMessage.data2 = 0; mMessage.data2 = 0;
mSenderActiveSensingActivated = Settings::UseSenderActiveSensing;
mLastMessageSentTime = millis();
mThruFilterMode = Thru::Full; mThruFilterMode = Thru::Full;
mThruActivated = true; mThruActivated = true;
} }
@ -182,9 +182,9 @@ void MidiInterface<SerialPort, Settings>::send(MidiType inType,
{ {
sendRealTime(inType); // System Real-time and 1 byte. sendRealTime(inType); // System Real-time and 1 byte.
} }
if (mActiveSensingActivated) if (mSenderActiveSensingActivated)
mLastSendMessageTime = millis(); mLastMessageSentTime = millis();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -320,22 +320,6 @@ void MidiInterface<SerialPort, Settings>::sendPitchBend(double inPitchValue,
sendPitchBend(value, inChannel); sendPitchBend(value, inChannel);
} }
/*! \brief Send an Active Sensing message.
This message is intended to be sent
repeatedly to tell the receiver that a connection is alive. Use
of this message is optional. When initially received, the
receiver will expect to receive another Active Sensing
message each 300ms (max), and if it does not then it will
assume that the connection has been terminated.
*/
template<class Encoder, class Settings>
void MidiInterface<Encoder, Settings>::sendActiveSensing()
{
sendRealTime(ActiveSensing);
}
/*! \brief Generate and send a System Exclusive frame. /*! \brief Generate and send a System Exclusive frame.
\param inLength The size of the array to send \param inLength The size of the array to send
\param inArray The byte array containing the data to send \param inArray The byte array containing the data to send
@ -682,10 +666,10 @@ inline bool MidiInterface<SerialPort, Settings>::read(Channel inChannel)
// assume that the connection has been terminated. At // assume that the connection has been terminated. At
// termination, the receiver will turn off all voices and return to // termination, the receiver will turn off all voices and return to
// normal (non- active sensing) operation. // normal (non- active sensing) operation.
if (mActiveSensingActivated && (millis() - mLastSendMessageTime) > 250) if (mSenderActiveSensingActivated && (millis() - mLastMessageSentTime) > 250)
{ {
sendActiveSensing(); sendRealTime(ActiveSensing);
mLastSendMessageTime = millis(); mLastMessageSentTime = millis();
} }
if (inChannel >= MIDI_CHANNEL_OFF) if (inChannel >= MIDI_CHANNEL_OFF)

View File

@ -61,6 +61,17 @@ struct DefaultSettings
*/ */
static const bool HandleNullVelocityNoteOnAsNoteOff = true; static const bool HandleNullVelocityNoteOnAsNoteOff = true;
/*! Active Sensing is intended to be sent
repeatedly by the sender to tell the receiver that a connection is alive. Use
of this message is optional. When initially received, the
receiver will expect to receive another Active Sensing
message each 300ms (max), and if it does not then it will
assume that the connection has been terminated. At
termination, the receiver will turn off all voices and return to
normal (non- active sensing) operation..
*/
static const bool UseSenderActiveSensing = true;
/*! Setting this to true will make MIDI.read parse only one byte of data for each /*! Setting this to true will make MIDI.read parse only one byte of data for each
call when data is available. This can speed up your application if receiving call when data is available. This can speed up your application if receiving
a lot of traffic, but might induce MIDI Thru and treatment latency. a lot of traffic, but might induce MIDI Thru and treatment latency.