Euclidean rhythm – Wikipedia

Source: Euclidean rhythm – Wikipedia

 

Stuart Errol Anderson

I found this algorithm on the web by Brian House https://github.com/brianhouse/bjorklund which generates single lines of Euclidean rhythms
I had to hack it a little for my linux system, then generated 64 lines from 64 1 to 64 64
To generate a line using python, for example an 8 7 Euclidean rhythm, type;
python3 example2.py 8 7
– but first save the next lines as file example2.py
import sys
def bjorklund(steps, pulses):
steps = int(steps)
pulses = int(pulses)
if pulses > steps:
raise ValueError
pattern = []
counts = []
remainders = []
divisor = steps – pulses
remainders.append(pulses)
level = 0
while True:
counts.append(divisor // remainders[level])
remainders.append(divisor % remainders[level])
divisor = remainders[level]
level = level + 1
if remainders[level] <= 1:
break
counts.append(divisor)
def build(level):
if level == -1:
pattern.append(0)
elif level == -2:
pattern.append(1)
else:
for i in range(0, counts[level]):
build(level – 1)
if remainders[level] != 0:
build(level – 2)
build(level)
i = pattern.index(1)
pattern = pattern[i:] + pattern[0:i]
return pattern
try:
steps = int(sys.argv[1])
pulses = int(sys.argv[2])
except Exception:
print(“usage: python bjorklund.py <STEPS> <PULSES>”)
else:
print(bjorklund(steps, pulses))

https://www.facebook.com/groups/391950357895182?multi_permalinks=1802928763463994&hoisted_section_header_type=recently_seen

Leave a Reply

Your email address will not be published. Required fields are marked *