Simple USB-MIDI to MIDI

Having experimented with the Hobbytronics USBMIDI device, I always wanted to see if it was possible to build my own using an Arduino. And it turns out to be a lot simpler than I expected, as least to use the USBMIDI keyboard for MIDI OUT to another device.

2020-07-29 16.57.26

Warning! I strongly recommend using an old or second hand keyboard for your MIDI experiments.  I am not responsible for any damage to expensive instruments!

These are the key Arduino tutorials for the main concepts used in this project:

If you are new to Arduino, see the Getting Started pages.

Parts list

The Circuit

There isn’t really any circuit.  My USB Host Shield has stackable headers, so I just assembled the three pieces as follows.

2020-07-29 16.58.23

It needs power of course – I powered it all via the Arduino’s USB connector.  Then the USB MIDI keyboard will plug into the USB Host Shield on the middle layer and my MIDI keyboard will plug into the MIDI OUT port on the MIDI Shield.

There was one quirk. My USB Host Shield needed the jumpers setting for the Arduino Uno.  For me, this mean using a solder bridge to join the 3.3V and 5V jumpers near the Arduino’s power pins; and the setting the 5V VBUS jumper too.  This is all described on the USB Host Shield site linked to above.

The Code

I was fully anticipating having to write some bespoke code to get all this working, but my starting point was the USB Host Shield library, developed by Oleg Mazurov and others, which can be found here:

The MIDI support was provided by Yuuichi Akagawa and can be found here – http://yuuichiakagawa.github.io/USBH_MIDI/ – except that it is now include into the USB Host Shield library already which is readily installable from within the Arduino IDE itself using the usual Sketch -> Include Library -> Manage Libraries.  Searching for USB Host Shield should find it.  If you only search for USB Host then there are several that come up – make sure you install the USB Host Shield v2.0 library.

So next up was how to design the code.  But actually browsing the examples, there is already a USB_Midi_Converter example sketch which does exactly what I need – take an input from the USB port, pass it through via the USB MIDI code and then output the resulting data on the built-in serial port, which in my case means heading to the MIDI Shield.

No further code was necessary!

Note there are probably some limitations:

  • This is one direction only – USBMIDI to MIDI.
  • This works with “class compliant” USB MIDI devices. I don’t know if it works with any devices that need their own driver (for example) to work with a computer.

Closing Thoughts

Sometimes things just work!  And that is great.  But it is all down to the generosity of those developing these hardware modules and associated code to just let you plug things together and get on with your own tasks.

I have a smaller USB Host shield designed for use with an Arduino Pro micro so at some point I’ll try and get that working.

Kevin

 

One thought on “Simple USB-MIDI to MIDI

Leave a comment