Commit Graph

75 Commits

Author SHA1 Message Date
Francois Best f6d95113f5 chore: Add test for system common messages 2022-10-08 15:23:09 +02:00
Francois Best 21a4ad23df chore: Fix build (things got lost in merge) 2022-10-08 14:50:54 +02:00
lathoub 12f05866cf return mReceiverActiveSensingActive in SensingTimeout Handler
return mReceiverActiveSensingActive in SensingTimeout Handler:
- true when all is OK and active sensing is received on time
- false when active sensing is **not** received on tome
2022-10-08 14:41:56 +02:00
lathoub 59fafdbf1a ActiveSensingTimeout has its own callback handler
removed ErrorActiveSensingTimeout
2022-10-08 14:41:56 +02:00
lathoub b82f241349 reworked ActiveSensing
reworked ActiveSensing using input from a variety of device MIDI Implementation manuals (Roland,  KORG, Yamaha) found on the internet.

Receiving ActiveSensing:
Once an Active Sensing message is received, the unit will begin monitoring the intervalbetween all subsequent messages. If there is an interval of ActiveSensingPeriodicity ms or longer betweenmessages while monitoring is active, the same processing as when All Sound Off, All Notes Off,and Reset All Controllers messages are received will be carried out. The unit will then stopmonitoring the message interval.

Sending ActiveSensing: send x ms after the last sent command
2022-10-08 14:40:45 +02:00
lathoub 350f6d1ec4 reworked active Sensing 2022-10-08 14:40:45 +02:00
Eric Sherman 4469f2aa7f uses Transport::thruActivated for initial thru state 2022-10-08 14:34:30 +02:00
Eric Sherman 1fe67bec4f makes changes requested in #232 discussion 2022-10-08 14:34:30 +02:00
Eric Sherman a6c3a48571 thru filter overhaul
* resolves #40 with franky47's proposed thru filter overhaul
* removes thru filter modes
* adds thru filter callback
* adds thru map callback
* old thru filter unit tests have been replicated with filter callbacks
* does not yet include documentation changes

I believe this implements the latest proposal for #40 and exercises
everything necessary in the unit tests, including the immutability of
`mMessage` after a thru map callback has modified the outgoing message.

The thru filter callbacks in the unit tests are not suitable for copying
and pasting by end-users due to the difference in the MIDI namespace
when setup via the unit tests vs via `MIDI_CREATE_DEFAULT_INSTANCE()`.

If the changes here are deemed suitable, I'll work on documentation.
2022-10-08 14:33:53 +02:00
Paul 663b24b0b5
fix: Updated send(midiMessage&) to better handle system real time (#250)
* updated send(midiMessage&) to better handle system real time,
sysex and other system common messages

* use fully qualified function names as requested

Co-authored-by: Element <paul-emile.element@windriver.com>
2021-11-03 15:04:52 +01:00
lathoub c9d3b9b592 no chaining for private functions, added example 2021-10-10 15:33:28 +02:00
lathoub 892f65a9ee Update MIDI.hpp 2021-10-10 12:16:15 +02:00
lathoub e1035a03f7 Update MIDI.hpp
fixed errors (return -> return *this where needed)
2021-10-10 12:13:30 +02:00
lathoub 2012e2a84a chaining for all commands, callbacks and setters 2021-10-10 12:04:08 +02:00
Francois Best d9873560ad chore: Improve coverage blind spots 2021-08-10 16:21:18 +02:00
Francois Best 7ca289d84e chore: Fix internal method casing 2021-08-06 09:35:54 +02:00
stfufane 150cecd450 Fix sendPitchBend multiplication 2020-06-08 11:39:16 +02:00
lathoub 99a981be5e thruActivated as a property of the Transport layer 2020-04-23 22:08:15 +02:00
Francois Best d600656f04 Merge branch dev into master 2020-04-20 17:09:02 +02:00
Francois Best b384278b29 chore: Ignore edge cases for coverage 2020-04-20 15:36:12 +02:00
Francois Best a9664ef4a4 fix: Use SysEx size in Settings 2020-04-17 08:15:42 +02:00
lathoub 2c657a38d1
Added support for Active Sensing and SysEx command segments (v4.4.0) (#138)
* stuff to ignore list

* Update midi_Defs.h

* added support for ActiveSensing

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.

* replaced ActiveSensing with Sender Active Sensing

Receiver active Sensing is not implemented (yet)

* added support for receiving SysEx command segments

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

* lift and shift of the Serial code into a seperate class, allowing for other serializers

lift and shift of the Serial code into a seperate class, allowing for other serializers as AppleMIDI, USBMIDI, ipMIDI, BLE-MIDI

* added Platform class to abstract millis()

* add MidiType to beginTransmission

Avoids reparsing of the stream in the transport layer, in order to get the MidiType

* active sensing defaults to false, to avoid spamming devices

* set ActiveSensing Periodicity in ms

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

* added namespace reference

* renamed Encoder -> Transport, added MidiType to beginTransmission in serialMIDI

* added callback for Message

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), added (untested) bridge example

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)

* changed based on Franky47's feedback

- 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

* return reference to Transport layer

* return a *pointer* (not a ref) to the transport layer

* mPendingMessageExpectedLength as before

mMessage.length is reset to 0 before the callback, so bring back mPendingMessageExpectedLength as before, and set mMessage.length (and not reset it)

* DefaultPlatform for Arduino

* strong typing Channel in the callbacks

* aliasing for callbacks (and default initializers

* cleanup setHandleMessage

unfortunately, not using aliases yet (too complex)

* Fixed "FML" case: fall down here with an overflown SysEx..

Splitting larger incoming messages into smaller SysEx packets - using an RrtpMidi trick:
            //   first:  0xF0 .... 0xF0
            //   midlle: 0xF7 .... 0xF0
            //   last:   0xF7 .... 0xF7

see: https://tools.ietf.org/html/rfc4695#section-3.2

(Understanding this is not part of the original MIDI spec, but does allow for receiving very very large SysEx messages on a small footprint (does require some 'handy' parsing))

SysExMaxSize in Settings can be reduced significatly (16bytes works fine - pending use case)

* + receiver ActiveSensing, + error Callback

1) Active Sensing:
Once an ActiveSensing message is received, the system checks for timeouts: if no message is received within the specified 300ms (see in _Defs), an error is set and the checks for timeout stop.

2) added a callback for errors. 2 errors are defined: parse error and ActiveSensing timeout

* cleanup of basic example

use LED_BUILTIN

* + Manufacturer System Exclusive ID (incomplete)

* + noteValues

* added SendCommon, consistent with SendRealTime

including:

sendClock, sendStart, sendStop, sendContinue, sendActiveSensing, sendSystemReset

* UseSenderActiveSensing & UseReceiverActiveSensing to enable/disable Active Sensing

UseSenderActiveSensing & UseReceiverActiveSensing in Settings are global switches to turn on/off ActiveSensing (and save memory)

* use #defined value, not the literal

* cleanup

* removed deprecated MidiFilterMode (to be removed for v5)

* getting ready for v5

* prepare for v5

* updating authors

* Removed USB examples

* added header

* removed typedef

when instanciating multiple instances of SerialMIDI, a redefinition error accors because of typing of the serial##Name.
Fix: removed the typdef, a bit harder to read, but avoided complex #ifdef

* move bridge example to other Transport mechanisms

* Update Bench.ino

* Create NoteNames.ino

demonstrate use of MIDI_NAMESPACE::NoteValues[inNote].strptr

* moved #version to MIDI.h

#version of the library does not belong in general MIDI definitions
(making midi_Defs.h as generic as possible - usable on other platforms)

* adding comment section

* shorter syntax using iif

* moved code to avoid doc clash

* added Tick (0xF9)

* Simplified NoteValues

Need need for extra index (that is the same as the noteName anyway)

* Removed Undefined_F9 (Tick) as an invalid token (so it valid now)

* removed references to USB in the test scripts

* setting the CMake env

* removed USB references

* struggling with travis

* LCOV_EXCL_LINE in sendCommon

* order of initialization

* reorder variables for initialisation

* extending platforms

* adding boards (but not the Zero)

* fixing cmake

* moved RingBuffer to SerialMock

* fix cmake removing RingBuffer

* Update CMakeLists.txt

* using bitwire operators (works on all platforms)

* Update midi_Platform.h

* removed NoteNames

* simplify test (will be rolled back later)

* Update unit-tests_MidiInput.cpp

* Update unit-tests_MidiInput.cpp

* Revert "Update midi_Platform.h"

This reverts commit bd2f6476b2.

* bring in other Platform (remove usb)

* added BaudRate

* Revert "using bitwire operators (works on all platforms)"

This reverts commit 122ebe1dc3.

* Revert "moved code to avoid doc clash"

This reverts commit ef878344cd.

* restored after very funcky commits and rollbacks (Sorry!)

* add Transport layer

* removed SerialMock test

* Update unit-tests_MidiInput.cpp

* Update unit-tests_MidiInput.cpp

* Update unit-tests_MidiInput.cpp

* Update unit-tests_MidiInput.cpp

* fixed MidiInterface<SerialMock => MidiInterface<Transport

* SerialMIDI should not aware of the channel

* Update unit-tests_MidiThru.cpp

* Update midi_Defs.h

* avoid shadow parameters and buf fix

* Update CMakeLists.txt

* Update unit-tests_MidiOutput.cpp

* Update midi_Settings.h

* Update unit-tests_MidiInput.cpp

* Update unit-tests_MidiInput.cpp

* Update unit-tests_MidiInput.cpp

* tmp removed teensy, bug fix sendCommon (unsigned, not byte)

* Update unit-tests_MidiInput.cpp

* fix for Leonardo

* Update DualMerger.ino

* adding tests_MidiInputCallbacks

* Update unit-tests_MidiInputCallbacks.cpp

* preparing to release 5.0.0

* added Alternative Pin for Serial port example

* default listen on all channel as in #96

* Update unit-tests_MidiInput.cpp

Co-authored-by: lathoub <lathoub@gmail.com>
2020-04-08 10:36:10 +02:00
Eric Bateman dac0862657 Update MIDI.hpp 2019-08-11 00:58:17 -07:00
Eric Bateman d688030c14 debugging 2019-08-11 00:34:40 -07:00
Francois Best 42b98a78cf refactor: Avoid redundant call 2018-10-11 10:33:07 +02:00
Jacek Roszkowski e486667d8a
Corrected typo: Lenght - Length 2018-06-22 20:47:13 +02:00
Jacek Roszkowski 2e8be813c4
Corrected typo: Lenght - Length 2018-06-22 20:43:21 +02:00
Francois Best 33bd77dd13 fix: Fix more sign / implicit type conversion warnings 2018-03-10 17:59:17 +01:00
Lennart 3396ec9429 fixed some warnings when compiling with -Wconversion and -Wsign-conversion 2017-07-18 10:37:49 +02:00
Francois Best 3a31a366e4 Changed def to match updates to cake library (FortySevenEffects/cake) 2017-01-07 14:40:27 +01:00
Francois Best 82f5dca265 Bumped version to 4.3.1, fixing Arduino lib file.
Removed redundant version mentions in sources.
2016-11-04 10:53:18 +01:00
Francois Best 437d5ebce0 Bump version in sources. 2016-10-30 09:50:01 +01:00
Francois Best 4eee744b35 More unreacheable code hunt. 2016-10-29 16:21:06 +02:00
Francois Best 4ab8728c67 Removed unreacheable code, inlined stuff. 2016-10-29 16:09:04 +02:00
Francois Best 597a75e638 Keep running status when not sending anything.
Fixes #61
2016-10-29 09:42:47 +02:00
Francois Best 5d3cbd1f9f #54: added overload of sendAfterTouch for poly. Deprecates sendPolyPressure. 2016-10-28 09:13:06 +02:00
Francois Best f1f0ef41ce Using new definitions for Thru. 2016-10-27 08:11:29 +02:00
Francois Best 8ebd4f9161 Cleanup & init'd thru. 2016-10-20 10:08:00 +02:00
Francois Best 5f7fa5d083 Fix #58. 2016-10-15 13:41:50 +02:00
Francois Best 300cb139e9 #54: Deprecated sending of TuneRequests with sendRealTime. 2016-10-10 14:23:50 +02:00
Francois Best 34b37f75e8 Fixed order of DataEntry bytes (MSB first). 2016-10-07 09:50:37 +02:00
Francois Best bc0308223c Initialise new attributes. 2016-10-07 00:58:35 +02:00
Francois Best 489b49b862 Fix thruFilter bug from #45. 2016-10-07 00:49:50 +02:00
Francois Best 96374a1fa1 Added RPN/NRPN sending facilities.
Needs doc, closes #37.
2016-10-07 00:38:27 +02:00
Francois Best c29dfd84d7 Added more tests & fixed #53 (sendPitchBend range). 2016-10-06 20:49:38 +02:00
Francois Best 6705d0ed81 Initialize attributes with default values. 2016-10-04 18:55:47 -07:00
Francois Best 55f91d54aa Fix float pitch bend. 2016-08-19 14:58:39 +02:00
Francois Best 219797524d Fixed MIDI.read with input channel parameter. 2016-04-03 17:58:00 +02:00
Francois Best fb693e7245 Changed license to MIT. 2015-08-13 09:03:17 +02:00
Francois Best e31d0a1910 Doc. 2014-06-11 09:33:32 +02:00