From 2685bb458b3a392745ecc17eacf864f87c3a5f9c Mon Sep 17 00:00:00 2001 From: lathoub Date: Sat, 16 May 2020 16:35:03 +0200 Subject: [PATCH] reworked active Sensing --- src/MIDI.h | 1 - src/MIDI.hpp | 6 ++---- src/midi_Settings.h | 5 ++--- src/serialMIDI.h | 3 ++- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/MIDI.h b/src/MIDI.h index d15888f..d29eb37 100644 --- a/src/MIDI.h +++ b/src/MIDI.h @@ -282,7 +282,6 @@ private: MidiMessage mMessage; unsigned long mLastMessageSentTime; unsigned long mLastMessageReceivedTime; - unsigned long mSenderActiveSensingPeriodicity; bool mReceiverActiveSensingActivated; int8_t mLastError; diff --git a/src/MIDI.hpp b/src/MIDI.hpp index 1731916..02a82b3 100644 --- a/src/MIDI.hpp +++ b/src/MIDI.hpp @@ -44,11 +44,9 @@ inline MidiInterface::MidiInterface(Transport& in , mThruFilterMode(Thru::Full) , mLastMessageSentTime(0) , mLastMessageReceivedTime(0) - , mSenderActiveSensingPeriodicity(0) , mReceiverActiveSensingActivated(false) , mLastError(0) { - mSenderActiveSensingPeriodicity = Settings::SenderActiveSensingPeriodicity; } /*! \brief Destructor for MidiInterface. @@ -720,7 +718,7 @@ inline bool MidiInterface::read(Channel inChannel // assume that the connection has been terminated. At // termination, the receiver will turn off all voices and return to // normal (non- active sensing) operation. - if (Settings::UseSenderActiveSensing && (mSenderActiveSensingPeriodicity > 0) && (Platform::now() - mLastMessageSentTime) > mSenderActiveSensingPeriodicity) + if (Settings::UseSenderActiveSensing && (Platform::now() - mLastMessageSentTime) > Settings::SenderActiveSensingPeriodicity) { sendActiveSensing(); mLastMessageSentTime = Platform::now(); @@ -1384,7 +1382,7 @@ inline void MidiInterface::turnThruOff() template inline void MidiInterface::UpdateLastSentTime() { - if (Settings::UseSenderActiveSensing && mSenderActiveSensingPeriodicity) + if (Settings::UseSenderActiveSensing) mLastMessageSentTime = Platform::now(); } diff --git a/src/midi_Settings.h b/src/midi_Settings.h index 179b773..f142593 100644 --- a/src/midi_Settings.h +++ b/src/midi_Settings.h @@ -75,6 +75,7 @@ struct DefaultSettings /*! 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) + as often as possible (1000 / SenderActiveSensingPeriodicity per second). */ static const bool UseSenderActiveSensing = false; @@ -95,10 +96,8 @@ struct DefaultSettings Typical value is 250 (ms) - an Active Sensing command is send every 250ms. (All Roland devices send Active Sensing every 250ms) - - Setting this field to 0 will disable sending MIDI active sensing. */ - static const uint16_t SenderActiveSensingPeriodicity = 0; + static const uint16_t SenderActiveSensingPeriodicity = 250; }; END_MIDI_NAMESPACE diff --git a/src/serialMIDI.h b/src/serialMIDI.h index 9bd9669..40c36d7 100644 --- a/src/serialMIDI.h +++ b/src/serialMIDI.h @@ -116,10 +116,11 @@ END_MIDI_NAMESPACE #endif /*! \brief Create an instance of the library attached to a serial port with - custom settings. + custom MIDI settings (not to be confused with modified Serial Settings, like BaudRate) @see DefaultSettings @see MIDI_CREATE_INSTANCE */ #define MIDI_CREATE_CUSTOM_INSTANCE(Type, SerialPort, Name, Settings) \ MIDI_NAMESPACE::SerialMIDI serial##Name(SerialPort);\ MIDI_NAMESPACE::MidiInterface, Settings> Name((MIDI_NAMESPACE::SerialMIDI&)serial##Name); +