Hooking up a MIDI keyboard to Ubuntu

I have a MIDI-capable keyboard and a MIDI-to-USB converter. Today it finally worked under Ubuntu Linux. The MIDI-to-USB converter was quite cheap and no-name, but in case this is of help for anyone, the vendor ID was: VF-21-USB-MIDI-KYBD-CBLE-A43

From Linux, the usb device looks as follows (type lsusb in the terminal to get this info):

Bus 002 Device 004: ID 1a86:752d QinHeng Electronics CH345 MIDI adapter

If you plug it in, it pretty much works straight out of the box. Here is the dmesg output:

[ 582.546409] usb 2-1.3: USB disconnect, device number 3
[ 613.878085] usb 2-1.3: new full-speed USB device number 4 using ehci-pci
[ 613.971701] usb 2-1.3: New USB device found, idVendor=1a86, idProduct=752d
[ 613.971709] usb 2-1.3: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 613.971714] usb 2-1.3: Product: USB2.0-MIDI

For me, this creates a device node under /dev/snd/midiC1D0 (but the exact name might depend on other MIDI-capable devices present in your system, so simply look in /dev/snd/ to see what devices appear or disappear when you plug or unplug the USB cable). This device can then be read by Jack and hooked up to Fluidsynth or Rosegarden for your MIDI enjoyment!

Installing FTAP for finger tapping synchronisation experiments (OR: How to use FTAP in the 21st century)

Steve Finney made a neat Linux program for running sensorimotor synchronisation tapping experiments. In tapping experiments, you typically have a participant tap her or his finger along with a metronome. Finney’s program FTAP is a C-based program that will read the taps from a MIDI interface and that can generate metronome sounds. However, the program was developed in the early 2000s and the Linux landscape has changed somewhat. These days I’m installing FTAP on my friend’s Linux box. I figured the world might learn something from our errors.

First of all, make sure you start with a 32-bit version of Linux. It seemed to us that the binaries (pre-compiled executables) that come with FTAP don’t work under 64-bit Linux (which nowadays is the standard). When you download FTAP it should come with source code, which should allow you to compile it, but this didn’t work out of the box for us. Also, it should be possible to run the 32-bit FTAP executables in 64-bit Linux but we were too lazy to figure out how. So make your life easy and install 32-bit Linux.

Second, install a realtime Linux kernel. Current Linux versions by default have a kernel that allows you to come close to real time (called lowlatency) but I got the impression that for the very best timing performance you need the kernels called “realtime” which you can get from abogani’s PPA archive. Note that this works for Ubuntu 12.04 but maybe not for newer versions. For details:




Third, download FTAP: http://csml.som.ohio-state.edu/ftap/ Extract it and you should be ready to roll! Note that FTAP can only read the MIDI device /dev/midi. So if your MIDI device somehow gets mapped to another device node, make sure you install a symbolic link in /dev/midi to the actual device node.

A final note (please learn from our stupidity): When we ran FTAP on a particular day, we found incredible delays (up to several seconds) between the MIDI input and MIDI output. These delays persisted when FTAP wasn’t even running, and the computer was set up (using aconnect) to immediately forward the MIDI signal back to the USB-MIDI device. It turned out to be due to the fact that Windows (which was also installed on the computer in a dual-boot set up) had not been shut down but was in hibernation mode. Apparently this meant that Windows was still using resources and this caused massive delays in the MIDI processing. Lesson learned: don’t hibernate Windows while you are running an experiment under Ubuntu!