Check out my music: https://soundcloud.com/playinmyblues

Saturday 12 May 2018

Arduino Multiple USB MIDI IN MIDI DIN Out

(Originally, this project was intended to have a few more features added such as applying velocity values to messages sent to a Volca FM, which requires a special message to get velocity values applied to notes. Unfortunately, the replacement USB Host Shield does not easily allow extra code and I never did get any support from the manufacturer. The manufacturer of the USB Host Shield I used is not Circuits@Home, in case you were wondering. Given all that, technically, the project currently provides MIDI Thru functionality instead of MIDI Out.)

This project began when in spirit when I started watching YouTube Videos on synthesizers. I have a Casio XW-G1 and was looking into that when I started to see some interesting music being made with the Korg Volca synths. Watching more videos, I was seeing some cool music being made by using their sync ports and then I noticed some people using the MIDI In.

The price point of these synths is great for getting further into the synth world and the various models is great for expanding functionality. Having seen different hardware such as MIDI Thru boxes and already having a audio/MIDI interface, I knew I could connect my USB MIDI keyboards to the PC and play all the Volcas at once. Granted, I had none at the time, but I started out by getting the Volca Keys. I was definitely intrigued.

 There were two problems that I had right away. The first, in my book was that a PC takes time to boot up, connect the audio/MIDI interface and any other accessories that I might want to use with my laptop. I suppose this is made worse by the fact that I have no permanent setup for making my music. The second problem is that I had no MIDI Thru box.

Once I started to investigate the process of making a MIDI device that would accept a USB MIDI keyboard and found ending up finding a very simple solution with the USB Host Shield, which I already had, I was a little disappointed that I did not build this sooner. It was one of the simpler projects to build on a breadboard and the code was already provided in the library for the USB Host Shield. Here is the schematic to the left. Save it and open it to get a better view.

Please do your own footwork to ensure any project you make will not burn out anything in your project. They way the MIDI protocol works with this particular setup is that current only flows when the Arduino pin used, D1 (TX) goes low. Wondering how that works with the MIDI protocol to produce a logic HIGH to the MIDI device? Sparkfun provides a good MIDI tutorial on the subject which I highly recommend you read, at least the first two pages, before you start the project. Another important point when building any stage of this project - prototyping on a breadboard or permanent, is to disconnect the Arduino TX pin from the 74HC14 IC before you upload the sketch. The Arduino still uses the TX pin for the uploading process.

In short (no pun intended), once I breadboarded it, I did some groundwork (no pun intended, again!) to make sure it would not burn anything out. Then I decided to build it. It took longer than I expected, mostly the cutting of holes in the dollar store jewellry box, and then recutting them to fit the new Arduino Uno instead of the Arduino Mega. The Uno's power jack was just a little higher than the Mega's. In the process, I mishandled the USB Host Shield with what was likely ESD and that had to be replaced. See below for the inside of the final version of this stage:

Materials needed:
Arduino Uno or Mega,
USB Host Shield,
powered USB hub,
MIDI DIN jacks,
74HC14 IC,
some resistors,
protoboard, jumper wires
and a box of some sort.


It has 5 MIDI DIN outs, at the moment is coded to accept 4 USB MIDI devices but can handle 7 with the current USB hub.

So, I have tested a number of MIDI controllers with the project. It appears to work with all MIDI devices that I have which are: Oxygen 49 blue version, Akai LPD8, iRig Keys, iRig Keys Mini, Akai MPK Mini MKII, Alesis SR-18 drum machine, Ableton Live Intro, Traktion 7, Behringer UMC404HD, Scarlett 6i6, and an M-Audio Uno Sport USB-to-MIDI cable.

The M-Audio Uno Sport is needed to input the MIDI data into the project as its only input is via USB. I would like to have a MIDI In but the shield does not work well with other code added. I intend to impliment a different shield in a similar later.

((I have not tested the capabilites using a MIDI keyboard such as the M-Audio Oxygen 49 which has some sliders and knobs to turn. I would like to have that working.)) One of the reasons I like this, aside from being able to play my Volcas with keyboards, is looks to be only a step away from making my own synth that I can play with a keyboard.
The basic code is found in the USB Host Shield Library 2.0 > USBH_MIDI > USB_MIDI_converter_multi sketch.

Simply copy the section that outputs the MIDI data, paste it, rename the new section so it differs from the old, add the prototyping up top and you have the code.

This project holds a lot of potential for the future. If you have already worked with microcontrollers, then you probably realize that once you can produce code to accept USB MIDI data and output it, you should be able to make that data do what you want. Making my own synth should be just one step away! Maybe two... three... wait a sec...

Feel free to comment below.

Let me know if you build it yourself and expand upon it. It is not like I made the code myself. Once you see the original code from the library you will see. I posted this project on Facebook and had a comment on HoodLoader so that is another possibility worth exploring.

No comments:

Post a Comment