Using a Raspberry Pi as USB MIDI Host

February 8, 2016

Wheeeeeeeee! I have some money again, though not a lot of time, but I’m determined to finish and further expand the projects I started with such gusto last year.

Both the Tempest and FS1r are blurred memories, and I’ve been getting my kicks, whenever possible, with a Monomachine/Blofeld Combo.

The great thing about this pairing is that I can sequence 6 channels of Blofeld multimode goodness alongside 5 Monomachine tracks, with the 6th track acting as the FX machine for the Blofeld, which is routed back through the MnM inputs. A nice, self contained, and gloriously digital setup. Did I mention that MnM does killer drum synthesis?

RPi_USB_MIDI_Host_MnM

On the the MnM it is possible to input chords using an external MIDI keyboard for the Arps and external sequencing.

I have an cheapo Akai LPK USB mid keyboard that would make a nice compliment to this mini setup. But MnM only accepts 5-pin DIN MIDI. One existing option is the Kenton USB MIDI Host, but that goes for over 100 euro.

I got to thinking that I could use my similarly-abandoned and superseded Raspberry Pi 1, and a MIDI 1×1 USB MIDI cable that never got used because it kept causing bluescreens on my Windows PC. What if I could use the Pi to route the output of the LPK through the 1×1?

Well yes, it’s possible, works perfectly, and is really easy to get running.

Any flavour of linux will do, in my case I’m using a Raspberry Pi v1 with an optimised Raspbian Wheezy image I downloaded from here. I’ve also got this to work on a Rpi2 using the official Ubuntu ARMv7 distro.
The instructions for both are the same.

EDIT: Georgios Says:

By the way, on the latest raspbian, it works out of the box. No need to install anything 🙂

Obviously, with only 2 USB ports on the Pi v1, there is no room for wireless, so I needed to login over ethernet.

Once a command prompt is available, it’s a matter of installing Alsa:

sudo apt-get install alsa alsa-utils

Now connect the *class compliant* MIDI devices, in my case the Akai LPK25 and E-mu USB MIDI 1×1.

To show all connected MIDI devices:

sudo amidi -l

Show connection status and port numbers of connected MIDI devices

sudo aconnect -i -o

Look for the device ID, which is in the format x:0. In my case, the LPK25 was 20:0 and the Emu 1×1 was 16:0. So to connect the output of the LPK to the output of the Emu, just go:

sudo aconnect 20:0 16:0

…and voila! Works a treat here, no latency and I’ve sent boatloads of MIDI through it.

To dump all midi message to the screen,
sudo amidi -d

Naturally, we will want this connection to happen automatically every time we start the Pi. Of the several ways to do this, I opted for the laziest, which was to make a root crontab.
If you’re not root already,

sudo su
crontab -e

at the end of the file, enter the aconnect command that works for you to run at reboot, e.g.

@reboot aconnect 20:0 16:0

🙂

Advertisements

14 Responses to “Using a Raspberry Pi as USB MIDI Host”


  1. Do you run it on battrery (for me it would make just any sense for mobile usage of my mini maudio and i.e. my shruti) or similiar? If so, how long does it reach (with the Akai USB Keyboard connected too)?

    • stimresp Says:

      Hi Niels,
      I have not run it off batteries, but I know it is possible with a suitable battery clip. I’m powering it from a USB phone charger.

      The reach is long enough. The Emu interface cable is nearly 2 metres, and the USB cable connecting the LPK25 can be as long as you like.

      I’m already looking at ways to expand this, possibly to offer a USB-CV interface. Rasp Pi model B+ are < 30euro.
      I'm sure there's an even cheaper ay, but I had all the ingredients available, so it was free. Yay!

      Cheers,
      stim

  2. David Says:

    This is very cool got a few Raspberry Pi’s very first one and a B+ and 2 and 3 of course, I already own a USB Midi Host but still want to try this out, going to see how I could power this via battery 🙂 thank you for this

  3. Rich Says:

    Thanks! I figured this wouldn’t be hard but it’s always nice to get a confirmation before trying.

  4. Paul Says:

    Thank you for your fine work. This was extremely helpful. I am now able to get my OP1 to play nicely with my circuit and organelle. BTW your Tempest guide was masterful.

  5. Georgios Says:

    Thank you so much for sharing this.

    I was thinking to get the Kenton Midi hub but it feels so overpriced for what it does.

    Getting a raspberry pi will do the job on 1/3 of the price, plus you’ll have all that fun with anything else that can be built on top of that.

    Cheers!

  6. Daniel Hamilton Says:

    I’m a beginnner at all things Linux but keen to try this out, all I am wondering is if you can use alsa to convert CCs going in to different ccs going out? I’d be looking to convert CC74 to CC01.

  7. Grant M Says:

    Great, thanks! Although having bother getting the frontal to work, the MIDI ports of my devices seem to jump around every time I reboot!


Comments:

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: