Skip to content

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

License

Notifications You must be signed in to change notification settings

YuuichiAkagawa/Arduino-UHS2MIDI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Change CableNumber

#include <UHS2-MIDI.h>
...
USB Usb;
UHS2MIDI_CREATE_DEFAULT_INSTANCE(&Usb);
void setup()
{
  MIDI.begin(4);                            // Launch MIDI and listen to channel 4
  MIDI.getTransport()->setCableNumber(1);   // Change CableNumber to 1 later

Tested boards / modules

  • Arduino UNO R3

Changelog

Chagelog

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published