Breadth-First Binary Numbers and Their Application to Musical Rhythms
Figure 1. Rhythms encoded by breadth-first binary numbers. Introduction I built some robots recently that play musical rhythms. They are depicted in Figure 2. Figure 2. Dr. Squiggles rhythmic robots, which motivated this rabbit hole. The rhythms in question are all a certain constant number of beats in duration, with a certain constant number of subdivisions per beat. Each subdivision can be populated by an onset or not. For simplicity, say there are always 4 beats and 4 subdivisions per beat (16 subdivision per rhythm). I want to know how the rhythms evolve over time; sometimes a robot might play the same thing over and over, and sometimes it might play something very different every 4 beats. I would like to encode each 16-bit rhythm as an integer, so I can plot the rhythms that each robot plays over time. The obvious thing would be to convert the rhythms directly to integers via binary. The problem is that similar rhythms might not have nearby integers, and vice verca. F