Software considerations

A project log for CasioKeyBot

This funky Arduino-powered robot adds MIDI capability to an old Casio SA-21 keyboard.

igor-angstIgor Angst 10/06/2018 at 19:260 Comments

This project is more or less finished, at least I have a stable version that I am satisfied with and that I already used in a live setup on stage. The one thing I regret not having implemented during my performance was MIDI panic (cc #123 set to zero should be interpreted as "all notes off"), since I ended the first song with one finger stuck in the downward position...

In my Linux musical setup, I am using both JACK (mostly for audio) and ALSA (only for MIDI). Jack also does MIDI, but the API is even uglier than the ALSA one. So I opted for ease of use. Using the QJackctrl patchbay, JACK and ALSA coexist peacefully.

This is how I drive the robot in my live setup: On the Linux host side, there is a C program running, which accepts incoming ALSA MIDI sequencer connections. It reads incoming note events (and optionally cc events for the finger setup) and sends corresponding messages (in a dedicated message format) over the USB-to-serial connection to the robot. The heart of the robot is an Arduino Uno. The firmware listens to the serial interface, interprets incoming messages and drives 8 soft PWM outputs to move the individual fingers.  

Meanwhile I discovered that having an extra client program on the host and a dedicated protocol was probably not the best design choice. In other projects I am using the Arduino Micro or Leonardo. These boards have the ATmega32u4, which has builtin USB support. This allows it to act as USB human interface controller (keyboard, mouse or MIDI) natively. This means that if you have your Arduino setup acting as a MIDI interface, the ALSA sequencer will automatically attribute a sequencer port to the device once the USB cable is connected, without starting the client software manually. While this would be definitely a better and more portable solution, I do not plan to do this change in the near future. This is also due to the fact that my client software now integrates some brothers and sisters of the keybot: a xylophone bot, a snare drum bot, and a bass drum but which all speak the same protocol and identify themselves with the client software, so I can setup ALSA sequencer ports with appropriate names.