Posts Tagged click track
One of my more popular posts from last year was ‘In Search of the Click track‘ where I posted some plots showing the tempo deviations from the average tempo for a number of songs. From these plots it was pretty easy to see which songs had a human setting the beat and which songs had a machine setting the beat (be it a click track, drum machine or an engineer fitting the song to a tempo grid). I got lots of feedback along with many requests to generate click plots for particular drummers. It was a bit of work to generate a click plot (find the audio, upload it to the analyzer, get the results, normalize the data, generate the plot, convert it to an image and finally post it to the web) so I didn’t create too many more.
Last week Brian released the alpha version of a nifty new set of APIs that give access to the analysis data for millions of tracks. Over the weekend, I wrote a web application that takes advantage of the new APIs to make it easy to get a click plot for just about any track. Just type in the name of the artist and track and you’ll get the click plot – you don’t have to find the audio or upload it or wrestle with python or gnuplot. The web app is here:
Here are some examples of the output. First up is a plot of “I love rock’n’ roll’ by Britney Spears. The plot shows the tempo deviations from the average song tempo over the course of the song. The plot shows that there’s virtually no deviation at all. Britney is using a machine to set the beat.
Now compare Britney’s plot to the click plot for the song ‘So Lonely’ by the Police:
Here we see lots of tempo variation. There are four main humps each corresponding to each chorus where Police drummer Stewart Copeland accelerates the beat. Over the course of the song there is an increase in the average tempo that build tension and excitement. In this song the tempo is maintained by a thinking, feeling human, whereas Britney is using a coldhearted, sterile machine to set the tempo for her song.
For some types of music, machine generated tempos are appropriate. Electronica, synthpop and techno benefit from an ultra-precise tempo. Some examples are Kraftwerk and The Postal Service:
and the crescendo in ‘In the Hall of the Mountain King’:
It is also fun to use the click plots to see how steady drummers are (and to see which ones use clicktracks). Some of my discoveries:
Keith Moon used a click track on ‘Won’t Get Fooled Again’:
(You can see him wearing headphones in this video)
It looks like Neil Peart uses a click track on Stick it out:
Art Blakey can really lay it down without a click track (he really looks like a machine here):
It seems that all of the nümetal bands use clicks:
I find it interesting to look at the various click plots. It gives me a bit more insight into the band and the drummer. However, some types of music such as progressive rock – with its frequent time signature and tempo changes are really hard to plot – which is too bad since many of the best drummers play prog rock.
In addition the plots I attempted a couple of objective metrics that can be used to measure the machine like quality of drummer. The Machine Score is a measure of how often the beat is within a 2 BPM window of the average tempo of the song. Higher numbers indicate that the drummer is more like a machine. This metric is a bit troublesome for songs that change tempo, a song that changes tempo often may have a lower machine score than it should. The Longest run of machine like drumming is the count of the longest stretch of continuous beats that are within 1BPM of the average tempo of the song. Long runs (over a couple hundred beats) tend to indicate that a machine is in charge of the beat. Both these metrics are somewhat helpful in determining whether or not the drumming is live, but I still find that the best determinate is to look at the plot. More work is needed here.
The new click plotter was a fun weekend project. I got to use rgraph – an HTML5 canvas graph library (thanks to Ryan for suggesting client-side plotting), along with cherrypy, pound and, of course, the Brian’s new web services. The whole thing is just 500 lines of code.
For many years, I’ve used awk and gnuplot to generate plots but as I switch over to using Python for my day to day programming, I thought there might be a more Pythonic way to do plots. Google pointed me to Matplotlib and after kicking the tires, I’ve decided to retire gnuplot from my programming toolkit and replace it with matplotlib.
Matplotlib is a 2D plotting library that produces a wide variety of high quality figures suitable for interactive applications or for inserting into publications. A quick tour of the gallery shows the wide range of plots that are possible with Matplotlib. The syntax for creating plots is simple and familiar to anyone who’s used matlab for plotting.
With this new tool in my programming pocket, I thought I’d update my click plotter program to use matplotlib. (The click plotter is a program that generates plots showing how a drummer’s BPM varies over the course of a song. By looking at the generated plots it is easy to see if the beat for a song is being generated by a man or a machine. Read more about it in ‘In Search of the Click Track‘).
The matplotlib code to generate the plots is straightforward:
def plot_click_track(filename): track = track_api.Track(filename) tempo = float(track.tempo['value']) beats = track.beats times = [ dict['start'] for dict in beats ] bpms = get_bpms(times)plt.title('Click Plot for ' + os.path.basename(filename)) plt.ylabel('Beats Per Minute') plt.xlabel('Time') plt.plot(times, get_filtered_bpms(bpms), label='Filtered') plt.plot(times, bpms, color=('0.8'), label='raw') plt.ylim(tempo * .9, tempo * 1.1) plt.axhline(tempo, color=('0.7'), label="Tempo") plt.show()
Here are a few examples plots generated by click_plot:
To create your own click plots grab the example from the SVN repository, make sure you have pyechonest and matplotlib installed, get an Echo Nest API key and start generating click plots with the command:% click_plot.py /path/to/music.mp3