Since the time of Pythagoras around 500 BCE, music and mathematics have had an intimate and mutually supportive relationship.

Mathematics has been used to tune musical scales, to design musical instruments, to understand musical form and to generate novel music. But what can mathematics say about one of the most common features of contemporary music – rhythmic loops?

Repeated rhythmic loops are an essential component of most electronic dance music and hip-hop, and also play an important role in rock, jazz, Latin and non-Western music.

Now, two mathematical models of rhythmic loops – made in a free software application called XronoMorph – can be used to generate exciting new musical structures that would otherwise be hard to compose or perform.

XronoMorph: An Introduction

Rhythmic loops: Circles and polygons

A natural geometrical characterisation of a periodic structure, such as a rhythmic loop, is as a circular arrangement of points. You can travel clockwise around a circle but inevitably you come back to where you started.

A common feature of rhythmic loops is that they are multilevel. For example, in Latin percussion, different instruments play different interlocking patterns that may or may not coincide. Such rhythms can be depicted by multiple polygons on the same circle.

A simple geometrical representation is to draw lines that make each of these independent levels into an independent polygon. In this way, a multilevel rhythm becomes a collection of inscribed polygons.

Clave (top) + Conga (bottom) rhythm in score notation. Andrew Milne, Author provided
Clave (red) + Conga (blue) rhythm as polygons. Andrew Milne, Author provided

But which polygons?

There are more than 17 trillion different rhythms, and that is only counting rhythms with three levels where every beat occurs at one of 16 distinct time locations (16 being a very common temporal subdivision in music).

But, realistically, only a small proportion of these are of musical interest. The trick is to find them.

Two mathematical principles – well-formedness and perfect balance – allow us to easily navigate two distinct rhythmic sub-spaces that are of musical interest, but hard to explore with traditional computational tools or notation.

Well-formed polygons

Well-formedness elegantly generalises three properties commonly found in real-world multilevel rhythms:

  • each rhythmic level comprises only a small number of distinct beat lengths, often only one or two;

  • each level’s beats are fairly evenly spaced in time – there aren’t sudden clusters of events followed by long gaps; and

  • the rhythmic levels are hierarchical – there is a slow and metrically dominant level; above this is a faster and weaker level that splits the previous level’s beats; above this is an even faster and weaker level that splits the previous level’s beats; and so on.

Every level of a well-formed rhythm has two beat lengths: a long beat and a short beat. The length of a given beat is the time between its onset and the onset of the following beat.

A multilevel well-formed rhythm can then be fully defined by three numerical parameters: the numbers of long and short beats in the lowest level rhythm, and the ratio of the sizes of its long and short beats.

From these three numbers, an entire rhythmic hierarchy can be calculated, such that each level has no more than two beat lengths, each level arranges these beat lengths to make them as evenly spaced as possible and each successive level in the hierarchy is created by splitting the long beats of the level below.

Using XronoMorph, the above three parameters can be freely manipulated. The rhythmic hierarchy emerging from them often has great aesthetic appeal. Every level is related to every other level and is also intrinsically well-formed. Together, they create a somewhat self-similar and interwoven structure reminiscent of fractals.

A demonstration of how a well-formed hierarchy is built, and the effect of the lowest level’s beat-size ratio.

Perfectly balanced polygons

Perfect balance is a mathematical principle that can generalise polyrhythms, a type of rhythm commonly used in sub-Saharan African music.

Unlike well-formed rhythms and most Western rhythms, polyrhythms are not hierarchical. They are more like an alliance of different rhythmic levels, each of equal status.

In a polyrhythm, two or more levels, each comprising evenly spaced beats, are superimposed.

Geometrically, they are combinations of regular polygons like equilateral triangles, squares, regular pentagons, and so forth. In real-world polyrhythms, beats from all levels typically coincide at a single location in the period.

A standard 2:3:6 polyrhythm. For clarity, the hexagonal level is not shown.
A standard 3:4:12 polyrhythm. For clarity, the 12-gon level is not shown.
A standard 3:5:15 polyrhythm. For clarity, the 15-gon level is not shown.

A notable feature of these polyrhythms is that the average position, or centre of gravity, of the circularly arranged beats is precisely at the centre of the circle. This property is defined as perfect balance.

All regular polygons are perfectly balanced, so any combination of regular polygons is also perfectly balanced, and this is true regardless of the individual rotations of the polygons.

This allows an immediate generalisation of standard polyrhythms. The regular polygons can be independently rotated (time-shifted) so they never coincide. This is a musical feature that is, as far as we know, rarely exploited but which produces exciting rhythmic grooves.

Perfectly balanced music constructed with independently rotated regular polygons: 2 digons, 3 squares, 1 heptagon. The polygons have been independently rotated so – unlike a standard polyrhythm – there is no single location at which they all coincide.

But perfect balance opens up yet another fascinating generalisation of standard polyrhythms. There are certain perfectly balanced shapes – irregular elemental polygons – that are not produced by a simple combination of regular polygons.

An irregular elemental polygon: 1 triangle + 1 pentagon - 1 digon. Only the labelled vertices are sounded. Andrew Milne, Author provided
An irregular elemental polygon: 2 digons + 3 pentagons - 3 digons - 2 triangles. Only the labelled vertices are sounded. Andrew Milne, Author provided

Intriguingly, such polygons are constructed by summing differently rotated positively-weighted and negatively-weighted regular polygons. When a positively-weighted vertex and a negatively-weighted vertex coincide they cancel out.

Legal patterns are produced when no negative weights are left behind. So, although we never hear these negative beats directly, they have a ghostly impact by cancelling out some of the positive beats.

In XronoMorph, a wide choice of regular and irregular elemental polygons can be combined and independently rotated, creating a fascinating subspace of generalised polyrhythms.

Perfectly balanced music constructed with regular and irregular elemental polygons.


We developed the rhythmic loop generator XronoMorph to demonstrate these principles, hoping it might inspire musicians and music enthusiasts to create novel and interesting rhythms that would be hard to play manually or to otherwise compose.

Simple and attractive software interfaces can also transform a need for expert knowledge into a willingness to intuitively interrogate the interface. In this way, we also hope it will encourage musical engagement, with potential application in music education by allowing visual exploration of complex rhythmic patterns.

Early reaction from musicians and composers has been highly enthusiastic with comments such as “This is an inspired design – truly musical”, “the most interesting and inventive new app around” and “this really helps me better understand and create beats”.

This lends support to the long-held notion that there is a profound connection between mathematics and music, and that a little mathematics can help create some beautiful music.

XronoMorph screenshot. Andrew Milne, Author provided
The Conversation

Andrew J. Milne, Postdoctoral Research Fellow in Music Cognition and Computation, Western Sydney University and Steffen A. Herff, PhD candidate, Memory and Music Perception, Western Sydney University
