Recently I've been playing around with Euclidean rhythms. Exploring stacked polyrhythms and asymmetrical looping. I tend to prefer it's output when not using gcd-based numbers (the original paper used it to recreate middle-eastern/traditional rhythms).
The Python implementation I am using
# Euclidean Rhythm in vanilla py3
def euclidean_rhythm(beats, pulses):
"""Computes Euclidean rhythm of beats/pulses
Examples:
euclidean_rhythm(8, 5) -> [1, 0, 1, 0, 1, 0, 1, 1]
euclidean_rhythm(7, 3) -> [1, 0, 0, 1, 0, 1, 0]
Args:
beats (int): Beats of the rhythm
pulses (int): Pulses to distribute. Should be <= beats
Returns:
list: 1s are pulses, zeros rests
"""
if pulses is None or pulses < 0:
pulses = 0
if beats is None or beats < 0:
beats = 0
if pulses > beats:
beats, pulses = pulses, beats
if beats == 0:
return []
rests = beats - pulses
result = [1] * pulses
pivot = 1
interval = 2
while rests > 0:
if pivot > len(result):
pivot = 1
interval += 1
result.insert(pivot, 0)
pivot += interval
rests -= 1
return result
Also on a gist with tests.