Hardware MIDI translator for Radio Baton

First a quote from Carmine Casciato’s M.A. Thesis:

Originally referred to as an electronic drum controller, the Radio Baton consists of two batons which are in essence radio transmitters. It employs a near-field capacitive measurement. Each baton is driven by an oscillator at a different frequency (50 kHz and 55 kHz respectively) so as to allow for independent tracking of both. They are tracked over a rectangular tablet that houses two pairs of shaped radio receiving antennas. The first pair is shaped so that the X coordinate of each baton can be determined as close to linearly as possible; similarly, the final pair corresponds to the Y coordinate. These coordinates refer to the horizontal plane in front of the user. The incoming signals are processed by a CPU such that a vertical Z-coordinate up to 15 centimeters above the surface is also output.

The IDMIL is currently improving the data-capture methods used by Casciato by improving synchronization and sample-rates and reducing latency and jitter. One problem is that while the Radio Baton outputs MIDI, the messages are all “Poly Aftertouch” messages, even when the device is struck like a drum. Previously this was dealt with by using a general purpose computer to listen to the MIDI datastream and output “note on” messages when appropriate. The MIDI was then routed to a Roland TD-20 drum sound module.

One solution is to use a microcontroller dedicated to translating the MIDI messages instead of a PC, since it can run much faster than the routine running on the PC, and will have vastly reduced jitter since it is not doing anything else. We whipped up something fairly quickly using an Arduino Pro Mini board, with just a few extra parts and some online resources:

Below are some photos of the finished box and its firmware:

// Radio Baton MIDI Translator
// Joseph Malloch 2009
// www.music.mcgill.ca/~mallochj
// Input Devices and Music Interaction Laboratory
// www.idmil.org

byte incomingByte;
boolean polyKey = 0;
boolean strike = 0;
boolean RXledStatus = 0;
boolean RXledPin = 12;
boolean TXledStatus = 0;
boolean TXledPin = 13;
unsigned long RXthen = 0;
unsigned long TXthen = 0;
unsigned long now = 0;

void setup() {
  pinMode(RXledPin, OUTPUT);
  pinMode(TXledPin, OUTPUT);

void loop() {
  if (Serial.available() > 0) {
    incomingByte = Serial.read();
    if (!RXledStatus) {      //if RX LED is off...
      RXledStatus = 1;       //turn it on
      digitalWrite(RXledPin, RXledStatus);
      RXthen = millis();     //and reset clock
    if (polyKey==1) {            //if Poly aftertouch...
      if (strike==1) {           //and already received strike...
        playNote(incomingByte);  //play note with this velocity
        polyKey = 0;             //and reset
        strike = 0;
      }else if ((incomingByte==1) || (incomingByte==2)) {
        strike = 1;              //received strike message
      }else {
        polyKey = 0;
    }else if (incomingByte==160) {
      polyKey = 1;               //received Poly aftertouch message
  now = millis();
  if(TXledStatus) {            //if TX LED is on...
    if((TXthen - now) > 20) {  //and enough time has passed...
      TXledStatus = 0;         //turn it off
      digitalWrite(TXledPin, TXledStatus);
  if(RXledStatus) {            //if RX LED is on...
    if((RXthen - now) > 10) {  //and enough time has passed...
      RXledStatus = 0;         //turn it off
      digitalWrite(RXledPin, RXledStatus);

void playNote(byte velocity) { //Send a Note-ON message with a note of middle C
  Serial.print(159, BYTE);     //Note ON message, channel 16
  Serial.print(60, BYTE);      //Middle C
  Serial.print(velocity, BYTE);
  if(!TXledStatus) {
    TXledStatus = 1;
    digitalWrite(TXledPin, TXledStatus);
    TXthen = millis();

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s