midiHost turns a Raspberry Pi 2 with a small PiTFT screen and four buttons into a standalone USB MIDI host, so that my Akai MPK mini Play can play other instruments without a computer in between.
Incoming MIDI events go into a queue on a dispatcher thread and pass through a chain of filters (transpose, channel mapping, controller mapping, pressure to CC) before they’re sent on. There are two targets I set it up to talk to:
- A Novation Circuit gets notes on channel 1 or 2, one channel per synth.
- A Korg Kaossilator Pro+ gets a custom filter that turns notes into positions on its XY pad. X comes from the note and Y from a knob on the keyboard.
On the little screen there’s a text-mode (curses) interface, and the four hardware buttons are used to switch modes, and the code itself is based on the filter example from python-rtmidi.