# superbuggy/euclidean-rhythm-visualizer

Visualization of Euclidean Rhythms built in vanilla JS. Check it out:
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
images
_config.yml
generate-pattern.js
index.html
script.js
style.css

# Euclidean Rhythm Visual👁👁r

## Background

Through my habitual acquiring of weird synthesizer modules, I stumbled upon a couple modules with functions to generate rhythmic patterns that were called Euclidean sequences or rhythms. I, like most people tend to associate Euclid, the ancient Greek thinker and mathematician, with geometry, so I found the association with geometry and music really intriguing.

I had seen connections drawn between geometry and music in the context of talking about systems of tuning, but never with rhythm. I furtively wondered if there might be a different way to think about or experience rhythms in a visual context, since there was an apparent relationship between music and geometry.

Like most intuitions, mine contained a kernel of truth, but it didn't turn out to be exactly what I'd expected, but joyfully, something more mind-blowing. By seeking out a mathematically-guided synesthetic tour between the worlds of math and music, I found something more mind-blowing: this algorithm can generate the rhythms found in unique musical traditions all around the world. It is sometimes claimed that this algorithm can describe almost all of the rhythms found in known musical traditions on this planet.

I gleaned this through reading an opt-cited paper (linked at the bottom of this document) by McGill computer scientist Godfried Toussaint, whose work seems to point at many parallels between music and math.

## A Brief Introduction to Euclidean Rhythms

The Algorithms in Question

A Euclidean rhythm can be generated by the Bjorklund algorithm, which is based on the Euclidean algorithm. The Euclidean algorithm describes a process to the greatest common denominator between 2 positive integers.

The Bjorklund alogrithm was apparently developed to coordinate timing systems in neutron accelerators.

What makes a Rhythm Euclidean?

Put simply, a Euclidean rhythm will distribute a certain number of pulses over a number of steps.

### Example I: 2 pulses over 8 steps

Let's look at a simple example...

2 pulses, in yellow, over 8 steps.

In yellow we have the pulses, and in brown are the inactive steps, or speaking musically, rests.

Each step has the same duration. My project uses a default step duration of an 8th note. At 120 beats per minute, an eighth note lasts .25 seconds.

The result is that we have 2 pulses evenly distributed over 8 steps, where each step has the same duration (.25 seconds at 120bpm).

The resulting sound is a regular, mechanical ticking that sounds like a metronome or a timepiece that has an audible click. Not a super interesting rhythm.

### Example II: 3 pulses over 8 steps

Since clock-like isn't particularly interesting on a rhythmic level, we can vary the number of pulses we distribute over the 8 steps.

"In Cuba it goes by the name of the tresillo and in the USA is often called the Habanera rhythm used in hundreds of rockabilly songs during the 1950’s" (Toussaint, 4).

### Euclidean Rhythms in Musical Traditions Around the World

It turns out that certain distributions of pulses over steps actually generate rhythms that are the basis of a wide variety of musical traditions around the world, in particular rhythms found in musical traditions throughout the world. Many of the same rhythms appear in multiple contexts around the world.

### Interesting Combinations of Pulses and Steps

As some of the more mathematically inclined of you might've intuited, many interesting rhythms are produced by number that share no common factors other than 1. Two numbers related in this way are said to be relatively prime.

The 2nd example of 3 pulses over 8 steps is one such example. Let's look at some others!

#### 2 pulses over 5 steps

This distribution produces "a rhythm found in Greece, Namibia, Rwanda and Central Africa [7]. It is the pattern of the N-geru and Yalli rhythms used in heroic ballads by the Tuareg nomadic people of the Sahara desert [135]" (Toussaint, 7).

#### 3 pulses over 4 steps

Spreading 3 steps over 4 pulses creates "pattern used in the Baiao´ rhythm of Brazil [130], a drum rhythm in South Indian classical music [95], as well as the polos rhythm of Bali [90]. It is also the anapest rhythm (shortshort-long) from ars antiqua [129], traditionally associated with prosody [38]..." (Toussaint, 7).

If you shift the pattern of active pulses over 2 steps, the resulting pattern "is also the amphibrach rhythm (short-long-short) traditionally associated with prosody [38]" (Toussaint, 7).

Many of these sequences can similarly shifted over a varying number of places to produce other common rhythmic patterns.

In the paper linked below, there are numerous examples of other interesting combinations of pulses distributed over steps.