A Study of Rhythms

In which we enumerate every possible rhythm available with 16 subdivisions within a 4/4 meter, consisting of only whole, half, quarter, eighth and sixteenth notes. While you will see dotted notes in the output below, there are actually no notes with a duration of 3; the dotted eighths and ties are merely an artifact of proper splitting of beams across beat boundaries.

There are 5272 different rhythms here. If we did allow notes with durations other than 1, 2, 4, 8, and 16, then the number of rhythms would be 32768.

The code used to generate this set is a simple recursive function, and can be easily adapted to produce other interesting rhythmic sets.

function permutations(&$list, $set) {
	$total = 16;
	$durations = array(1,2,4,8,16);
	if (array_sum($set) == $total) {
		$list[] = $set;
		return $list;
	$sum = array_sum($set);
	foreach ($durations as $d) {
		if (($total-$sum) >= $d) {
			$new = $set;
			$new[] = $d;
			permutations($list, $new);
	return $list;