Discovering the Atoms

What are beats? Are they the individual triggerings of samples? Or are they groups of triggerings? Or are they the span of time between triggering samples? I have settled on something close to the latter: beats can best be described as the time intervals (or “durations”) between triggering samples, which I shall henceforth call “notes”. Okay, so what are the atomic units here?

Given a simple rhythm such as this, where C is a kick drum hit and G is a snare drum note:

(Fig. 1)

Is each quarter note the most atomic unit? Are the pairs? When I first started, I tried to think of each note as the most atomic unit and randomize the durations. However, this generated some pretty a-rhythmic, unsteady sounding stuff. For example, imagine the following SonicPi “random duration generator”

This generates some extremely arhythmic, unlistenable stuff. Clearly the individual note is not the atomic unit of rhythm.

Taking a bit of a cue from how TidalCycles defines its DSL as little strings defining cycles of note data, I got to thinking: what if the groupings of note/durations are the atomic unit? The “pattern” or cycle is the atom and each note/duration is just an electron/proton/muon/gluon-type elementary particle?

Let’s consider a different way to express the rhythm using a new atomic unit: the rhythm word.

T=4.0# To make the durations more readable and use a sort of time signature# Collection of pattern "atoms" or "rhythm words"
patterns =[(bools,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0),# Kick / C(bools,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0)# Snare / G]
live_loop :kicksdo
sample :bd_mehackitif patterns[0].tick
sleep T/16# 16 is the total length of the pattern or its resolutionend
live_loop :snaresdo
sample :sn_dolfif patterns[0].tick
sleep T/16# 16 is the total length of the pattern or its resolutionend

Now this is much more “rhythmic”, avoiding the issues with the pattern pairing in Fig. 1 It has regularity and from an aesthetic perspective passes as “music”. However, it lacks variety and interestingness as a listenable piece of music. It seems like atoms alone don’t cut it. The atoms require a chemistry and the rhythm “words” require a grammar.

Discovering Chemistry

In “interesting” music, the same pattern doesn’t usually repeat for several minutes and then terminate. Sure, there are some repitions but there are also variations on the pattern. These occur at different points selected by the “composer”. What we need is a way to select different patterns and form chains of patterns emulating the decisions made by a composer at “build time”.

This actually begins to sound more “composed” now. There are variations here.

However, the “grammar” isn’t very smart. For example if Snare Pattern 2 is followed by another Snare Pattern 2 you end up with something like:

Notice the weird string of eighth notes in the middle there. Assuming unweighted randomization and “fair coins” during each .choose call, this weird string of eighth note snares would happen once every 4 cycles on average. We can do better.

Better Coin Flips

By bringing in markov chaining, we can preserve the randomness and non-determinism, but avoid too many “weird sounding” moments. Let’s use a different data structure here:

By using markov chaining, we’ve now sort of “stacked the deck” or, to mix metaphors even further, created a strategically unfair coin. We’ve now reduced the probability of two measures of Snare Pattern 2 following each other to just 1/16 * 1/16 or 1/256. This makes the weirdness of too many snare 1/8th notes happen way less often (or statistically maybe not happen at all on most songs).

This creates an overall less weird-sounding rhythm.

But Does It Scale?

Now the question is: can we apply this system to harmonies? The answer is absolutely. Each scale often brings with it a “family” of chords. 7 per scale when dealing with standard western standard “major” scales:

Adding the Sugar

The only thing missing here is a little bit of melody. The melody works exactly in the same way as all the pattern selection stuff above, with only minor variation. At first, I attempt to just let the melody be a free floating markov chain. But like the simple randomization which can put awkward patterns together, letting the melody be a single, giant markov chain failed to capture the atomic unit of melody: the musical phrase.

So like chords and rhythm patterns, melodies need atomic units from which to select using the markov chain and building the atomic unit randomly can sound too weird/randomized and non-musical. So let’s begin with how to generate the melodies randomly but keep each randomized pattern “frozen” so the markov chain can return to phrases and maintain a sort of motif/theme (again, better aesthetically speaking):