Using a Raspberry Pi as a RTP-MIDI Gateway for macOS

This is a guide to setting up a Raspberry Pi as a RTP-MIDI source for usage with macOS' networked MIDI support. After it, you'll have a Raspberry Pi acting as a transparent network bridge between a MIDI controller and a Mac running Garageband or any other MIDI software.

This allows you to record your electric piano or keyboard on your Mac wirelessly.

This guide assumes some general knowledge with the Raspberry Pi and MIDI. It won't go into detail on how to set up the Pi itself or how to access a shell on it.

Prerequisites

Raspberry Pi

USB MIDI Interface Anything supported by Linux will work. I bought some random cheap one from Amazon and didn't run in any issues. You don't need this if your MIDI controller supports USB natively.

MIDI Controller (a Keyboard, ...) Again, basically anything from the last 20 years will work. As long as it plugs into a computer and works with the usual MIDI software it will work with this guide too.

Checking if your device works with alsa s MIDI support

Run amidi -l to list all available MIDI devices:

$ amidi -l Dir Device Name IO hw:1,0,0 USB MIDI Interface MIDI 1

Remember the value in the Device column. We will need it later to tell raveloxmidi the device it should relay MIDI messages from.

You can also check if alsa is able to read messages from your device via amidi --dump :

$ amidi --port=hw:1,0,0 --dump 90 5B 4A 80 5B 00 90 5B 2A 80 5B 00

(Use Ctrl-C to stop the command)

Compiling raveloxmidi

raveloxmidi is a great piece of software originally written by Dave Kelly. It handles all the hard parts (advertising devices on the network, handling sessions, relaying MIDI messages) for us.

Compilation has some prerequisites. Install them via:

$ sudo apt install -y git pkg-config libasound2-dev libavahi-client-dev autoconf automake

Clone the repository (get the source code) via:

$ git clone -b experimental https://github.com/ravelox/pimidi.git

Change into the source directory and compile the code:

$ cd pimidi/raveloxmidi/ && ./autogen.sh && ./configure && make -j2

If everything compiled fine, install the generated binary system-wide:

$ sudo make install

Creating a config file

Create a simple config file in /etc/raveloxmidi.conf with the following contents:

alsa.input_device = YOUR_DEVICE_ID network.bind_address = 0.0.0.0 logging.enabled = yes logging.log_level = normal

Testing

To start raveloxmidi, run:

$ sudo raveloxmidi -dN -c /etc/raveloxmidi.conf

This will output a bunch of debug messages and should dump even more when a MIDI messages arrives from the connected controller. If nothing happens whena MIDI message arrives, check if you hardware-id ( amidi -l ) is correct.

On your Mac, start Audio MIDI Setup and open the MIDI Network Setup window under MIDI Studio -> Open MIDI Network Setup .

A device names raveloxmidi should appear in the Directory list.

After creating a new session by clicking on + in the My Sessions pane and enabling it you should be able to connect to raveloxmidi by selecting it and clicking Connect .

Now the last thing to do is piping the MIDI messages from the network to a local MIDI session by clicking on the dropdown with the arrow pointing to the left (meaning "Incoming MIDI Messages") and selecting an appropriate target session.

You should now be able to play an instrument for example in GarageBand from your MIDI controller connected to the Raspberry Pi.

Disconnect in Audio MIDI Setup and stop raveloxmidi via Ctrl-C .

Setting up auto-start via Systemd

Now the only thing left is setting everything up to start automatically on boot and restart in case it crashes. To do this, create a file in /etc/systemd/system/raveloxmidi.service with the following contents:

[Unit] After=local-fs.target network.target Description=raveloxmidi RTP-MIDI network server [Install] WantedBy=multi-user.target [Service] ExecStart=/usr/local/bin/raveloxmidi -N -c /etc/raveloxmidi.conf Type=simple Restart=always

This declares a new raveloxmidi systemd service which will start on boot and restart it in case it crashes.

To enable the service run:

$ sudo systemctl daemon-reload $ sudo systemctl enable raveloxmidi.service $ sudo systemctl start raveloxmidi.service

You can check the status and view most recent log messages via: