Send MIDI from USB-B to 5-pin

Please see the bottom of this page for an update.

Way back in January 2014, I outlined a way to send MIDI from a USB-B only controller to a keyboard or module with classic 5-pin MIDI using Raspberry Pi as a bridge. Finally, one year later, I got to try out this idea.

It seems like MIDI over USB has taken over the MIDI controller world!

New controllers now communicate MIDI data over USB instead of using the old 5-pin DIN interface. 5-pin MIDI is dirt simple and is just a faster form of plain old serial communication — no bus protocol, no host/client, no hassles.

The world was 5-pin MIDI for a long time and many classic synthesizers and workstations only have a 5-pin DIN interface. Most of the new controllers have only a USB-B device port and expect to be connected to a USB-A host port for power and communication. If you want to use your new controller with an old 5-pin MIDI synth, you have a communication gap to bridge. Because USB is a peripheral bus with a sophisticated protocol, USB cannot be directly connected/converted to simple 5-pin MIDI signals.

There are two ways to bridge the gap:

  1. Buy a bridge box like the Kenton MIDI USB Host (about $115USD) or iConnectivity iConnectMIDI4+ ($200USD).
  2. Use a PC-based DAW to bridge 5-pin MIDI ports and USB MIDI ports.

Both solutions involve software, a computer, a 5-pin MIDI IN/OUT interface, and a USB-A Host interface. The old synth (or whatever) is connected to the computer through the 5-pin MIDI IN/OUT interface and the controller is connected to the USB-A Host port. The software streams the MIDI data between the 5-pin and USB worlds.

The Kenton is portable, but is a little bit pricey for my taste. Also, the Kenton is not readily available in all parts of the world (e.g., the USA) and shipping is expensive. The PC-based bridge is not so portable and maybe you don’t want to take a laptop to the gig.

Hmmm, let’s see. Computer? USB Host interface? Software? Raspberry Pi!

The Rapsberry Pi B+ would be the ideal model with its four USB Host (A) ports. From the hardware perspective, here’s what we need to do:

  • Connect the USB MIDI controller to one of the Raspberry Pi USB-A Host ports.
  • Connect a bog standard 5-pin MIDI to USB-A interface to one of the other USB Host ports.
  • Connect the 5-pin MIDI IN/OUT ports on the interface to the appropriate 5-pin MIDI ports on the old synth.

This is exactly how we would connect the controller and synth if we used the PC and the DAW except we have replaced the PC with the Raspberry Pi (much smaller and only $40USD).

For software, the Raspbian Linux operating system comes with ALSA audio and MIDI support. We need to use the ALSA aconnect utility to identify the incoming and outgoing MIDI ports and to connect the appropriate ports.

I wanted to try this approach without buying any new hardware. Unfortunately, my Raspberry Pi is the earlier model B with only two USB-A Host ports. I need at least one more port to connect a keyboard and mouse, so a hub has to enter the picture somewhere. I found that the ALSA software did not recognize the controller or MIDI interface through my cheapo non-powered USB hub. Please keep this possible limitation in mind during your own experiments.

Here’s my test set-up. The keyboard controller is an M-Audio Keystation Mini 32. I used an Apple keyboard and mouse for regular user I/O. The Apple keyboard has a built-in hub and adds two USB-A ports. The keyboard is connected to the Raspberry Pi and the mouse is connected to one of the keyboard USB-A ports. The Keystation is connected to the second USB-A port on the Apple keyboard through a USB-A to USB-B cable.

USB-B to 5-pin MIDI connection diagram

The 5-pin MIDI IN/OUT ports are provided by a Roland (Edirol) UM-2ex USB MIDI interface. This interface is connected to one of the Raspberry Pi USB-A Host ports. The UM-2ex has a switch to select either the standard driver or an advanced proprietary driver. Select the standard driver setting. You want to be “class compliant” all the way for best results. Connect the 5-pin MIDI IN/OUT ports to the synth using standard MIDI cables. For this test, the synth is a Yamaha PSR-S950 arranger workstation.

Boot Raspbian and log in. You can either run aconnect from the initial shell or you can start the X Windows systems. For this example, I chose to start X Windows so I could capture output from aconnect.

Type “aconnect -i” to display a list of the readable input ports. These are the ports which provide incoming MIDI data.

$ sudo aconnect -i
client 0: 'System' [type=kernel]
    0 'Timer           '
    1 'Announce        '
client 14: 'Midi Through' [type=kernel]
    0 'Midi Through Port-0'
client 20: 'UM-2' [type=kernel]
    0 'UM-2 MIDI 1     '
client 24: 'Keystation Mini 32' [type=kernel]
    0 'Keystation Mini 32 MIDI 1'

The “$” charcter in the example output is the shell command prompt. The output shows the UM-2ex MIDI input port (client 20) and the Keystation (client 24). The Keystation input port is the source of the MIDI data that we want to send to the synth.

By the way, sudo is required when entering these commands through X Windows as an ordinary user. Superuser privilege is needed to set up ALSA connections.

Type “aconnect -o” to display a list of the writeable output ports. These are the ports which send outgoing MIDI data.

$ sudo aconnect -o
client 14: 'Midi Through' [type=kernel]
    0 'Midi Through Port-0'
client 20: 'UM-2' [type=kernel]
    0 'UM-2 MIDI 1     '
    1 'UM-2 MIDI 2     '
client 24: 'Keystation Mini 32' [type=kernel]
    0 'Keystation Mini 32 MIDI 1'

The output shows the two UM-2ex MIDI OUT ports (client 20 ports 0 and 1) and the Keystation (client 24).

Finally, type “aconnect 24:0 20:0” to establish a bridge between the Keystation port and the UM-2ex MIDI OUT port.

sudo aconnect 24:0 20:0

The first port (24:0) on the command line is the sender and the second port (20:0) is the receiver.

Play a few notes on the controller. If the controller and synth are communicating on the same MIDI channel (usually channel 1 by default), then you should hear some sound from the synth — assuming that the volume is turned up and the synth is connected to an amp, and so forth!

Type “aconnect -x” to remove all connections when finished. Individual connections can be removed using the -d option. If you ever need usage information about aconnect, just type “aconnect -h” or “man aconnect”.

Just for fun, I tried using the Yamaha PSR-E443 for input instead of the Keystation. I replaced the Apple keyboard hub with a powered USB hub, too. (Apple keyboards and Linux don’t always interoperate as friends!) The PSR-E443 keyboard sends on MIDI channels 1 (main voice), 2 (dual voice) and 3 (split voice). By assigning these MIDI channels to RIGHT1, RIGHT2 and LEFT on the S950, I could play a layer in the right hand with a split bass in the left hand.

So, there you go! A simple, cheap bridge between a USB MIDI controller and an old school 5-pin MIDI synthesizer. The next step is to find a way to discover and connect MIDI ports through a boot time, start-up script. If you solve this problem, please post the solution!

Update:If you enjoyed this blog post, then you might like these articles, too: