Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 100 commits into from
Apr 8, 2020
Merged

Conversation

lathoub
Copy link
Collaborator

@lathoub lathoub commented Feb 4, 2020

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..

lathoub added 5 commits August 18, 2019 11:38
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
@lathoub
Copy link
Collaborator Author

lathoub commented Feb 10, 2020

continuous-integration fails due to the use of mills() in the code, not sure how to fix it.

@lathoub lathoub changed the title Feat/4.4.0 Added support for Active Sensing and SysEx command segments Feb 10, 2020
@lathoub lathoub changed the title Added support for Active Sensing and SysEx command segments Added support for Active Sensing and SysEx command segments (v4.4.0) Feb 10, 2020
… other serializers

lift and shift of the Serial code into a seperate class, allowing for other serializers as AppleMIDI, USBMIDI, ipMIDI, BLE-MIDI
@lathoub
Copy link
Collaborator Author

lathoub commented Mar 4, 2020

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)

@lathoub
Copy link
Collaborator Author

lathoub commented Mar 4, 2020

@franky47 What are your plans with feat/4.4.0?

@franky47 franky47 mentioned this pull request Mar 4, 2020
lathoub added 2 commits March 5, 2020 19:58
Avoids reparsing of the stream in the transport layer, in order to get the MidiType
@@ -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;
Copy link
Member

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.

Copy link
Collaborator Author

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.

lathoub added 3 commits March 7, 2020 08:37
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
@@ -27,7 +27,7 @@

#pragma once

#define MIDI_NAMESPACE midi
#define MIDI_NAMESPACE midi_v440
Copy link
Member

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)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

lathoub added 3 commits March 9, 2020 09:00
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)
{
Copy link
Member

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 ?

Copy link
Collaborator Author

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
Copy link
Member

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 ! :)

http://projectgus.github.io/hairless-midiserial/
*/
static const long BaudRate = 31250;
static const bool Use1ByteParsing = false;
Copy link
Member

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.

Copy link
Collaborator Author

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;
Copy link
Member

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.

Copy link
Collaborator Author

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)
Copy link
Member

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)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

lathoub added 7 commits March 11, 2020 22:46
- 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)
@lathoub
Copy link
Collaborator Author

lathoub commented Mar 30, 2020

Any objection to a "Squash and Merge"?

@franky47 franky47 merged commit 2c657a3 into FortySevenEffects:feat/4.4.0 Apr 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants