-
Notifications
You must be signed in to change notification settings - Fork 268
Added support for Active Sensing and SysEx command segments (v4.4.0) #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
From: https://www.midi.org/specifications/item/table-1-summary-of-midi-message Active Sensing. 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. At termination, the receiver will turn off all voices and return to normal (non- active sensing) operation.
Receiver active Sensing is not implemented (yet)
Very long SysEx mesaages are cut in to multiple command segments Where a normal SysEx starts with F0 and ends with F7, the first segment will start with F0 and end with F0, the middle section (optional) start with F7 and ends with F7 - the last segments starts with F7 and ends with F0
continuous-integration fails due to the use of mills() in the code, not sure how to fix it. |
… other serializers lift and shift of the Serial code into a seperate class, allowing for other serializers as AppleMIDI, USBMIDI, ipMIDI, BLE-MIDI
lift and shift all Serial code into a separate class (serialMIDI), allowing for other serialisers, such as AppleMIDI, USBMIDI, BLE-MIDI, ipMIDI The code is smaller than the standard 4.4.0 release (4108/337 vs 4126/370), no speed penalty. (Checks fails because of the use of millis() - which should be totally fine) |
@franky47 What are your plans with feat/4.4.0? |
Avoids reparsing of the stream in the transport layer, in order to get the MidiType
src/midi_Settings.h
Outdated
@@ -70,7 +70,7 @@ struct DefaultSettings | |||
termination, the receiver will turn off all voices and return to | |||
normal (non- active sensing) operation.. | |||
*/ | |||
static const bool UseSenderActiveSensing = false; | |||
static const bool UseSenderActiveSensing = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default should probably be false
to avoid spamming other devices. It can be an opt-in behaviour when disconnection detection is desired.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been thinking about it as well, some devices have it as default (Roland, and recently a Cinara box), other don't. Happy to switch it off.
Gives more control over the bool value. Typical value is 300 (ms) - an Active Sensing command is send every 300ms; or 0 (zero) to disable sending ActiveSensing
src/midi_Namespace.h
Outdated
@@ -27,7 +27,7 @@ | |||
|
|||
#pragma once | |||
|
|||
#define MIDI_NAMESPACE midi | |||
#define MIDI_NAMESPACE midi_v440 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the namespace here will break existing code that references it directly (eg: midi::ControlChange
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
before the specific callback are called, a generic mMessage callback can be fired to inform the user that 'a' message has been received.
added send(MidiMessage) for Bridge application (that convert MIDI transport x into MIDI transport y), avoiding parsing entry a stream, setting up all callback - whilst this allows for passing the content, without to much processing/parsing. Had to move mPendingMessageExpectedLenght into MidiMessage to avoid parsing the data again, just to know the size Added Bridge example (untested)
|
||
public: | ||
void begin(MIDI_NAMESPACE::Channel inChannel = 1) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably call mSerial.begin
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The opposite, the MidiInterface will call this method.
See in MIDI.hpp:
template<class Transport, class Settings, class Platform>
void MidiInterface<Transport, Settings, Platform>::begin(Channel inChannel)
{
// Initialise the Transport layer
mTransport.begin();
src/serialMIDI.h
Outdated
BEGIN_MIDI_NAMESPACE | ||
|
||
template <class SerialPort> | ||
class serialMIDI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you name it with an Uppercase first letter ? Just to be consistent with the rest of the coding style, thanks ! :)
src/midi_Settings.h
Outdated
http://projectgus.github.io/hairless-midiserial/ | ||
*/ | ||
static const long BaudRate = 31250; | ||
static const bool Use1ByteParsing = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should keep the BaudRate as a setting, as some sketches use it, even though there might be better transports, I'd like to minimize breaking changes. But that means the Settings
will have to be passed as a template argument to SerialMIDI
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that mSerial.begin
was not called :-( - so added.
Also added DefaultSerialSettings
in serialMIDI.h
Requires modification of the test scripts!
src/MIDI.hpp
Outdated
|
||
mThruFilterMode = Thru::Full; | ||
mThruActivated = true; | ||
mThruActivated = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To minimize behaviour changes, thru should stay active by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
src/MIDI.hpp
Outdated
them thru. | ||
*/ | ||
template<class Transport, class Settings, class Platform> | ||
void MidiInterface<Transport, Settings, Platform>::send(MidiMessage inMessage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should pass the message as a const ref, to avoid copies (better performance and memory usage): ::send(const MidiMessage& inMessage)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch!
- send: pass the message as a const ref, to avoid copies - add mSerial.begin (with Baudrate - added Settings) - ThruActivated defaults to true - class name serialMIDI => SerialMIDI
mMessage.length is reset to 0 before the callback, so bring back mPendingMessageExpectedLength as before, and set mMessage.length (and not reset it)
Any objection to a "Squash and Merge"? |
Added Sender Active Sensing - switch in Settings
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..