Building a “Complex” Metronome

February 9, 2022

Even though my first love in music was the stripped-back hard rock bands of the 1990s, I was exposed to more complex compositions during my 5th hour Symphony Band class in high school.  As a percussionist I was particularly drawn to interesting rhythms, changes in tempo, and especially complex time signatures.  This trained my ear to catch the same complexity in other music, in particular songs by the band Rush that were still commonplace on the radio, but eventually other progressive rock & metal bands, and other styles of music as well.

So I wanted to create a smartphone app that I could use while practicing music that would “keep up” with what I was playing, and could cue when a change was about to occur, or keep track of how many iterations of a pattern I’d played.  At this point, it’s worth noting that I originally started this project many years ago, it was the first Android application I’d ever written, so the UI is based on some now-ancient design patterns and was cobbled together in whatever way I could make things work.

If you’re used to recording music at home, you might note that this can be done pretty easily in any major digital-audio workstation, as mapping out a “click” for an entire song, even a complicated song, is a pretty core task.  I still feel there’s some value to having the same ability in your pocket, away from a fully-featured computer setup, and that there are some features (like “alternate” measures) that make this project worth pursuing.

First and foremost, I knew it had to be simple to add a new segment at a new time signature or tempo.  This can be done by clicking a single button in the arrangement view.

I also knew that not all measures have the same “feel”, even though they may have been written in the same time signature.  In this complex metronome, I allow any countable beat(s) to be accented.  Likewise, you may want a gradual increase or decrease in tempo if a song speeds up or slows down, so I added a feature to create a linear accelerando or rallentando from one tempo to another.  Finally, I know how easy it is to get lost in 80 measures of a “click”, so I wanted the feature to add alternate measures – either to help you count sets of 4, 8, etc or to cue you to the fact that a transition is about to occur.

Being a relatively old-school software user, I’ve always been of the “options for everything” philosophy.  The settings in this application are fairly simple for now;

  • Choice of instrument for the “tick-tock”, and for alternate measures
  • Do you want extra beats to “count in” before the arrangement starts?

On the technical side of things, I wasn’t sure a user-level Android application would be millisecond-accurate-enough to play audio events on a timer callback, so I relied on an old standard (and an old friend) MIDI to handle this portion for me.  This application generates a MIDI bytestream and sends it to the Android MediaPlayer to turn into something audible.  As a future enhancement, it may be trivial to send this bytestream out of the Android device as a silent series of events to control connected MIDI devices’ tempos across the course of a song.

As it is, the app is functional.  It scratches the itch I had to develop something new, it solves a problem, and it works well enough to use it for every application I had originally planned.  The approach of using MIDI as a technical solution worked flawlessly.  Now that I’ve been able to pilot it, I realize there are a couple of features that I’d like to implement next.

  • Support “swung” notes, triplets, and other rhythmic ideas
  • Allow a specific number of bars of “count-in”, and make this match the current time signature
  • Flipping high/low tones (allow accent to be lower pitch instead of higher pitch)
  • Provide volume sliders for accented & non-accented notes
  • Add a “tap tempo” feature to set tempo without knowing an exact BPM
  • Make segment markers functional
  • Complete visual overhaul

I plan to wrap these items up in a future lab day!