MIDI-router on Raspberry Pi
I want to talk about how to solve a problem that is probably familiar to fans of hardware synthesizers.
What should I do if I want to dock a MIDI controller and synthesizer, but one of them has only a USB connector and no MIDI? Moreover, for obvious reasons, I want to do all this without using a computer.
I searched the Internet several times in search of a device for this, but I didn’t find anything except a couple of links to a couple of small-circulation devices for a lot of money, which have already been discontinued.
At some point it dawned on me: you can take the Raspberry Pi and do everything on it - this is a real computer, and on it such things are done easily.
It will probably be weak for full sound processing, but the MIDI message flow should already be pumped.
[By the way, there is a sound effect processor for Raspberry Pi , but it requires the latest Raspberry Pi model, which is much more expensive, plus an additional shield, which is also not cheap, and I decided not to bother].
No sooner said than done. Raspberry Pi got the very first model and assembled a working prototype in a couple of evenings. In a nutshell how it works.
ALSA Midi
At first, I planned to take PureData and write for him a simple patch that will transfer midi messages from one port to another.
But when I started to get MIDI on it in Linux, I found a much simpler approach.
Linux has a standard sound input / output system - ALSA. It supports both audio streams and MIDI.
In order for a program to receive MIDI messages through ALSA, you first need to connect it to the source of these messages. But this is exactly what we need to solve this problem! Without thinking twice, I threw out PureData and did everything with ALSA native tools.
Here is the result.
aconnect
When you connect a MIDI device to the system, it appears in ALSA devices and you can perform various operations with standard commands with it. We are interested in a team aconnectthat just makes connection-disconnection of ports. Detailed documentation can be found here .
In reality, we need only two operations: display a list of available devices and connect one device to another:
# Вывести список MIDI-устройств, имеющихся в системе
aconnect -l
# Пересылать весь вывод с Arturia Keystep на Xio
aconnect 'Arturia KeyStep 32' 'Xio'I wrapped these commands with auto-start systemd scripts and configured them to start constantly in a loop, you can see how I did it here .
Alternatives
If you still need to somehow process the MIDI stream before sending it to the output, you can use several options:
- Some of the audio processing languages:
- PureData in headless mode
- You can probably use SuperCollider
- Chuck
- Mididings
If you know more options - send.
Upd: Summary
After a month and a half of experiments, I summarize.
As a result, practice has shown that it does not matter for the transfer of notes - the notes often move out and skip.
For clock transmission, it’s more or less normal - in synchronization of the arpeggiator of the controlled synth with the master rhythm of the jambs, I don’t hear.
But for the transfer of controller messages, it seems to be ideal.
Now you can connect Launch Control XL to any syntax.
References
When I last studied this question for some reason, I could not find anything.
This time there were quite a lot of things, I will post links here so that you do not repeat my path if the same problem arises.