Control GPIO pins over the Network with MIDI using MMKServer

  • by

The GPIO (General-Purpose Input/Output) pins of the Raspberry Pi are versatile ports for handling both incoming and outgoing digital signals. When used as output ports, GPIO pins can control lights, actuators, motors, relays and many other things.

One neat thing you can do with them is map them to MIDI “Notes” and play them as output devices. Using McLaren Labs software, you can share these over the network and “play” them from a remote computer. This article says how.

Here are the steps.

  1. Install midi2gpiod
  2. Install MMKServer

Install midi2gpiod

Form our github account, get the software from the link below.

This software maps the first three GPIO pins to MIDI notes

  • middle-C (MIDI note 60) to GPIO pin 25
  • D (MIDI note 62) to GPIO pin 26
  • E (MIDI note 64) to GPIO pin 27

Compile the program and install the midi2gpiod.service file so that the program runs as a daemon. Once running, there will be a new MIDI SEQ device in your system called “midi2gpiod”.

You can see the list of MIDI SEQ devices in your system with the aconnect command.

$ aconnect -i -o -l

Install MMKServer

MMKServer is the McLaren Labs RTP-MIDI daemon that shares all of the attached MIDI Seq devices on your system over the network. Get it from the store.

Once running, MMKServer will see that there is a “midi2gpiod” MIDI device and will share it on the network. Other computers will be able to see this service as a MIDI service.

If you opened up the RTP-MIDI control panel on your Mac, Windows PC or Linux machine you would see this name in the Directory of available MIDI devices.

See the screenshot below on our Mac. You can see the “midi2gpiod” MIDI device advertised in the Directory. This is the service shared from the Raspberry Pi running “midi2gpiod” and “MMKServer”.

Control the GPIO pins from your laptop

Now, create a MIDI song that plays notes C, D, and E, and map the MIDI output of your sequencer or DAW to the network session attached to “midi2gpiod”. The notes played on your laptop will control the GPIO pins.

That’s it. You can use a sequencer software or DAW to coordinate the playing of music with the control of GPIO pins on a Raspberry Pi across the network.

Addendum

Read our original article about midi2gpio here: https://mclarenlabs.com/blog/2021/05/08/midi-to-gpio-for-120-vac-control/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.