Rhythmic Timelines

Much of music from around the world is centered around characteristic rhythms called “timelines.” Here, we explore these timelines using Mathematica to sonify, visualize and generate existing and original rhythms.
June 23, 2017—Connor Bain

Sonification

A timeline is simply a rhythm that repeats throughout a piece with no variation, giving a particular “feel” to the music that incorporates it, in addition to serving as a timekeeper and structuring device for the musicians. Sometimes, these are called “rhythmic ostinatos.”
Here we generate the clave son (commonly just called clave) rhythm, a central facet of any salsa dance:
In[]:=
EmitSound[Sound[{SoundNote["Clap",0.75],SoundNote["Clap",0.75],SoundNote["Clap",1.0],SoundNote["Clap",0.5],SoundNote["Clap",1.0]}]]
Sound familiar? That pattern is the foundation of nearly all Afro-Cuban music. Usually it’s played on an instrument called claves, which are two cylindrical pieces of resonant hardwood that produce a sound that cuts through the entire ensemble to communicate this pattern as a foundation to the music that’s going on around it.
Here is the same rhythm, but this time with a claves sound instead of clapping. Here, we use a pure function to avoid retyping our instrument name each time:
In[]:=
EmitSound[Sound[{SoundNote[#,0.75],SoundNote[#,0.75],SoundNote[#,1.0],SoundNote[#,0.5],SoundNote[#,1.0]}]]&["Claves"]
Interestingly enough, this is same pattern is also known in rock-and-roll music as the Bo Diddley beat, named after rhythm and blues musician Bo Diddley.
Again, we have the same timeline, now with a bass drum:
In[]:=
EmitSound[Sound[{SoundNote[#,0.75],SoundNote[#,0.75],SoundNote[#,1.0],SoundNote[#,0.5],SoundNote[#,1.0]}]]&["BassDrum"]
Up until now, we’ve been generating these timelines by creating a SoundNote sequence with predetermined lengths in seconds (take a look at the second argument of each SoundNote). However, in music we hear what many call a “pulse,” or the thing you tap your foot to. The pulse is just a set of identical, repeated and periodic stimuli.
Here’s a steady pulse (repeated 16 times) every 0.25 seconds:
In[]:=
EmitSound[Sound[Table[SoundNote[#,0.25],16]]]&["Clap"]
So if every rhythm is built off of this pulse, can we express our earlier claves rhythm in terms of this pulse? Of course! Let’s assume a pulse with a duration of 0.25. That means that each hit or onset will be a minimum of 0.25 seconds away from each other.
In[]:=
EmitSound[Sound[{SoundNote[#1,#2*3],SoundNote[#1,#2*3],SoundNote[#1,#2*4],SoundNote[#1,#2*2],SoundNote[#1,#2*4]}]]&["Claves",0.25]
So in that case, we’re expressing each onset as a certain multiple of our base pulse of 0.25. Because we’re dealing with percussion instruments, we could also just express every single pulse, with some being silent.
To “play” silence, we use an instrument called None:
In[]:=
EmitSound[Sound[{​​SoundNote[#1,#2],SoundNote[None,#2],SoundNote[None,#2],​​SoundNote[#1,#2],SoundNote[None,#2],SoundNote[None,#2],​​SoundNote[#1,#2],SoundNote[None,#2],SoundNote[None,#2],SoundNote[None,#2],​​SoundNote[#1,#2],SoundNote[None,#2],​​SoundNote[#1,#2],SoundNote[None,#2],SoundNote[None,#2],SoundNote[None,#2]​​}]]&["Claves",0.25]
The last thing we need to talk about is tempo. Tempo, in music, is just the speed of the pulse, usually measured in beats per minute. Well, in our previous example, we had 0.25 seconds per beat, so how do we find the number of beats per minute for that particular pulse length?
In[]:=
60
s

0.25
s/
beats

1
min
Out[]=
240.
beats
/min
We can also reverse this process—that is, given a tempo, we can calculate how long each pulse is in seconds.
In[]:=
240
beats
/min

60
"
per minute
^-1
Out[]=
1
4
"
per beats

Visualization

Generation

Bonus: Cross-beats

Things We Didn’t Get To

FURTHER EXPLORATIONS
Musical Geometry
Musical Structure (Voice-Leading and Part-Writing)
Classical Fugue Analysis
Composing from the Greats: Using Machine Learning to Generate Musical Compositions
AUTHORSHIP INFORMATION
Connor Bain
6/23/17