During my summer holidays I got an interesting idea: Pianoteq has a very nice feature of “always on MIDI logging” that saves everything you play on your keyboard while Pianoteq was on. I’ve previously made some MIDI projects and had a great idea:
How about building a small device that records everything I play on my piano, and save it as MIDI files?
This would enable me to later grab a good performance, and eliminate the “recording anxiety” I get if I know I’m recording and should definitely not do any mistakes during the next 1000+ notes. Furthermore, even with easy MIDI recording to USB stick, it’s still several manual steps plugging the memory stick in, starting recording, stopping it, lugging it to a computer, etc.
My first idea was to use some WLAN-enabled embedded device, but MIDI IN would require optoisolators and some custom electronics, and more modern digital pianos often come with only USB MIDI, so it could easily become an exercise in communication protocols. Fast forward a couple of minutes to my next revelation:
Raspberry Pi Model 0 W already has USB and WLAN, and it’s small. Why not use that?
Turns out using a RaspPi as fully automated MIDI logger is really easy. Read on for instructions!
Update: Also check out my follow-up post to split the recorded MIDI files automatically!
Recording MIDI with Raspbian
Turns out recording MIDI from a USB MIDI enabled device is really easy. When I plug in my Kawai CS-11 (sorry for the unsolicited link, I love my CS11 :) to the Pi (or just turn it on when it’s plugged in),
dmesg shows that the Pi automatically notices the new MIDI device:
[ 587.887059] usb 1-1.5: new full-speed USB device number 4 using dwc_otg [ 588.022788] usb 1-1.5: New USB device found, idVendor=0f54, idProduct=0101 [ 588.022800] usb 1-1.5: New USB device strings: Mfr=0, Product=2, SerialNumber=0 [ 588.022807] usb 1-1.5: Product: USB-MIDI [ 588.074579] usbcore: registered new interface driver snd-usb-audio
Once the USB MIDI device is found, you can use
arecordmidi -l to list available MIDI ports:
pi@raspberrypi:~ $ arecordmidi -l Port Client name Port name 14:0 Midi Through Midi Through Port-0 20:0 USB-MIDI USB-MIDI MIDI 1