UseSenderActiveSensing & UseReceiverActiveSensing to enable/disable Active Sensing
UseSenderActiveSensing & UseReceiverActiveSensing in Settings are global switches to turn on/off ActiveSensing (and save memory)
This commit is contained in:
parent
8730ae0bde
commit
d4b692ab76
|
|
@ -235,6 +235,8 @@ public:
|
||||||
inline void turnThruOff();
|
inline void turnThruOff();
|
||||||
inline void setThruFilterMode(Thru::Mode inThruFilterMode);
|
inline void setThruFilterMode(Thru::Mode inThruFilterMode);
|
||||||
|
|
||||||
|
inline void UpdateLastSentTime();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void thruFilter(byte inChannel);
|
void thruFilter(byte inChannel);
|
||||||
|
|
||||||
|
|
@ -273,13 +275,6 @@ private:
|
||||||
private:
|
private:
|
||||||
inline StatusByte getStatus(MidiType inType,
|
inline StatusByte getStatus(MidiType inType,
|
||||||
Channel inChannel) const;
|
Channel inChannel) const;
|
||||||
|
|
||||||
inline void UpdateLastSentTime()
|
|
||||||
{
|
|
||||||
if (mSenderActiveSensingPeriodicity)
|
|
||||||
mLastMessageSentTime = Platform::now();
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
24
src/MIDI.hpp
24
src/MIDI.hpp
|
|
@ -47,6 +47,7 @@ inline MidiInterface<Transport, Settings, Platform>::MidiInterface(Transport& in
|
||||||
, mThruFilterMode(Thru::Full)
|
, mThruFilterMode(Thru::Full)
|
||||||
, mLastError(0)
|
, mLastError(0)
|
||||||
{
|
{
|
||||||
|
mSenderActiveSensingPeriodicity = Settings::SenderActiveSensingPeriodicity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Destructor for MidiInterface.
|
/*! \brief Destructor for MidiInterface.
|
||||||
|
|
@ -82,7 +83,6 @@ void MidiInterface<Transport, Settings, Platform>::begin(Channel inChannel)
|
||||||
mCurrentRpnNumber = 0xffff;
|
mCurrentRpnNumber = 0xffff;
|
||||||
mCurrentNrpnNumber = 0xffff;
|
mCurrentNrpnNumber = 0xffff;
|
||||||
|
|
||||||
mSenderActiveSensingPeriodicity = Settings::SenderActiveSensingPeriodicity;
|
|
||||||
mLastMessageSentTime = Platform::now();
|
mLastMessageSentTime = Platform::now();
|
||||||
|
|
||||||
mMessage.valid = false;
|
mMessage.valid = false;
|
||||||
|
|
@ -718,13 +718,13 @@ inline bool MidiInterface<Transport, Settings, Platform>::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 ((mSenderActiveSensingPeriodicity > 0) && (Platform::now() - mLastMessageSentTime) > mSenderActiveSensingPeriodicity)
|
if (Settings::UseSenderActiveSensing && (mSenderActiveSensingPeriodicity > 0) && (Platform::now() - mLastMessageSentTime) > mSenderActiveSensingPeriodicity)
|
||||||
{
|
{
|
||||||
sendActiveSensing();
|
sendActiveSensing();
|
||||||
mLastMessageSentTime = Platform::now();
|
mLastMessageSentTime = Platform::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mReceiverActiveSensingActivated && (mLastMessageReceivedTime + ActiveSensingTimeout < Platform::now()))
|
if (Settings::UseReceiverActiveSensing && mReceiverActiveSensingActivated && (mLastMessageReceivedTime + ActiveSensingTimeout < Platform::now()))
|
||||||
{
|
{
|
||||||
mReceiverActiveSensingActivated = false;
|
mReceiverActiveSensingActivated = false;
|
||||||
|
|
||||||
|
|
@ -741,7 +741,8 @@ inline bool MidiInterface<Transport, Settings, Platform>::read(Channel inChannel
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#ifndef RegionActiveSending
|
#ifndef RegionActiveSending
|
||||||
if (mMessage.type == ActiveSensing)
|
|
||||||
|
if (Settings::UseReceiverActiveSensing && mMessage.type == ActiveSensing)
|
||||||
{
|
{
|
||||||
// When an ActiveSensing message is received, the time keeping is activated.
|
// When an ActiveSensing message is received, the time keeping is activated.
|
||||||
// When a timeout occurs, an error message is send and time keeping ends.
|
// When a timeout occurs, an error message is send and time keeping ends.
|
||||||
|
|
@ -756,9 +757,9 @@ inline bool MidiInterface<Transport, Settings, Platform>::read(Channel inChannel
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep the time of the last received message, so we can check for the timeout
|
// Keep the time of the last received message, so we can check for the timeout
|
||||||
if (mReceiverActiveSensingActivated)
|
if (Settings::UseReceiverActiveSensing && mReceiverActiveSensingActivated)
|
||||||
mLastMessageReceivedTime = Platform::now();
|
mLastMessageReceivedTime = Platform::now();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
handleNullVelocityNoteOnAsNoteOff();
|
handleNullVelocityNoteOnAsNoteOff();
|
||||||
|
|
@ -1384,6 +1385,13 @@ inline void MidiInterface<Transport, Settings, Platform>::turnThruOff()
|
||||||
mThruFilterMode = Thru::Off;
|
mThruFilterMode = Thru::Off;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class Transport, class Settings, class Platform>
|
||||||
|
inline void MidiInterface<Transport, Settings, Platform>::UpdateLastSentTime()
|
||||||
|
{
|
||||||
|
if (Settings::UseSenderActiveSensing && mSenderActiveSensingPeriodicity)
|
||||||
|
mLastMessageSentTime = Platform::now();
|
||||||
|
}
|
||||||
|
|
||||||
/*! @} */ // End of doc group MIDI Thru
|
/*! @} */ // End of doc group MIDI Thru
|
||||||
|
|
||||||
// This method is called upon reception of a message
|
// This method is called upon reception of a message
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,18 @@ struct DefaultSettings
|
||||||
*/
|
*/
|
||||||
static const bool HandleNullVelocityNoteOnAsNoteOff = true;
|
static const bool HandleNullVelocityNoteOnAsNoteOff = true;
|
||||||
|
|
||||||
|
/*! Global switch to turn on/off sender ActiveSensing
|
||||||
|
Set to true to send ActiveSensing
|
||||||
|
Set to false will not send ActiveSensing message (will also save memory)
|
||||||
|
*/
|
||||||
|
static const bool UseSenderActiveSensing = false;
|
||||||
|
|
||||||
|
/*! Global switch to turn on/off receiver ActiveSensing
|
||||||
|
Set to true to check for message timeouts (via ErrorCallback)
|
||||||
|
Set to false will not check if chained device are still alive (if they use ActiveSensing) (will also save memory)
|
||||||
|
*/
|
||||||
|
static const bool UseReceiverActiveSensing = false;
|
||||||
|
|
||||||
/*! Active Sensing is intended to be sent
|
/*! Active Sensing is intended to be sent
|
||||||
repeatedly by the sender to tell the receiver that a connection is alive. Use
|
repeatedly by the sender to tell the receiver that a connection is alive. Use
|
||||||
of this message is optional. When initially received, the
|
of this message is optional. When initially received, the
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue