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.
The Linux ALSA MIDI subsystem has a lot of capabilities and it takes a while to learn all of the bits and pieces that are available. Such was the case when one of our customers wanted to connect Reaper to an external RTP-MIDI capable device (a Behringer X-Touch). The solution was the snd-virmidi kernel module. This post will describe what snd-virmidi does and how it can be used to bridge different types of software.
The types of Linux device Access
MIDI hardware devices connected to Linux show up through simultaneously through two distinct mechanisms.
the RAW MIDI interface
the SEQ (sequencer) MIDI interface
The figure below illustrates this situation. On the left is the “RAW” MIDI software interface and on the right is the “SEQ” MIDI interface. When an external device is connected, these two distinct interfaces are created for it.
The RAW interface
The RAW interface for software programs presents MIDI data as an uninterpreted byte stream. A ‘noteOn’ message will appear as a sequence of bytes (0x90, 0x??, 0x??) for a software program to interpret according to the MIDI standard. The stream of bytes on this interface is not timestamped and is not interpreted.
Version 2.0 of McLaren Lab’s rtpmidi improves the timing capabilities of the software and optimizes memory usage.
Our most notable new feature is the ability to adjust the playing time of received notes by adjusting latency. Users will notice a new column in the list of participants called “latency adjust.” The entry field is editable and you can type in a number (in milliseconds) to adjust latency of received notes.
The figure above shows the latency field highlighted and we have entered a value of 100.
This article describes the background of the latency adjustment feature and how it can improve your musical experience.
Flight Time
The figure below shows four notes being sent from a Sender MIDI instrument to a Receiver MIDI instrument. The flight time is the time it takes for the note information to be sent from the Sender to the Receiver.
Depending on the network and its characteristics, flight time might be so small it is not noticeable, or large and variable enough that you can “hear” or “feel” it. On a dedicated Ethernet network using RTP-MIDI, the flight time is usually small and uniform. On a WiFi network using RTP-MIDI the flight time can be large and variable.
McLaren Labs’ rtpmidi software has been around for a few years now. It reliably sends and receives MIDI events and properly implements error correction. The software is robust and has been used in very many different environments by an enormous number of users.
But, we knew there were some limitations around scheduled note timing, and we resolved to get to the bottom of it.
Update: 2024-09-15 – The easiest way to connect external MIDI devices to the Linux subsystem of your Chromebook is to use the free McLaren MIDI Server sending to McLaren Labs’ rtpmidi for Chromebook Linux! (Debian 12 Bookworm).
Our port of rtpmidi to Debian 12 (Bookworm) installs effortlessly in the Chromebook Linux subsystem. Why would you want to do this? The reason is to get MIDI events from external devices into the Linux subsystem of your Chromebook.
Currently, when you plug a MIDI device into the USB of your Chromebook, it is not passed through to the Linux subsystem. By using rtpmidi you can send MIDI events from a device connected to another computer into the Linux subsystem of your Chromebook.
When used with a wired Ethernet connection (avoiding WiFi) the latency of such a set-up can rival a direct connection.
Container technology can be used for many things. It can be used for isolation, security, portability or resource management. One popular use of containers is to run a binary for one operating system on another operating system. We wondered if Linux lxc/lxd container technology would allow us to run the binary of rtpmidi for Ubuntu 22.04 on a Debian 12 system. We succeeded eventually.
This post outlines how we reached success. It is not necessarily a recommendation to follow this path. There are a lot of steps, and they can be confusing. But we are going to write down what we learned anyway.
A few weeks ago I picked up an inexpensive Chromebook. I’m typing this on it now, in fact. This was my first experience with Chromebook, and my first experience thinking about porting McLaren Labs’ tools onto a Chromebook. At first, I was thinking about wiping ChromeOS and putting Debian11 directly on it. But then I learned about native Linux support on Chrome in a VM.
Chromebook Linux
Crostini is the name given to the Linux-on-Chromebook virtual machine support. To enable it on my chromebook, I needed to open chrome://flags and enable Linux. Then I rebooted, and in Settings>>Advanced there was a new section called “Linux”. Voila.
Applications that need the Linux environment cause the Linux VM to start. One application is “Terminal” in the main applications menu. Start it up, and there is a full Debian 11 environment there. You can use “apt-get” and install whatever you desire.
The McLaren Synth Kit — https://github.com/mclarenlabs/McLarenSynthKit — now includes an RTP-MIDI engine that you can include in your own projects. The engine is the same one that is in our well-known rtpmidi product! We’re providing the library so that you can set up RTP-MIDI connections as you like.
Background
We sometimes receive requests from users to add features to McLaren Labs’ rtpmidi product to handle connections in a certain way. Some users might want to automatically find a particular endpoint or address. Another user might want automatic re-connect in a certain situation. Others want to experiment by translating events from non-MIDI sources into note events sent to a synthesizer on their network.