From 128990fe0d40fe15cd6c82accb19e60abe100336 Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Fri, 24 Apr 2020 07:10:22 +0200 Subject: [PATCH 01/33] bumped to 1.1.1, thruActivated defaults to false --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 5739ba2..9c03fcf 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=USB-MIDI -version=1.1.0 +version=1.1.1 author=lathoub maintainer=lathoub sentence=USB-MIDI I/Os for Arduino From 68070f57f730b342965d9796b636106dc933654b Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Fri, 24 Apr 2020 07:22:33 +0200 Subject: [PATCH 02/33] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 39476e5..fd24bcd 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ # Arduino USB-MIDI Transport +[![GitHub version](https://badge.fury.io/gh/lathoub%2FArduino-USBMIDI.svg)](https://badge.fury.io/gh/lathoub%2FArduino-USBMIDI) + This library implements the USB-MIDI transport layer for the [FortySevenEffects Arduino MIDI Library](https://github.com/FortySevenEffects/arduino_midi_library) ## Installation From 3664dd2c0979cc81c513b9f40e071fe98eb130ca Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Sat, 25 Apr 2020 09:44:28 +0200 Subject: [PATCH 03/33] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index fd24bcd..deed7bf 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,9 @@ This library implements the USB-MIDI transport layer for the [FortySevenEffects Arduino MIDI Library](https://github.com/FortySevenEffects/arduino_midi_library) ## Installation + +Screenshot 2020-04-25 at 09 42 19 + This library depends on the [Arduino MIDI Library](https://github.com/FortySevenEffects/arduino_midi_library) and [Arduino's MIDIUSB](https://github.com/arduino-libraries/MIDIUSB). When installing this library from the Arduino IDE, both will be downloaded and installed in the same directory as this library. (Thanks to the `depends` clause in `library.properties`) From f192a722e03fcf524a903e466dffb5c8eaf251b0 Mon Sep 17 00:00:00 2001 From: lathoub Date: Sun, 26 Apr 2020 17:21:14 +0200 Subject: [PATCH 04/33] added thruActivated, as per MIDI library v5.0.1 --- src/USB-MIDI.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/USB-MIDI.h b/src/USB-MIDI.h index e6ddfcd..9f6bf4f 100644 --- a/src/USB-MIDI.h +++ b/src/USB-MIDI.h @@ -53,6 +53,9 @@ class usbMidiTransport }; protected: + + static const bool thruActivated = false; + void begin() { mTxIndex = 0; From 706725da132201155d6ff44db5bef8cf91b7dd91 Mon Sep 17 00:00:00 2001 From: lathoub Date: Sun, 26 Apr 2020 17:21:47 +0200 Subject: [PATCH 05/33] bumper version to 1.1.2 --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 9c03fcf..a1b75c5 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=USB-MIDI -version=1.1.1 +version=1.1.2 author=lathoub maintainer=lathoub sentence=USB-MIDI I/Os for Arduino From d4196961c28a8723b5460b8d168e488f90781da9 Mon Sep 17 00:00:00 2001 From: lathoub Date: Sun, 10 May 2020 21:29:46 +0200 Subject: [PATCH 06/33] remove friend declaration to allow for custom settings --- src/USB-MIDI.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/USB-MIDI.h b/src/USB-MIDI.h index 9f6bf4f..ce24344 100644 --- a/src/USB-MIDI.h +++ b/src/USB-MIDI.h @@ -32,8 +32,6 @@ BEGIN_USBMIDI_NAMESPACE class usbMidiTransport { - friend class MIDI_NAMESPACE::MidiInterface; - private: byte mTxBuffer[4]; size_t mTxIndex; @@ -52,7 +50,7 @@ class usbMidiTransport this->cableNumber = cableNumber; }; -protected: +public: static const bool thruActivated = false; @@ -171,6 +169,8 @@ class usbMidiTransport }; }; +END_USBMIDI_NAMESPACE + /*! \brief */ #define USBMIDI_CREATE_INSTANCE(CableNr, Name) \ @@ -179,5 +179,3 @@ class usbMidiTransport #define USBMIDI_CREATE_DEFAULT_INSTANCE() \ USBMIDI_CREATE_INSTANCE(0, MIDI) - -END_USBMIDI_NAMESPACE From fa3415a2fe79fa4c0d90e4b727854a765ac8f6ef Mon Sep 17 00:00:00 2001 From: lathoub Date: Sun, 10 May 2020 21:29:54 +0200 Subject: [PATCH 07/33] Create ActiveSensing.ino --- examples/ActiveSensing/ActiveSensing.ino | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 examples/ActiveSensing/ActiveSensing.ino diff --git a/examples/ActiveSensing/ActiveSensing.ino b/examples/ActiveSensing/ActiveSensing.ino new file mode 100644 index 0000000..8f5c2cd --- /dev/null +++ b/examples/ActiveSensing/ActiveSensing.ino @@ -0,0 +1,33 @@ +#include + +/// + +struct MyMIDISettings : public MIDI_NAMESPACE::DefaultSettings +{ + // When setting UseSenderActiveSensing to true, MIDI.read() *must* be called + // as often as possible (1000 / SenderActiveSensingPeriodicity per second). + static const bool UseSenderActiveSensing = false; +}; + +USBMIDI_NAMESPACE::usbMidiTransport usbMIDI(0); +MIDI_NAMESPACE::MidiInterface MIDI((USBMIDI_NAMESPACE::usbMidiTransport&)usbMIDI); + +unsigned long t1 = millis(); + +void setup() +{ + pinMode(LED_BUILTIN, OUTPUT); + + MIDI.begin(1); +} + +void loop() +{ + MIDI.read(); + + if ((millis() - t1) > 1000) + { + t1 = millis(); + MIDI.sendNoteOn(42, 55, 1); + } +} From e7d9ff6305ae2a85102e399f670269befeae2239 Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Sat, 16 May 2020 07:48:25 +0200 Subject: [PATCH 08/33] Added ArduBadge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index deed7bf..cfd8474 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Arduino USB-MIDI Transport -[![GitHub version](https://badge.fury.io/gh/lathoub%2FArduino-USBMIDI.svg)](https://badge.fury.io/gh/lathoub%2FArduino-USBMIDI) +[![arduino-library-badge](https://www.ardu-badge.com/badge/USB-MIDI.svg?)](https://www.ardu-badge.com/USB-MIDI)[![GitHub version](https://badge.fury.io/gh/lathoub%2FArduino-USBMIDI.svg)](https://badge.fury.io/gh/lathoub%2FArduino-USBMIDI) This library implements the USB-MIDI transport layer for the [FortySevenEffects Arduino MIDI Library](https://github.com/FortySevenEffects/arduino_midi_library) From 647cf8a3ee8348ac86e1c1171a13a5f1d7d6f110 Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Fri, 11 Sep 2020 22:39:08 +0200 Subject: [PATCH 09/33] send only SysEx send only, receive in // example --- examples/SysEx/SysEx.ino | 20 -------- examples/SysExReceive/SysExReceive.ino | 69 ++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 20 deletions(-) create mode 100644 examples/SysExReceive/SysExReceive.ino diff --git a/examples/SysEx/SysEx.ino b/examples/SysEx/SysEx.ino index 07838d6..6a9471e 100644 --- a/examples/SysEx/SysEx.ino +++ b/examples/SysEx/SysEx.ino @@ -25,13 +25,8 @@ unsigned long t0 = millis(); // ----------------------------------------------------------------------------- void setup() { - Serial.begin(115200); - while (!Serial); - // Listen for MIDI messages on channel 1 MIDI.begin(1); - - MIDI.setHandleSystemExclusive(OnMidiSysEx); } // ----------------------------------------------------------------------------- @@ -52,18 +47,3 @@ void loop() MIDI.sendSysEx(sizeof(sysex14), sysex14, true); } } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void OnMidiSysEx(byte* data, unsigned length) { - Serial.print(F("SYSEX: (")); - Serial.print(length); - Serial.print(F(" bytes) ")); - for (uint16_t i = 0; i < length; i++) - { - Serial.print(data[i], HEX); - Serial.print(" "); - } - Serial.println(); -} diff --git a/examples/SysExReceive/SysExReceive.ino b/examples/SysExReceive/SysExReceive.ino new file mode 100644 index 0000000..07838d6 --- /dev/null +++ b/examples/SysExReceive/SysExReceive.ino @@ -0,0 +1,69 @@ +#include + +byte sysex14[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0x4D, 0x20, 0x20, 0x38, 0x39, 0x37, 0x33, 0x50, 0xF7 }; +byte sysex15[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0x4D, 0x20, 0x20, 0x38, 0x39, 0x37, 0x33, 0x50, 0x4D, 0xF7 }; +byte sysex16[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0x4D, 0x20, 0x20, 0x38, 0x39, 0x37, 0x33, 0x32, 0x50, 0x4D, 0xF7 }; +byte sysexBig[] = { 0xF0, 0x41, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, + 0x7a, + + 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0xF7 + }; + +USBMIDI_CREATE_DEFAULT_INSTANCE(); + +unsigned long t0 = millis(); + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void setup() +{ + Serial.begin(115200); + while (!Serial); + + // Listen for MIDI messages on channel 1 + MIDI.begin(1); + + MIDI.setHandleSystemExclusive(OnMidiSysEx); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void loop() +{ + // Listen to incoming notes + MIDI.read(); + + // send a note every second + // (dont cáll delay(1000) as it will stall the pipeline) + if ((millis() - t0) > 1000) + { + t0 = millis(); + // Serial.print(F("."); + + MIDI.sendSysEx(sizeof(sysex14), sysex14, true); + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void OnMidiSysEx(byte* data, unsigned length) { + Serial.print(F("SYSEX: (")); + Serial.print(length); + Serial.print(F(" bytes) ")); + for (uint16_t i = 0; i < length; i++) + { + Serial.print(data[i], HEX); + Serial.print(" "); + } + Serial.println(); +} From f41689f81a48b534a9e7ec9b550c8fc04c67e6b4 Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Fri, 11 Sep 2020 22:44:13 +0200 Subject: [PATCH 10/33] Update SysEx.ino --- examples/SysEx/SysEx.ino | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/SysEx/SysEx.ino b/examples/SysEx/SysEx.ino index 6a9471e..abddf12 100644 --- a/examples/SysEx/SysEx.ino +++ b/examples/SysEx/SysEx.ino @@ -42,7 +42,6 @@ void loop() if ((millis() - t0) > 1000) { t0 = millis(); - // Serial.print(F("."); MIDI.sendSysEx(sizeof(sysex14), sysex14, true); } From 8c6af0117a45e263e6905d95a295ae5bd8eff0a8 Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Fri, 11 Sep 2020 22:44:38 +0200 Subject: [PATCH 11/33] Update SysEx.ino --- examples/SysEx/SysEx.ino | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/SysEx/SysEx.ino b/examples/SysEx/SysEx.ino index abddf12..910e53e 100644 --- a/examples/SysEx/SysEx.ino +++ b/examples/SysEx/SysEx.ino @@ -37,8 +37,7 @@ void loop() // Listen to incoming notes MIDI.read(); - // send a note every second - // (dont cáll delay(1000) as it will stall the pipeline) + // send a SysEx every second if ((millis() - t0) > 1000) { t0 = millis(); From 7883f8dda75e8ff64c1ae3d04736d726b183cf85 Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Sat, 19 Sep 2020 06:57:43 +0200 Subject: [PATCH 12/33] Update USB-MIDI_defs.h added MidiType:: to each of the types to prevent ambiguities with user defined types (Issue #2 by @Sanotronics) --- src/USB-MIDI_defs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/USB-MIDI_defs.h b/src/USB-MIDI_defs.h index 7010a45..97a8827 100644 --- a/src/USB-MIDI_defs.h +++ b/src/USB-MIDI_defs.h @@ -32,9 +32,9 @@ using namespace MIDI_NAMESPACE; // 4 USB-MIDI Event Packets // Table 4-1: Code Index Number Classifications -static uint8_t type2cin[][2] = { {InvalidType,0}, {NoteOff,8}, {NoteOn,9}, {AfterTouchPoly,0xA}, {ControlChange,0xB}, {ProgramChange,0xC}, {AfterTouchChannel,0xD}, {PitchBend,0xE} }; +static uint8_t type2cin[][2] = { {MidiType::InvalidType,0}, {MidiType::NoteOff,8}, {MidiType::NoteOn,9}, {MidiType::AfterTouchPoly,0xA}, {MidiType::ControlChange,0xB}, {MidiType::ProgramChange,0xC}, {MidiType::AfterTouchChannel,0xD}, {MidiType::PitchBend,0xE} }; -static uint8_t system2cin[][2] = { {SystemExclusive,0}, {TimeCodeQuarterFrame,2}, {SongPosition,3}, {SongSelect,2}, {0,0}, {0,0}, {TuneRequest,5}, {SystemExclusiveEnd,0}, {Clock,0xF}, {0,0}, {Start,0xF}, {Continue,0xF}, {Stop,0xF}, {0,0}, {ActiveSensing,0xF}, {SystemReset,0xF} }; +static uint8_t system2cin[][2] = { {MidiType::SystemExclusive,0}, {MidiType::TimeCodeQuarterFrame,2}, {MidiType::SongPosition,3}, {MidiType::SongSelect,2}, {0,0}, {0,0}, {MidiType::TuneRequest,5}, {MidiType::SystemExclusiveEnd,0}, {MidiType::Clock,0xF}, {0,0}, {MidiType::Start,0xF}, {MidiType::Continue,0xF}, {MidiType::Stop,0xF}, {0,0}, {MidiType::ActiveSensing,0xF}, {MidiType::SystemReset,0xF} }; static byte cin2Len[][2] = { {0,0}, {1,0}, {2,2}, {3,3}, {4,0}, {5,0}, {6,0}, {7,0}, {8,3}, {9,3}, {10,3}, {11,3}, {12,2}, {13,2}, {14,3}, {15,1} }; From a36826da0dc2ee0b2e13bfa0793fcaf76b194864 Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Fri, 25 Sep 2020 21:17:59 +0200 Subject: [PATCH 13/33] Update SysEx.ino added more SysEx sizes (related to #170 in https://github.com/FortySevenEffects/arduino_midi_library/issues/170) --- examples/SysEx/SysEx.ino | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/examples/SysEx/SysEx.ino b/examples/SysEx/SysEx.ino index 910e53e..33e209b 100644 --- a/examples/SysEx/SysEx.ino +++ b/examples/SysEx/SysEx.ino @@ -1,5 +1,15 @@ #include +byte sysex4[] = { 0xF0, 0x43, 0x20, 0xF7 }; +byte sysex5[] = { 0xF0, 0x43, 0x20, 0x7E, 0xF7 }; +byte sysex6[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0xF7 }; +byte sysex7[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0x4D, 0xF7 }; +byte sysex8[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0x4D, 0x20, 0xF7 }; +byte sysex9[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0x4D, 0x20, 0x20, 0xF7 }; +byte sysex10[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0x4D, 0x20, 0x20, 0x38, 0xF7 }; +byte sysex11[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0x4D, 0x20, 0x20, 0x38, 0x39, 0xF7 }; +byte sysex12[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0x4D, 0x20, 0x20, 0x38, 0x39, 0x37, 0xF7 }; +byte sysex13[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0x4D, 0x20, 0x20, 0x38, 0x39, 0x37, 0x33, 0xF7 }; byte sysex14[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0x4D, 0x20, 0x20, 0x38, 0x39, 0x37, 0x33, 0x50, 0xF7 }; byte sysex15[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0x4D, 0x20, 0x20, 0x38, 0x39, 0x37, 0x33, 0x50, 0x4D, 0xF7 }; byte sysex16[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0x4D, 0x20, 0x20, 0x38, 0x39, 0x37, 0x33, 0x32, 0x50, 0x4D, 0xF7 }; @@ -38,10 +48,10 @@ void loop() MIDI.read(); // send a SysEx every second - if ((millis() - t0) > 1000) + if ((millis() - t0) > 100) { t0 = millis(); - MIDI.sendSysEx(sizeof(sysex14), sysex14, true); + MIDI.sendSysEx(sizeof(sysex11), sysex11, true); } -} +} \ No newline at end of file From 1548cc295c32e6b8b086d737ad38293911299982 Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Sat, 26 Sep 2020 12:07:28 +0200 Subject: [PATCH 14/33] Update USB-MIDI.h decorate transport name with underscores to avoid name clash (on Teensy) --- src/USB-MIDI.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/USB-MIDI.h b/src/USB-MIDI.h index ce24344..dabe47d 100644 --- a/src/USB-MIDI.h +++ b/src/USB-MIDI.h @@ -174,8 +174,8 @@ END_USBMIDI_NAMESPACE /*! \brief */ #define USBMIDI_CREATE_INSTANCE(CableNr, Name) \ - USBMIDI_NAMESPACE::usbMidiTransport usb##Name(CableNr);\ - MIDI_NAMESPACE::MidiInterface Name((USBMIDI_NAMESPACE::usbMidiTransport&)usb##Name); + USBMIDI_NAMESPACE::usbMidiTransport __usb##Name(CableNr);\ + MIDI_NAMESPACE::MidiInterface Name((USBMIDI_NAMESPACE::usbMidiTransport&)__usb##Name); #define USBMIDI_CREATE_DEFAULT_INSTANCE() \ USBMIDI_CREATE_INSTANCE(0, MIDI) From 0732da7a8f1f5a9688f4ce9eabe43f88bfefbc8a Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Sat, 26 Sep 2020 12:58:02 +0200 Subject: [PATCH 15/33] Update README.md add test for Teensy 4.1 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index cfd8474..cf9b259 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ will create a instance named `usbMIDI2` (and underlaying MIDI object `MIDI2`) an ## Tested boards/modules - Arduino Leonardo +- Teensy 4.1 ## Memory usage The library does not add additional buffers and is extremely efficiant and has a small memory footprint. From b893ca0fcd8d476f8c566fd4317b48295eaf357e Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Sat, 26 Sep 2020 13:01:07 +0200 Subject: [PATCH 16/33] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cf9b259..85a1b6f 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ void loop() { MIDI.read(); ``` -will create a instance named `usbMIDI` and is by default connected to cable number 0 - and listens to incoming MIDI on channel 1. +will create a instance named `MIDI` (transport instance named `__usbMIDI`) and is by default connected to cable number 0 - and listens to incoming MIDI on channel 1. ### Modified ```cpp @@ -36,7 +36,7 @@ will create a instance named `usbMIDI` and is by default connected to cable numb ... USBMIDI_CREATE_INSTANCE(4); ``` -will create a instance named `usbMIDI` and is connected to cable number 4. +will create a instance named `MIDI` (transport instance named `__usbMIDI`) and is connected to cable number 4. ### Advanced ```cpp From f02ce0e06bab7e80b3b23126f8aac972c82b9fa3 Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Sat, 26 Sep 2020 17:20:01 +0200 Subject: [PATCH 17/33] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 85a1b6f..2d78d76 100644 --- a/README.md +++ b/README.md @@ -42,8 +42,8 @@ will create a instance named `MIDI` (transport instance named `__usbMIDI`) and i ```cpp #include ... -USBMIDI_NAMESPACE::usbMidiTransport usbMIDI(CableNr); -MIDI_NAMESPACE::MidiInterface MIDI((USBMIDI_NAMESPACE::usbMidiTransport&)usbMIDI); +USBMIDI_NAMESPACE::usbMidiTransport usbMIDI2(5); +MIDI_NAMESPACE::MidiInterface MIDI2((USBMIDI_NAMESPACE::usbMidiTransport&)usbMIDI2); ``` will create a instance named `usbMIDI2` (and underlaying MIDI object `MIDI2`) and is by default connected to cable number 5. From 9d95950405262845f98daa51b405b788bd9ad1cf Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Sat, 26 Sep 2020 19:22:33 +0200 Subject: [PATCH 18/33] Update SysEx.ino added NoteOn / NoteOff --- examples/SysEx/SysEx.ino | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/examples/SysEx/SysEx.ino b/examples/SysEx/SysEx.ino index 33e209b..5c24808 100644 --- a/examples/SysEx/SysEx.ino +++ b/examples/SysEx/SysEx.ino @@ -29,6 +29,7 @@ byte sysexBig[] = { 0xF0, 0x41, USBMIDI_CREATE_DEFAULT_INSTANCE(); unsigned long t0 = millis(); +unsigned long t1 = millis(); // ----------------------------------------------------------------------------- // @@ -47,11 +48,20 @@ void loop() // Listen to incoming notes MIDI.read(); - // send a SysEx every second + // send 10 NoteOn 7 SysEx per second if ((millis() - t0) > 100) { t0 = millis(); + MIDI.sendNoteOn(27, 55, 1); MIDI.sendSysEx(sizeof(sysex11), sysex11, true); } + + // send NoteOff every 750ms + if ((millis() - t1) > 750) + { + t1 = millis(); + + MIDI.sendNoteOff(27, 55, 1); + } } \ No newline at end of file From 5e6fdef2f90e025b13f194e4e27abc8eecd63b53 Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Sat, 26 Sep 2020 19:50:47 +0200 Subject: [PATCH 19/33] added Teensy 4.1 MIDIx4 example --- examples/SysEx_Teensy4.1/SysEx_Teensy4.1.ino | 62 ++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 examples/SysEx_Teensy4.1/SysEx_Teensy4.1.ino diff --git a/examples/SysEx_Teensy4.1/SysEx_Teensy4.1.ino b/examples/SysEx_Teensy4.1/SysEx_Teensy4.1.ino new file mode 100644 index 0000000..6f12d86 --- /dev/null +++ b/examples/SysEx_Teensy4.1/SysEx_Teensy4.1.ino @@ -0,0 +1,62 @@ +#include + +byte sysex4[] = { 0xF0, 0x43, 0x20, 0xF7 }; +byte sysex5[] = { 0xF0, 0x43, 0x20, 0x7E, 0xF7 }; +byte sysex6[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0xF7 }; +byte sysex7[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0x4D, 0xF7 }; +byte sysex8[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0x4D, 0x20, 0xF7 }; +byte sysex9[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0x4D, 0x20, 0x20, 0xF7 }; +byte sysex10[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0x4D, 0x20, 0x20, 0x38, 0xF7 }; +byte sysex11[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0x4D, 0x20, 0x20, 0x38, 0x39, 0xF7 }; +byte sysex12[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0x4D, 0x20, 0x20, 0x38, 0x39, 0x37, 0xF7 }; +byte sysex13[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0x4D, 0x20, 0x20, 0x38, 0x39, 0x37, 0x33, 0xF7 }; +byte sysex14[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0x4D, 0x20, 0x20, 0x38, 0x39, 0x37, 0x33, 0x50, 0xF7 }; +byte sysex15[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0x4D, 0x20, 0x20, 0x38, 0x39, 0x37, 0x33, 0x50, 0x4D, 0xF7 }; +byte sysex16[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0x4D, 0x20, 0x20, 0x38, 0x39, 0x37, 0x33, 0x32, 0x50, 0x4D, 0xF7 }; +byte sysexBig[] = { 0xF0, 0x41, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, + 0x7a, + + 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0xF7 + }; + +// Make sure the USB-TYPE is set to MIDIx4 in Tools +USBMIDI_CREATE_INSTANCE(0, MIDI1) // Cable 0 +USBMIDI_CREATE_INSTANCE(1, MIDI2) // Cable 1 + +unsigned long t0 = millis(); + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void setup() +{ + MIDI1.begin(1); + MIDI2.begin(1); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void loop() +{ + // Listen to incoming notes + MIDI1.read(); + MIDI2.read(); + + // send 10 SysEx per second + if ((millis() - t0) > 100) + { + t0 = millis(); + + MIDI1.sendSysEx(sizeof(sysex11), sysex11, true); + MIDI2.sendSysEx(sizeof(sysex11), sysex11, true); + } + +} \ No newline at end of file From 527edfbaeaa6e351e0ac05dcea6c3aa2ebc19aaf Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Sat, 26 Sep 2020 19:55:21 +0200 Subject: [PATCH 20/33] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2d78d76..6617d85 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ will create a instance named `usbMIDI2` (and underlaying MIDI object `MIDI2`) an ## Tested boards/modules - Arduino Leonardo -- Teensy 4.1 +- Teensy 4.1 (incl MIDI, MIDIx4 and MIDIx16) ## Memory usage The library does not add additional buffers and is extremely efficiant and has a small memory footprint. From 16da6958794b0caa0d60894b5c0cc0dbb87f5790 Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Sat, 26 Sep 2020 19:55:51 +0200 Subject: [PATCH 21/33] Update library.properties bumped version --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index a1b75c5..952cf4f 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=USB-MIDI -version=1.1.2 +version=1.1.3 author=lathoub maintainer=lathoub sentence=USB-MIDI I/Os for Arduino From 081e6080fcd847745eb2d4c3fec7914f95cf07a4 Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Sun, 4 Oct 2020 10:24:29 +0200 Subject: [PATCH 22/33] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 6617d85..999ff65 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,10 @@ will create a instance named `usbMIDI2` (and underlaying MIDI object `MIDI2`) an - Arduino Leonardo - Teensy 4.1 (incl MIDI, MIDIx4 and MIDIx16) +## In development +- Arduino NANO 33 BLE +- nRF52832 Bluefruit Feather + ## Memory usage The library does not add additional buffers and is extremely efficiant and has a small memory footprint. From e4be95b76320dabc283ebd85406aacfd5606ff27 Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Sun, 4 Oct 2020 10:24:59 +0200 Subject: [PATCH 23/33] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 999ff65..b805313 100644 --- a/README.md +++ b/README.md @@ -47,11 +47,11 @@ MIDI_NAMESPACE::MidiInterface MIDI2((USBMID ``` will create a instance named `usbMIDI2` (and underlaying MIDI object `MIDI2`) and is by default connected to cable number 5. -## Tested boards/modules +## Tested boards / modules - Arduino Leonardo - Teensy 4.1 (incl MIDI, MIDIx4 and MIDIx16) -## In development +### Boards / modules in development - Arduino NANO 33 BLE - nRF52832 Bluefruit Feather From b85cc5f4974f409b0633511a8bcc982455eeafac Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Sun, 4 Oct 2020 10:25:14 +0200 Subject: [PATCH 24/33] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b805313..0bc1093 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ will create a instance named `usbMIDI2` (and underlaying MIDI object `MIDI2`) an - Arduino Leonardo - Teensy 4.1 (incl MIDI, MIDIx4 and MIDIx16) -### Boards / modules in development +### Boards / modules in development (help needed) - Arduino NANO 33 BLE - nRF52832 Bluefruit Feather From 7b97993eed5abb73de71f02352630efad8d44e37 Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Sun, 18 Oct 2020 07:49:01 +0200 Subject: [PATCH 25/33] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0bc1093..ec3c433 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Arduino USB-MIDI Transport -[![arduino-library-badge](https://www.ardu-badge.com/badge/USB-MIDI.svg?)](https://www.ardu-badge.com/USB-MIDI)[![GitHub version](https://badge.fury.io/gh/lathoub%2FArduino-USBMIDI.svg)](https://badge.fury.io/gh/lathoub%2FArduino-USBMIDI) +[![arduino-library-badge](https://www.ardu-badge.com/badge/USB-MIDI.svg?)](https://www.ardu-badge.com/USB-MIDI) [![GitHub version](https://badge.fury.io/gh/lathoub%2FArduino-USBMIDI.svg)](https://badge.fury.io/gh/lathoub%2FArduino-USBMIDI) This library implements the USB-MIDI transport layer for the [FortySevenEffects Arduino MIDI Library](https://github.com/FortySevenEffects/arduino_midi_library) From cc28002b61a59d70a31c2d04dffd11eb1a644dbe Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Sun, 6 Dec 2020 20:18:48 +0100 Subject: [PATCH 26/33] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ec3c433..11347ba 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Arduino USB-MIDI Transport [![arduino-library-badge](https://www.ardu-badge.com/badge/USB-MIDI.svg?)](https://www.ardu-badge.com/USB-MIDI) [![GitHub version](https://badge.fury.io/gh/lathoub%2FArduino-USBMIDI.svg)](https://badge.fury.io/gh/lathoub%2FArduino-USBMIDI) -This library implements the USB-MIDI transport layer for the [FortySevenEffects Arduino MIDI Library](https://github.com/FortySevenEffects/arduino_midi_library) +This library implements the USB-MIDI transport layer for the [FortySevenEffects Arduino MIDI Library](https://github.com/FortySevenEffects/arduino_midi_library) and uses the underlying [Arduino MIDIUSB](https://github.com/arduino-libraries/MIDIUSB) library (so only devices working with MIDIUSB, will work here). ## Installation From da85b845f594c660998bb1169a9817860f17914f Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Mon, 21 Dec 2020 22:36:33 +0100 Subject: [PATCH 27/33] Update README.md remove separate version badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 11347ba..1b84c20 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Arduino USB-MIDI Transport -[![arduino-library-badge](https://www.ardu-badge.com/badge/USB-MIDI.svg?)](https://www.ardu-badge.com/USB-MIDI) [![GitHub version](https://badge.fury.io/gh/lathoub%2FArduino-USBMIDI.svg)](https://badge.fury.io/gh/lathoub%2FArduino-USBMIDI) +[![arduino-library-badge](https://www.ardu-badge.com/badge/USB-MIDI.svg?)](https://www.ardu-badge.com/USB-MIDI) This library implements the USB-MIDI transport layer for the [FortySevenEffects Arduino MIDI Library](https://github.com/FortySevenEffects/arduino_midi_library) and uses the underlying [Arduino MIDIUSB](https://github.com/arduino-libraries/MIDIUSB) library (so only devices working with MIDIUSB, will work here). From ae8b31cb155ddd6350fd3e957cfc396722dea2dd Mon Sep 17 00:00:00 2001 From: frensing <61296674+frensing@users.noreply.github.com> Date: Mon, 1 Feb 2021 23:34:25 +0100 Subject: [PATCH 28/33] Update README.md Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1b84c20..7a774dd 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ will create a instance named `usbMIDI2` (and underlaying MIDI object `MIDI2`) an - nRF52832 Bluefruit Feather ## Memory usage -The library does not add additional buffers and is extremely efficiant and has a small memory footprint. +The library does not add additional buffers and is extremely efficient and has a small memory footprint. ## Other Transport protocols: The libraries below the same calling mechanism (API), making it easy to interchange the transport layer. From bd2f580309cbf7112e8c9981cf201d2a74f4e16d Mon Sep 17 00:00:00 2001 From: Levi Kennedy Date: Wed, 5 May 2021 23:05:09 -0500 Subject: [PATCH 29/33] Add custom instance --- src/USB-MIDI.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/USB-MIDI.h b/src/USB-MIDI.h index dabe47d..daafe96 100644 --- a/src/USB-MIDI.h +++ b/src/USB-MIDI.h @@ -177,5 +177,9 @@ END_USBMIDI_NAMESPACE USBMIDI_NAMESPACE::usbMidiTransport __usb##Name(CableNr);\ MIDI_NAMESPACE::MidiInterface Name((USBMIDI_NAMESPACE::usbMidiTransport&)__usb##Name); +#define USBMIDI_CREATE_CUSTOM_INSTANCE(CableNr, Name, Settings) \ + USBMIDI_NAMESPACE::usbMidiTransport __usb##Name(CableNr);\ + MIDI_NAMESPACE::MidiInterface Name((USBMIDI_NAMESPACE::usbMidiTransport&)__usb##Name); + #define USBMIDI_CREATE_DEFAULT_INSTANCE() \ USBMIDI_CREATE_INSTANCE(0, MIDI) From 320d1278c369ca257702d228117148a613d3f387 Mon Sep 17 00:00:00 2001 From: Yuuichi Akagawa Date: Thu, 6 May 2021 22:31:12 +0900 Subject: [PATCH 30/33] Fixed incorrect CIN when sending system messages --- src/USB-MIDI.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/USB-MIDI.h b/src/USB-MIDI.h index dabe47d..ed5f5bb 100644 --- a/src/USB-MIDI.h +++ b/src/USB-MIDI.h @@ -74,7 +74,7 @@ class usbMidiTransport else { // Only System messages cin = system2cin[status & 0x0F][1]; - mPacket.header = MAKEHEADER(cableNumber, 0x04); + mPacket.header = MAKEHEADER(cableNumber, cin); } mPacket.byte1 = mPacket.byte2 = mPacket.byte3 = 0; From cf600cc83ed43c1e93f1fd1ee2d9c84ce7c9b8ff Mon Sep 17 00:00:00 2001 From: lathoub Date: Fri, 28 May 2021 21:07:13 +0200 Subject: [PATCH 31/33] added end() method Anticipating the end() method being called by the underlying MIDI library --- src/USB-MIDI.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/USB-MIDI.h b/src/USB-MIDI.h index ed5f5bb..06624d0 100644 --- a/src/USB-MIDI.h +++ b/src/USB-MIDI.h @@ -61,6 +61,10 @@ class usbMidiTransport mRxLength = 0; }; + void end() + { + } + bool beginTransmission(MidiType status) { mTxStatus = status; From 279c76d29f5121cf9817edd6b7037bb0c73ad575 Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Sat, 26 Mar 2022 23:18:04 +0100 Subject: [PATCH 32/33] added link to Adafruit TinyUSB Library for Arduino --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 7a774dd..954e897 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ This library implements the USB-MIDI transport layer for the [FortySevenEffects Arduino MIDI Library](https://github.com/FortySevenEffects/arduino_midi_library) and uses the underlying [Arduino MIDIUSB](https://github.com/arduino-libraries/MIDIUSB) library (so only devices working with MIDIUSB, will work here). +See also [Adafruit's TinyUSB Library for Arduino](https://github.com/adafruit/Adafruit_TinyUSB_Arduino) for ESP32, mbed_rp2040, ArduinoCore-samd and Pico + ## Installation Screenshot 2020-04-25 at 09 42 19 From ab62611b9ef50a32875910d4af74eea260bbdcde Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Sat, 26 Mar 2022 23:18:31 +0100 Subject: [PATCH 33/33] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 954e897..f7bc327 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This library implements the USB-MIDI transport layer for the [FortySevenEffects Arduino MIDI Library](https://github.com/FortySevenEffects/arduino_midi_library) and uses the underlying [Arduino MIDIUSB](https://github.com/arduino-libraries/MIDIUSB) library (so only devices working with MIDIUSB, will work here). -See also [Adafruit's TinyUSB Library for Arduino](https://github.com/adafruit/Adafruit_TinyUSB_Arduino) for ESP32, mbed_rp2040, ArduinoCore-samd and Pico +Alternative library: see also [Adafruit's TinyUSB Library for Arduino](https://github.com/adafruit/Adafruit_TinyUSB_Arduino) for ESP32, mbed_rp2040, ArduinoCore-samd and Pico ## Installation