From 113bbec47453a47be375fe5375ed6ed60a312ce0 Mon Sep 17 00:00:00 2001 From: lathoub Date: Sat, 16 May 2020 10:41:06 +0200 Subject: [PATCH 1/3] Update MIDI_DIN2USB.ino --- examples/MIDI_DIN2USB/MIDI_DIN2USB.ino | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/examples/MIDI_DIN2USB/MIDI_DIN2USB.ino b/examples/MIDI_DIN2USB/MIDI_DIN2USB.ino index bde218c..98f6a0d 100644 --- a/examples/MIDI_DIN2USB/MIDI_DIN2USB.ino +++ b/examples/MIDI_DIN2USB/MIDI_DIN2USB.ino @@ -1,13 +1,7 @@ #include -USING_NAMESPACE_MIDI; - -typedef USBMIDI_NAMESPACE::usbMidiTransport __umt; -typedef MIDI_NAMESPACE::MidiInterface<__umt> __ss; -__umt usbMIDI(0); // cableNr -__ss MIDICoreUSB((__umt&)usbMIDI); - -typedef Message MidiMessage; +USING_NAMESPACE_MIDI +USBMIDI_CREATE_INSTANCE(0, MIDICoreUSB); MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDICoreSerial); // ----------------------------------------------------------------------------- @@ -34,12 +28,12 @@ void loop() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void onUsbMessage(const MidiMessage& message) +void onUsbMessage(const MidiInterface::MidiMessage& message) { MIDICoreSerial.send(message); } -void onSerialMessage(const MidiMessage& message) +void onSerialMessage(const MidiInterface>::MidiMessage& message) { MIDICoreUSB.send(message); -} +} \ No newline at end of file From 9a8b68521b7e68997c713cb8f270960854ba93f0 Mon Sep 17 00:00:00 2001 From: lathoub Date: Sat, 16 May 2020 11:21:57 +0200 Subject: [PATCH 2/3] USBMIDI_CREATE_CUSTOM_INSTANCE, DIN2USB using modified SysEx len - USBMIDI_CREATE_CUSTOM_INSTANCE - added DIN2USB using modified SysEx example --- .../MIDI_DIN2USB_SysEx/MIDI_DIN2USB_SysEx.ino | 45 +++++++++++++++++++ src/USB-MIDI.h | 4 ++ 2 files changed, 49 insertions(+) create mode 100644 examples/MIDI_DIN2USB_SysEx/MIDI_DIN2USB_SysEx.ino diff --git a/examples/MIDI_DIN2USB_SysEx/MIDI_DIN2USB_SysEx.ino b/examples/MIDI_DIN2USB_SysEx/MIDI_DIN2USB_SysEx.ino new file mode 100644 index 0000000..4f439fa --- /dev/null +++ b/examples/MIDI_DIN2USB_SysEx/MIDI_DIN2USB_SysEx.ino @@ -0,0 +1,45 @@ +#include +USING_NAMESPACE_MIDI + +struct ModifiedSettings : public MIDI_NAMESPACE::DefaultSettings +{ + static const unsigned SysExMaxSize = 8196; +}; + +// Both Instances *must* use the same SysExMaxSize +USBMIDI_CREATE_CUSTOM_INSTANCE(0, MIDICoreUSB, ModifiedSettings); +MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial1, MIDICoreSerial, ModifiedSettings); + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void setup() +{ + MIDICoreUSB.setHandleMessage(onUsbMessage); + MIDICoreSerial.setHandleMessage(onSerialMessage); + + MIDICoreUSB.begin(MIDI_CHANNEL_OMNI); + MIDICoreSerial.begin(MIDI_CHANNEL_OMNI); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void loop() +{ + MIDICoreUSB.read(); + MIDICoreSerial.read(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void onUsbMessage(const MidiInterface::MidiMessage& message) +{ + MIDICoreSerial.send(message); +} + +void onSerialMessage(const MidiInterface, ModifiedSettings>::MidiMessage& message) +{ + MIDICoreUSB.send(message); +} diff --git a/src/USB-MIDI.h b/src/USB-MIDI.h index ce24344..a038f17 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 596456d776dc3cd18098edcbdcd8628540ffd9d8 Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Sun, 6 Dec 2020 20:19:30 +0100 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cfd8474..54e23e4 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