I took a quick break with some random hacking last night. I wanted to see what kind of statistical structure there is in rhythm, since I am always tapping on various vaguely percussive objects. You can see the code on Github.
The simplest setting to study this is the class of random processes consisting of discrete events called “arrivals”, where each arrival represents a tap. The statistics of interest here are distributions of interarrival times, like the time between consecutive arrivals (1st order interarrival time), or the time between every kth arrival (kth order interarrival time). You could even look at the joint distributions of arbitrarily many consecutive interarrival times of various order. The image below shows the joint distribution of two consecutive interarrival times — the first of order 3 and the second of order 5 — for rhythmic tapping versus random tapping (modeled by a Poisson process). The distribution of consecutive interarrival times of order 3 and 5 tells you things like “if it took 6 seconds for the past 3 arrivals, it will take 4, or 8 or 12 seconds for the next 5 arrivals”. That’s what the little bumps in the right image represent — different rhythmic alternatives for the next few beats given the past few beats. The reason it’s not a perfect lattice is because I actually used a recording of my own drumming, which is noisy and also far from perfect rhythm-wise. But however imperfect, there is obvious structure there that is not present in random tapping.
Eventually, I want to sample from these distributions to generate rhythms. A logical extension would be to support different types of arrivals representing different instruments. Another extension would be to teach the system to accompany someone else’s drumming. A simple approach would be to train it on some beats composed of instruments 1 and 2, then play instrument 1 and have it fill in instrument 2.