I had some fun doing an experiment on myself today. Way back when I was in grad school I had the pleasure of taking part in the Lionel Hampton Jazz Festival. One of the guests worked with our band and had us keep time in our heads for something like 16 measures. No high hat, no snare, no foot tapping. We were all supposed to clap on the downbeat of the 17th measure. She set the tempo for a couple measures and then we were silent. I was really impressed with how synchronized we were at the end. Today I thought I’d play around with that a little.
Here’s what I did: I recorded myself clapping at a given tempo. I wanted to know just how accurate my claps were. What I mean is, how similar were the gaps between claps?
I used Audacity to record the sounds and then I used Mathematica to do the analysis. I know I could have just zoomed in on the Audacity time sequence to get the data but I was wondering how hard it would be to get Mathematica to do all the analysis by itself.
Here’s the full time sequence and a zoom in on one of the peaks:
Then I had to figure out a way for Mathematica to determine the time of the claps. This actually took me a while because I wanted to see how little information I could give it (since my eyes were pretty good at seeing where the peaks were – this is something I deal with every year with my students in Modern Lab).
I settled on trying to find those points in the time series where the standard deviation of the neighboring 500 points was the highest. So I calculated a rolling standard deviation:
These peaks proved easier to get Mathematica to find. I did that by having it walk through the time series and find the time when the curve went up through 0.1 amplitude. I actually did this using the super awesome EventLocator method in NDSolve that I’ve been playing around with.
Once I got the time of the peaks, I did a linear curve fit to find the average frequency and then I took the average of the fit residuals. What’s amazing is that even though I was only clapping at 30 beats per minute (2 seconds between claps) I was only off on average from the perfect downbeat by 5 milliseconds!
This was a lot of fun and I learned a lot about how to find peaks and about my awesome metronome-like ability. In the future I’d like to figure out the best way to concentrate and minimize the errors. For this test run I sang a little song in my head while clapping and that seems to have worked quite well.