AlpesMachines / Arduino-UHS2MIDI

USB Host Shield 2.0 MIDI transport layer for the FortySevenEffects Arduino MIDI Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Arduino USB Host Shield 2.0 MIDI Transport

arduino-library-badge Check Arduino status License

USB Host Shield 2.0 MIDI transport layer for the FortySevenEffects Arduino MIDI Library and uses the underlying USB Host Shield 2.0 library.
This library is based on the Arduino-USBMIDI.

Installation

Install from Arduino Library Manager. Search for UHS2-MIDI. arduino-library-manager

Usage

Basic / Default

#include <UHS2-MIDI.h>
...
USB Usb;
UHS2MIDI_CREATE_DEFAULT_INSTANCE(&Usb);
...
void setup()
{
  MIDI.begin(1);
  if (Usb.Init() == -1) {
    while (1); //halt
  }//if (Usb.Init() == -1...
  ...
}
void loop()
{
  Usb.Task();
  MIDI.read();
  ...

will create a instance named MIDI (transport instance named __uhs2MIDI) and is by default connected to cable number 0 - and listens to incoming MIDI on channel 1.

Modified

#include <UHS2-MIDI.h>
...
USB Usb;
UHS2MIDI_CREATE_INSTANCE(&Usb, 4, MIDI);

will create a instance named MIDI (transport instance named __uhs2MIDI) and is connected to cable number 4.

Custom Settings

#include <UHS2-MIDI.h>
...
struct MySettings : public midi::DefaultSettings
{
    static const unsigned SysExMaxSize = 512; // Accept SysEx messages up to 512 bytes long.
};
USB Usb;
UHS2MIDI_CREATE_CUSTOM_INSTANCE(&Usb, 0, MIDI, MySettings);

will create a instance named MIDI (transport instance named __uhs2MIDI) and change the maximum size of SysEx messages to 512 bytes.

Advanced

#include <UHS2-MIDI.h>
...
USB Usb;
UHS2MIDI_NAMESPACE::uhs2MidiTransport uhs2MIDI2(&Usb, 5);
MIDI_NAMESPACE::MidiInterface<UHS2MIDI_NAMESPACE::uhs2MidiTransport> MIDI2((UHS2MIDI_NAMESPACE::uhs2MidiTransport&)uhs2MIDI2);

will create a instance named uhs2MIDI2 (and underlaying MIDI object MIDI2) and is by default connected to cable number 5.

Tested boards / modules

  • Arduino UNO

Other Transport protocols:

The libraries below the same calling mechanism (API), making it easy to interchange the transport layer.

About

USB Host Shield 2.0 MIDI transport layer for the FortySevenEffects Arduino MIDI Library

License:MIT License


Languages

Language:C++ 81.3%Language:C 18.7%