An Euclidean Rhythms generator implemented in p5.js.
Try it out on Open Processing ⌛ 🎵
Note: for compatibility reasons, it is highly recommended to run the web app on a chromium-based browser.
As the name suggests, Euclidean rhythms have roots in ancient Greek geometry before entering the world of modern music creation.
The musical properties of the Euclid's ubiquitous greatest common divisor algorithm were discovered by Godfried Toussaint in 2005 and are described in his paper "The Euclidean Algorithm Generates Traditional Musical Rhythms". In short, he demonstrates how this mathematical principle can produce rhythms that are found in numerous and disparate styles of music from around the world and throughout history.
This implementation is based on the Bjorklund algorithm, which uses the same form of division of Euclid's algorithm in a binary structure. Bjorklund's algorithm was first introduced in nuclear physics for timing patterns in neutron accelerators, but then re-imagined by Toussaint to produce sequences of maximally even rhythms.
It takes a number of steps (n) and finds the most even way to space pulses (k) within the window using only integers: if n is not evenly divisible by k, there will be two different durations between the pulses. For example, k = 7 and n = 16 produces [ 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0 ].
For the algorithm details, the reference is Bjorklund's paper "The Theory of Rep-Rate Pattern Generation in the SNS Timing System" (where he provides C code).
I set up four independent sequencers synchronized by the same clock, in order to enhance the polyrhythmic capabilities of the algorithm.