<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Percussion on Sebastian Spicker</title>
    <link>https://sebastianspicker.github.io/tags/percussion/</link>
    <description>Recent content in Percussion on Sebastian Spicker</description>
    <image>
      <title>Sebastian Spicker</title>
      <url>https://sebastianspicker.github.io/og-image.png</url>
      <link>https://sebastianspicker.github.io/og-image.png</link>
    </image>
    <generator>Hugo -- 0.160.0</generator>
    <language>en</language>
    <lastBuildDate>Mon, 07 Apr 2025 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://sebastianspicker.github.io/tags/percussion/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>The Oldest Algorithm in the World Plays the Clave</title>
      <link>https://sebastianspicker.github.io/posts/euclidean-rhythms/</link>
      <pubDate>Mon, 07 Apr 2025 00:00:00 +0000</pubDate>
      <guid>https://sebastianspicker.github.io/posts/euclidean-rhythms/</guid>
      <description>Euclid&amp;rsquo;s algorithm for computing greatest common divisors, applied to the problem of distributing k drum beats as evenly as possible among n time slots, generates rhythmic patterns that match traditional timelines from West Africa, Cuba, Brazil, Turkey, and the Balkans. An algorithm devised in Alexandria around 300 BCE encodes the rhythmic structure of musical cultures that had no contact with ancient Greek mathematics.</description>
      <content:encoded><![CDATA[<p><em>The first time I encountered the West African standard bell pattern it was in a
Music and Physics seminar. The lecturer played a twelve-beat cycle on a wood
block — seven strokes distributed unevenly but with a rightness that arrested the
room. She then played the Cuban clave, the bossa nova timeline, a Bulgarian
aksak rhythm. Different cultures, different instruments, different centuries. She
asked whether there was a pattern. There was. It is named after a mathematician
who died around 270 BCE.</em></p>
<hr>
<h2 id="euclids-algorithm">Euclid&rsquo;s Algorithm</h2>
<p>Every student who has taken a number theory course has encountered the algorithm
for computing the greatest common divisor of two positive integers. Given $a \geq
b$, repeatedly replace $(a, b)$ with $(b, a \bmod b)$ until the remainder is
zero; the last non-zero remainder is the GCD.</p>
<p>For example, $\gcd(8, 3)$:</p>
$$8 = 2 \times 3 + 2 \;\Rightarrow\; \gcd(8, 3) = \gcd(3, 2)$$<p>
</p>
$$3 = 1 \times 2 + 1 \;\Rightarrow\; \gcd(3, 2) = \gcd(2, 1)$$<p>
</p>
$$2 = 2 \times 1 + 0 \;\Rightarrow\; \gcd(2, 1) = 1.$$<p>Three steps, result 1 (8 and 3 are coprime). The algorithm is efficient: the
number of steps is proportional to the number of digits in the smaller input.
It appears in Book VII of Euclid&rsquo;s <em>Elements</em>, composed around 300 BCE, making
it the oldest non-trivial algorithm in the Western mathematical tradition.</p>
<hr>
<h2 id="distributing-onsets-toussaints-observation">Distributing Onsets: Toussaint&rsquo;s Observation</h2>
<p>In 2005, Godfried Toussaint — a computer scientist and ethnomusicologist at
McGill University — published the observation that the problem of distributing
$k$ musical onsets as evenly as possible among $n$ time slots has the same
recursive structure as Euclid&rsquo;s algorithm applied to the pair $(k, n-k)$
(Toussaint, 2005).</p>
<p>The algorithm that solves this distribution problem was independently discovered
in nuclear physics. Bjorklund (2003), working on timing systems for the
Spallation Neutron Source particle accelerator at Oak Ridge, needed to distribute
$k$ beam-extraction pulses as evenly as possible among $n$ machine cycles.
The algorithm he derived — Bjorklund&rsquo;s algorithm — is mathematically equivalent
to the Euclidean algorithm applied to the same pair of integers.</p>
<p>The resulting pattern is denoted $E(k, n)$: the <strong>Euclidean rhythm</strong> with $k$
onsets distributed among $n$ pulses. A 1 denotes an onset; a 0 denotes a rest.</p>
<hr>
<h2 id="working-through--the-tresillo">Working Through $E(3, 8)$: The Tresillo</h2>
<p>Let us derive $E(3, 8)$ — 3 onsets distributed in 8 pulses — step by step.</p>
<p><strong>Start</strong>: 3 onset groups and 5 rest groups:</p>
$$[1]\; [1]\; [1]\; [0]\; [0]\; [0]\; [0]\; [0]$$<p><strong>Step 1</strong>: Distribute one rest group into each onset group, pairing until the
shorter list is exhausted. Three pairs, with $5 - 3 = 2$ rest groups remaining:</p>
$$[1,0]\; [1,0]\; [1,0]\; [0]\; [0]$$<p><strong>Step 2</strong>: Now 3 longer groups and 2 shorter groups. Distribute one shorter group
into each longer group, $3 - 2 = 1$ longer group unpaired:</p>
$$[1,0,0]\; [1,0,0]\; [1,0]$$<p><strong>Step 3</strong>: The two group types have different lengths and only one group of the
shorter type remains; no further pairing is possible. Read the sequence
left to right:</p>
$$E(3, 8) = [1, 0, 0, 1, 0, 0, 1, 0].$$<p>This is the <strong>Cuban tresillo</strong> — one of the foundational rhythmic cells of
Afro-Cuban music, used across son, salsa, and mambo. Its onset positions are
$\{0, 3, 6\}$, giving gap sizes $[3, 3, 2]$: two wide gaps and one narrow gap,
arranged as evenly as the integers allow.</p>
<p>The parallel with Euclid&rsquo;s algorithm is direct. In the division $8 = 2 \times 3</p>
<ul>
<li>2$, the quotient 2 gives the number of pairing steps before a remainder
appears, and the remainder 2 gives the number of groups in the shorter list at
each intermediate stage. The recursion $\gcd(8, 3) \to \gcd(3, 2) \to \gcd(2,
1)$ mirrors the three steps above.</li>
</ul>
<hr>
<h2 id="the-gap-structure">The Gap Structure</h2>
<p>For any $E(k, n)$, the spacing between consecutive onsets takes exactly two
values:</p>
$$\text{gap} \in \left\{\left\lfloor \frac{n}{k} \right\rfloor,\
\left\lceil \frac{n}{k} \right\rceil\right\}.$$<p>The number of each gap size is determined by the constraint that all $k$ gaps
sum to $n$. Writing $\alpha = n \bmod k$:</p>
$$\alpha \cdot \left\lceil \frac{n}{k} \right\rceil \;+\; (k - \alpha) \cdot
\left\lfloor \frac{n}{k} \right\rfloor = n.$$<p>So $E(k,n)$ has $\alpha$ gaps of the larger size and $k - \alpha$ gaps of the
smaller size. The Euclidean property is that these two gap types are distributed
<em>as evenly as possible</em> among themselves — not clustered at one end of the cycle
but interleaved. A cycle that maximises the minimum distance between any two
consecutive onsets has this property; it is called <strong>maximally even</strong> (Clough
and Douthett, 1991).</p>
<p>For $E(3, 8)$: $\lfloor 8/3 \rfloor = 2$, $\lceil 8/3 \rceil = 3$,
$\alpha = 8 \bmod 3 = 2$. Two gaps of 3, one gap of 2. Gap sequence $[3, 3, 2]$.
Maximum-evenness is why the tresillo sounds &ldquo;right&rdquo; even though it is
asymmetric: the asymmetry is the smallest possible deviation from perfect
regularity.</p>
<hr>
<h2 id="a-gallery-of-world-rhythms">A Gallery of World Rhythms</h2>
<p>The following table, derived from Toussaint (2005, 2020), shows Euclidean rhythms
alongside their ethnomusicological identifications. Asterisks mark patterns given
as rotations of the canonical form.</p>
<table>
  <thead>
      <tr>
          <th>Pattern</th>
          <th>Gap structure</th>
          <th>Musical tradition</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>$E(2,3) = [1,0,1]$</td>
          <td>$[2,1]$</td>
          <td>Iambic foot; West African, Balkan</td>
      </tr>
      <tr>
          <td>$E(3,8) = [1,0,0,1,0,0,1,0]$</td>
          <td>$[3,3,2]$</td>
          <td>Cuban <em>tresillo</em>; Flamenco</td>
      </tr>
      <tr>
          <td>$E(5,8) = [1,0,1,1,0,1,1,0]$</td>
          <td>$[2,1,2,1,2]^*$</td>
          <td>Cuban <em>cinquillo</em></td>
      </tr>
      <tr>
          <td>$E(4,9) = [1,0,0,1,0,1,0,1,0]^*$</td>
          <td>$[3,2,2,2]^*$</td>
          <td>Turkish <em>aksak</em> patterns</td>
      </tr>
      <tr>
          <td>$E(7,12) = [1,0,1,1,0,1,0,1,1,0,1,0]$</td>
          <td>$[2,1,2,2,1,2,2]^*$</td>
          <td>West African standard bell</td>
      </tr>
      <tr>
          <td>$E(9,16)$</td>
          <td>$[2,1,2,2,1,2,2,1,2,1]^*$</td>
          <td>Brazilian and West African</td>
      </tr>
      <tr>
          <td>$E(13,24)$</td>
          <td></td>
          <td>South Indian (Carnatic) <em>tāla</em></td>
      </tr>
  </tbody>
</table>
<p>Three of these are worth examining in more detail.</p>
<p><strong>$E(5,8)$: the cinquillo.</strong> Five onsets in eight pulses: $\lfloor 8/5 \rfloor =
1$, $\lceil 8/5 \rceil = 2$, $\alpha = 3$. Three gaps of 2 and two gaps of 1.
Gap sequence $[2,1,2,1,2]$ or a rotation thereof. The <em>cinquillo</em> is a
fundamental pattern in Cuban music, used as a melodic rhythmic figure in the
nineteenth-century contradanza and in much of what followed.</p>
<p><strong>$E(7,12)$: the West African standard bell.</strong> Seven onsets in a twelve-beat
cycle: $\lfloor 12/7 \rfloor = 1$, $\lceil 12/7 \rceil = 2$, $\alpha = 5$.
Five gaps of 2 and two gaps of 1. This timeline — used across the Ewe, Akan,
and many other traditions in West Africa — is the cyclic reference structure
against which other rhythmic layers are measured in ensemble drumming. It is also
the pitch-class set $\{0, 2, 4, 5, 7, 9, 11\}$ — the Western diatonic scale,
translated from pitch to rhythm. That the same maximally-even distribution
describes both the diatonic scale in pitch space and the standard bell in rhythm
is one of the more remarkable coincidences in mathematical music theory.</p>
<p><strong>Universality across non-connected cultures.</strong> The tresillo $E(3,8)$ appears
independently in Cuban music, Flamenco, Namibian Juǀ&rsquo;hoansi music, and
medieval Persian music (Toussaint, 2020). These traditions had no common musical
ancestor that could have transmitted the pattern. The Euclidean algorithm
produces what maximum evenness demands, and maximum evenness turns out to be
what these rhythmic traditions independently converged on.</p>
<hr>
<h2 id="circular-notation-and-necklaces">Circular Notation and Necklaces</h2>
<p>Euclidean rhythms are most naturally represented as <strong>necklaces</strong> — equivalence
classes of binary sequences under cyclic rotation. All rotations of $E(3,8)$
represent the same rhythmic structure with a different starting downbeat: the
musical identity is independent of which position is designated &ldquo;beat 1.&rdquo;</p>
<p>In circular notation, place $n$ equally spaced dots on a circle and mark the $k$
onset positions. The pattern is immediately visible: the $k$ onset-dots divide
the circle as evenly as possible. For $E(7,12)$, the seven onset dots on a
twelve-position circle look like the seven vertices of a near-regular heptagon
inscribed in a dodecagon. For $E(3,8)$, the three onset dots form a near-
equilateral triangle.</p>
<p>This geometric representation makes the maximum-evenness property transparent in
a way that the linear binary string does not. It also makes clear why Euclidean
rhythms feel &ldquo;balanced&rdquo; when played: the onset dots distribute the &ldquo;weight&rdquo; of
the cycle as uniformly as the integer constraints allow.</p>
<p>The mathematical theory of necklaces belongs to combinatorics on words.
Euclidean rhythms correspond to specific equivalence classes of binary sequences
known as <em>Christoffel words</em> (Lothaire, 2002): words over the alphabet $\{0,1\}$
whose combinatorial properties encode the slope of a line segment, which brings
us to the third independent context in which the same algorithm appears.</p>
<hr>
<h2 id="the-bresenham-connection">The Bresenham Connection</h2>
<p>Jack Bresenham&rsquo;s line algorithm (1965) rasterises a line from $(0,0)$ to $(n,k)$
on a grid of integer pixels. At each column $x$, the algorithm tracks whether the
fractional error accumulated since the last row increment exceeds $\frac{1}{2}$,
and if so, increments the row and resets the error. The sequence of column
positions at which the row increments is the onset pattern $E(k,n)$.</p>
<p>Formally, an onset occurs at position $m$ in $E(k,n)$ if and only if:</p>
$$\left\lfloor \frac{(m+1)\, k}{n} \right\rfloor > \left\lfloor \frac{m\, k}{n} \right\rfloor.$$<p>Equivalently, the onset positions themselves form the sequence:</p>
$$s_j = \left\lfloor \frac{j \cdot n}{k} \right\rfloor, \qquad j = 0, 1, \ldots, k-1.$$<p>For $E(3,8)$: $s_0 = 0$, $s_1 = \lfloor 8/3 \rfloor = 2$,
$s_2 = \lfloor 16/3 \rfloor = 5$, giving onset positions $\{0, 2, 5\}$ — a
rotation of the tresillo.</p>
<p>This is exactly the Bresenham increment condition. Drawing the line from $(0,0)$
to $(8,3)$ and marking where the $y$-coordinate takes a step produces the onset
positions $\{2, 5, 7\}$ — a rotation of the tresillo $\{0, 3, 6\}$.</p>
<p>Three independent fields — ancient Greek number theory, Afro-Caribbean percussion,
and 1960s computer graphics — converge on the same mathematical object. This is
not a coincidence. All three are solving the same fundamental problem: how to
distribute $k$ discrete events as evenly as possible among $n$ slots. When the
problem is universal, its solution is too.</p>
<hr>
<h2 id="euclidean-rhythms-in-contemporary-practice">Euclidean Rhythms in Contemporary Practice</h2>
<p>Toussaint&rsquo;s 2005 paper was primarily a contribution to computational
ethnomusicology, but it reached electronic music production rapidly. Euclidean
rhythm sequencers are now standard in modular synthesis (dedicated Eurorack
hardware modules exist under names including &ldquo;Euclidean&rdquo; and &ldquo;Erica Synths
Pico&rdquo;) and digital audio workstations (as Max for Live devices and software
plug-ins). The interface is minimal: set $k$ and $n$, adjust the rotation offset,
and hear the resulting timeline immediately.</p>
<p>This has opened a compositional mode in which the mathematical structure is
operational: a producer constructing a layered African-style polyrhythm by
stacking $E(3,8)$, $E(5,8)$, and $E(7,8)$ on different instruments is — whether
they know it or not — computing the Euclidean algorithm three times and listening
to the result.</p>
<hr>
<h2 id="implications-for-teaching-rhythm">Implications for Teaching Rhythm</h2>
<p>Music conservatories in the European tradition teach rhythm almost entirely
through Western notation: time signatures, note values, dotted notes, ties. This
system is well-suited to the repertoire it was designed for. It handles Euclidean
rhythms awkwardly. The tresillo $E(3,8)$ requires either a triplet feel against
a binary pulse or a notation involving a dotted quarter note followed by a dotted
quarter and a quarter, which correctly represents the sound but obscures the
structural principle entirely.</p>
<p>The Euclidean framework suggests a different pedagogical starting point. Rather
than beginning from the bar line and asking how notes fill it, begin from the
cycle length $n$ and the onset count $k$ and ask how to distribute the onsets
as evenly as possible. The answer is always computable and always produces a
recognisable rhythm.</p>
<p>For students who encounter West African, Afro-Cuban, or Middle Eastern music —
which conservatory students increasingly do — having a framework that makes these
rhythms <em>structurally necessary</em> rather than <em>culturally exotic</em> changes the
pedagogical relationship fundamentally. The tresillo is not a deviation from
&ldquo;normal&rdquo; rhythm. It is the unique maximally even solution to the problem of
placing three beats in eight pulses. That the same algorithm appeared in a 300
BCE Alexandrian text on number theory is an accident of the history of mathematics.
That it sounds right is not.</p>
<p>Whether conservatory curricula are ready to incorporate the Euclidean framework
alongside Western notation is a separate question. The mathematics does not
demand it. But it offers a language for rhythm that transcends the Western
bar-line without abandoning precision — and that seems worth something, especially
in a world where the music students will perform and teach is no longer
exclusively European.</p>
<hr>
<h2 id="references">References</h2>
<ul>
<li>
<p>Bjorklund, E. (2003). <em>The theory of rep-rate pattern generation in the SNS
timing system.</em> Technical Report SNS-NOTE-CNTRL-99, Spallation Neutron Source,
Oak Ridge National Laboratory.</p>
</li>
<li>
<p>Bresenham, J. E. (1965). Algorithm for computer control of a digital plotter.
<em>IBM Systems Journal</em>, 4(1), 25–30. <a href="https://doi.org/10.1147/sj.41.0025">https://doi.org/10.1147/sj.41.0025</a></p>
</li>
<li>
<p>Clough, J., &amp; Douthett, J. (1991). Maximally even sets. <em>Journal of Music
Theory</em>, 35(1–2), 93–173. <a href="https://doi.org/10.2307/843811">https://doi.org/10.2307/843811</a></p>
</li>
<li>
<p>Lothaire, M. (2002). <em>Algebraic Combinatorics on Words.</em> Cambridge University
Press.</p>
</li>
<li>
<p>Toussaint, G. T. (2005). The Euclidean algorithm generates traditional musical
rhythms. In R. Sarhangi &amp; J. Sharp (Eds.), <em>Proceedings of BRIDGES 2005:
Mathematical Connections in Art, Music, and Science</em> (pp. 47–56). Bridges
Conference.</p>
</li>
<li>
<p>Toussaint, G. T. (2020). <em>The Geometry of Musical Rhythm: What Makes a &ldquo;Good&rdquo;
Rhythm Good?</em> (2nd ed.). Chapman &amp; Hall/CRC Press.</p>
</li>
</ul>
]]></content:encoded>
    </item>
  </channel>
</rss>
