MIDI Conductor

The Introduction

Recently I’ve been working on a piece that has a lot of tempo changes. Although a click track is lovely for pieces that go at the same speed, it’s not very nice when the tempo is shifting all over the place. Besides, the headphones that I like have open backs and let the sound out, so that little click track ends up leaking into my vocals. Hardly a decent solution in a quiet digital recording setup.

That’s when I got to thinking about the Bjork concert that I saw a couple of years ago. She sang with a 100 piece orchestra, but the tracks were all played from a computer with MIDI. The human conductor in the orchestra pit followed some dancing lights over by the side of the stage. They seemed to be connected to the MIDI sequencer, and bounced back and forth just like a baton in the hand of a very unimaginative conductor.

The Technology

MIDI is an old and simplistic hardware and data protocol, but one that I believe will never completely go away. It’s because of its simplicity that little gadgets and gizmos like the MIDI Conductor can be built in an evening and cost about $10.

The reason that the MIDI Conductor is possible is because of MIDI clock. The MIDI clock is a group of commands initially designed to allow multiple sequencers to playback together. Personally I’ve never done this, as my computer has always been fast enough to control all the synthesizers at once. The clock commands can be used to start, stop and continue playback, as well as send the timing pulses during playback.

The start command begins playback from the beginning of the piece. Stop stops playback, and continue takes up from where the playback was stopped. The clock command is the actual timing command that sends timing information. Start and continue tells the receiver that the next clock signal will be a downbeat. The clock messages themselves carry no data, so it’s important to keep track of how many clocks have been received since playback was started. Unfortunately if a message is lost or the cable unplugged, subsequent clocks will be useless until playback is restarted.

There are some good MIDI tutorials on the web that you should read. Below is a quick summary of the MIDI clock commands:

  • 0xfa - start - starts playback from the beginning of the piece
  • 0xfb - continue - continue playback from where the playback was stopped (or the beginning if there has been no playback)
  • 0xfc - stop - stop playback
  • 0xf8 - clock - clock pulse - sent 24 times per quarter note

Also please note that not all MIDI sequencers send these commands by default. Cakewalk in particular has an option in the Project pane to send MIDI clock. You can tell if MIDI clock is being sent because you will most likely see the TX light on your MIDI interface lit up continuously.

The Solution

Well, having had the Bjork blinkenlight unit in the back of my mind for a few years, I finally got to the point where not only did I want one of these things for myself, I also needed one for the piece that I was working on. I decided to build the hardware one day after work and then write the firmware that night at home. Apart from a few tweaks in both hardware and software, I had the thing working the next morning when I got back to the office.

My MIDI Conductor is made from 25 LEDs. (plus the power LED) There are 24 red and one blue. (the downbeat) The processor is a Microchip PIC18F452, which was chosen because it has enough I/O to drive all the LEDs directly. The MIDI input uses a 4N25 optocoupler. There are a couple of parts in the power supply, which runs off a 9VAC 100mA wall wart. The entire unit is mounted in a deep 8″x10″ picture frame. The conductor is mounted on the wall above my keyboard/microphone.

The code is very simple, the MIDI receiving code being the easiest since all MIDI clock commands are only one byte. The bulk of the code counts back and forth on the LEDs and converts the count into the correct I/O line turning on, since the LEDs are connected to many different ports. There is only ever a single LED on at a time. The centre (blue) LED is lit at every beat, and the display dances left and right, hitting an extreme end at every off-beat. Even when not looking directly at the unit, the blue LED is quite obvious. Tempo changes, ritardandos, etc. are all very easy to see as each quarter note is divided into 24 display changes. Plus it looks frigging cool! You should build one for yourself!

Note: This source code is written to be compiled with mcc18 from Microchip. No binary is included. Please do not email me with questions about compiling or burning PICs. You need to figure that out for yourself. As a hint: you want MPLAB, mcc18 and a QuickWriter from TechTools.