Polyrhythm and polymeter can sound similar: both involve multiple rhythmic patterns happening at the same time. But they work in different ways.
The difference becomes especially clear when you look at the code.
- Polyrhythm – different numbers of beats are fitted into the same period of time.
- Polymeter – the beat stays the same, but the beats are grouped into bars of different lengths.
Let’s look at how both approaches work in Sonic Pi.
1. Polyrhythm: Different numbers of beats in the same amount of time
Let’s take a 3:4 polyrhythm.
Over one shared cycle of 4 beats:
- The first voice plays 4 beats.
- The second voice plays 3 beats.
Both voices start and finish the cycle together, but the spacing between their beats is different.
To create this, we use different sleep values:
- 4 beats:
sleep 1 - 3 beats:
sleep 4.0 / 3
Code: 3:4 polyrhythm
use_bpm 120
# Shared cycle - 4 beats
live_loop :bar do
cue :bar
sleep 4
end
# Voice 1: 4 hits - low, dry, grounded
live_loop :four_hits do
sync :bar
4.times do |i|
use_synth :fm
play 36, amp: (i == 0 ? 0.8 : 0.5), release: 0.15
sleep 1
end
end
# Voice 2: 3 hits - high, bright, floating above
live_loop :three_hits do
sync :bar
3.times do
use_synth :blade
play 84, amp: 0.35, attack: 0.01, release: 0.4, cutoff: 100
sleep 4.0 / 3
end
end
Here, :bar marks the beginning of each shared cycle. Both rhythms sync to it, then move forward at different intervals.
The result is two rhythmic patterns that meet again at the beginning of the next cycle.
What changes in the code?
To create a 3:2, 5:4, or 7:5 polyrhythm, we change the number of beats and the interval between them.
For example, with a 5:4 polyrhythm, the shared cycle lasts 5 beats:
use_bpm 120
# Shared cycle - 5 beats
live_loop :bar do
cue :bar
sleep 5
end
# Voice 1: 5 short plucks tight, rhythmic
live_loop :five_hits do
sync :bar
5.times do
use_synth :pluck
play 60, amp: 0.5, release: 0.2
sleep 1
end
end
# Voice 2: 4 long tones sustained, spacious
live_loop :four_hits do
sync :bar
4.times do
use_synth :hollow
play 72, amp: 0.4, attack: 0.3, release: 1.2, cutoff: 90
sleep 5.0 / 4
end
end
The main idea: each voice has a different number of beats, but they all fit into the same overall cycle.
2. Polymeter: Different bar lengths
Now let’s look at a different setup: 3/4 played alongside 4/4.
This time, we’re not trying to fit different numbers of beats into one shared bar.
Instead:
- The 4/4 voice groups beats in sets of four.
- The 3/4 voice groups the same beats in sets of three.
- The duration of each beat stays the same
License
Code: MIT
Text: CC BY 4.0
