Have you ever wanted to use MIDI commands to control electrical lights or appliances? This article will tell you how using a Raspberry Pi, the GPIO pins controlled by some open-source software from McLaren Labs on GitHub, and a nifty device called the IOT Relay. Using the Relay is an affordable and SAFE way to control 120 VAC sockets and it makes this project a breeze.
The “McLaren Synth Kit” is an Objective-C framework for using MIDI and Audio on Linux computers with the GNUstep programming environment. It is distributed as a project including libraries, headers and example programs at https://github.com/mclarenlabs/libs-mclaren-alpha. You can use it to experiment with sound synthesis for your own personal projects. The project is designed to provide ready-to-compile examples after you clone the repo.
Working with sound is a delicate endeavor. The Synth Kit does a lot of the low-level work of opening devices, managing an audio thread and copying MIDI events to and from dispatch queues. This leaves the audio programmer free to think about designing sounds as a graph of processing units, called Voices.
Standard Voices in the Synth Kit provide envelopes and oscillators of various types, filters and a reverb algorithm. Using the features of modern Objective-C (blocks, ARC and dispatch queues) the Synth Kit makes programming sounds easy, or at least “easier.”
On Linux systems, Bonjour is implemented by the “Avahi” service. This is what McLaren Labs’ rtpmidi program uses to find Apple MIDI services on your network when you set it up. Usually rtpmidi can find the iPhones and iPads on your network, but sometimes things do not go smoothly. That’s when you need to do some network debugging. One of the tools that you can use to learn about Bonjour services on your network is avahi-browse.
Install avahi-browse
If you have installed McLaren Labs’ rtpmidi, then there is a good chance that avahi-browser is already installed. Try it out.
$ avahi-browser
If it isn’t there, you can install it like this on Ubuntu systems.
Here at McLaren Labs we like to try all sorts of tools and development environments to see how they work together. We’ve been using vscode (https://code.visualstudio.com/) on and off for about a year, but only recently decided to try using it for a more complete edit/debug/run cycle for an Objective-C Synthesizer project. We ran into an unexpected interaction between the Snap environment of vscode and the ALSA (Advanced Linux Sound Architecture) PCM interface.
The Symptoms
What we discovered was that when running a program that attempted to access an ALSA sound device was that the program malfunctioned. It worked correctly in a “normal” terminal, however.
We reproduced the behavior using the default aplay command that is available in alsa-utils. See the screenshot below for what should appear in a terminal when it is run, playing an Ubuntu standard sound called “Front-Left”. Unless otherwise specified, this command opens the “default” sound device.
If your Ubuntu sound system is set up correctly, you will hear a woman saying “Front Left” … and it will come out of your front-left speaker.
When you use our rtpmidi tool to connect two devices you have created a “session.” The session has an “initiator” side that started the connection, and “listener” side that accepted the invitation. Some devices, however, do not make good “initiators” and iPhones are a great example. An iPhone cannot initiate a network MIDI session.
But sometimes you want an iPhone to join the MIDI network of a stationary computer … without going back to the computer screen. McLaren Labs’ “favorite” option was created to handle this case.
A “favorite” is the name of a device that that rtpmidi automatically initiates a session with whenever the favorite appears on the network. This new feature takes advantage of the properties of Bonjour (Avahi). A Listener advertises its availability using Bonjour. When rtpmidi detects a Bonjour name matching a favorite, it automatically initiates a session with that name.
Use the “favorite” option from the command line like this.
$ rtpmidi gui -F 'myiPhone' -t Organ-Synth:0
Now, whenever rtpmidi sees the iPhone named “myiPhone” it will automatically call it and route MIDI information to “Organ-Synth”.
You may notice that when you purchase our software in the “store” that you may be given multiple releases to choose from. See the screenshot below. The purchase of $5 on October 19 has given access to two releases: 0.5.2 and 0.5.0.
This month McLaren Labs releases rtpmidi version 0.5.0 for Ubuntu and Raspberry Pi. This release brings some great new features, and also provides a few performance and installation improvements.
More MIDI message types … including SysEx
McLaren Labs rtpmidi has always supported the following message types with full Journal capability for sending and receiving. (Note: The Journal is part of the error correction mechanism that recovers lost messages that occur when sent over a network.)
Note On, Note Off
Control Change
Program Change
Pitchwheel
System Reset
With this release, we also add the following to provide a complete set of MIDI message types including System Exclusive.