Pre-release of USB Host Library SAMD MIDI transport layer for the FortySevenEffects Arduino MIDI Library and uses the underlying USB Host Library SAMD.
Therefore, it depends on the behavior of the USB Host library SAMD.
This library is based on the Arduino-USBMIDI.
This libraries is EXTREMELY ALPHA!
copy it in "libraries" directory.
#include <USBHSAMD-MIDI.h>
USBHost UsbH;
...
USBHSAMDMIDI_CREATE_DEFAULT_INSTANCE(&UsbH);
...
void setup()
{
MIDI.begin(1);
...
void loop()
{
UsbH.Task();
MIDI.read();
will create a instance named MIDI
(transport instance named __usbhsamdMIDI
) and is by default connected to cable number 0 - and listens to incoming MIDI on channel 1.
#include <USBHSAMD-MIDI.h>
...
USBHSAMDMIDI_CREATE_INSTANCE(&UsbH, 4, MIDI);
will create a instance named MIDI
(transport instance named __usbhsamdMIDI
) and is connected to cable number 4.
#include <USBHSAMD-MIDI.h>
...
struct MySettings : public midi::DefaultSettings
{
static const unsigned SysExMaxSize = 512; // Accept SysEx messages up to 512 bytes long.
};
USB Usb;
USBHSAMDMIDI_CREATE_CUSTOM_INSTANCE(&UsbH, 0, MIDI, MySettings);
will create a instance named MIDI
(transport instance named __usbhsamdMIDI
) and change the maximum size of SysEx messages to 512 bytes.
#include <USBHSAMD-MIDI.h>
...
USBHSAMDMIDI_NAMESPACE::usbhsamdMidiTransport usbhsamdMIDI2(&Usb, 5);
MIDI_NAMESPACE::MidiInterface<USBHSAMDMIDI_NAMESPACE::usbhsamdMidiTransport> MIDI2((UHS2MIDI_NAMESPACE::uhlsdMidiTransport&)usbhsamdMIDI2);
will create a instance named usbhsamdMIDI2
(and underlaying MIDI object MIDI2
) and is by default connected to cable number 5.
- Arduino M0 Pro
The libraries below the same calling mechanism (API), making it easy to interchange the transport layer.