Max-only Euclidean Sequence/Rhythm Generator
Hi Maxers,
N00b coder here.
I've been working on a MIDI sequencer project and got the itch to add Euclidean rhythms.
Bad. Decision.
Totally fell down the rabbit hole...
I read Godfried Toussaint's seminal paper "The Euclidean Algorithm Generates Traditional Musical Rhythems" countless times - as others have pointed out, it's a nice explanation of what Euclidean rhythms are but not how to turn Euclid's 2000+ year-old Greatest Common Divisor algorithm into usable code.
I finally came across a Computer Music Design article on "Simplest Euclidean Rhythm algorithm, explained" (https://www.computermusicdesign.com/simplest-euclidean-rhythm-algorithm-explained/) that included procedural (rather than recursive) pseuodocode.
Based on this, I've hammered out what looks like a usable Max-only implementation:
My request to all of you Maxers out there is to please have a look at it and critique candidly. Please feel free to suggest a more canonical way to code this. I learned C.S. in the days of the dinosaurs and haven't coded in years (not my day job) - I'm 2-3 weeks into learning Max.
BTW, huge shout out to 11oLsen for his comments and code (https://cycling74.com/forums/using-euclideanbjorklund-algorithm-for-rhythm-generation-purely-in-max/) in a prior thread.
Many thanks!
J
Hi,
Thank you very much!
It seems to me working better than any other euclidean rhythm sequencer I have tried before. So this is very good and flexible. Of course, visual clock object would make setting fluent (but possible to full use also without). I have idea to figure out how to make automatic setting templates (for all parameters for all clocks same time) for different kind of use.
Here is some improvised examples, where I use this patch:
https://soundcloud.com/janne-nummela/what-is-seen-is-temporary-but-what-is-unseen-is-eternal
https://soundcloud.com/janne-nummela/202106221a
https://soundcloud.com/janne-nummela/2021061812a
- Janne
Thank for your shoutout. Your versions is awesome. It corrects a bug i did not notice for a long time where some sequences came out already rotated. ()https://cycling74.com/forums/euclidean-rhythm-as-list
here's another version i made a while back based on this https://medium.com/code-music-noise/euclidean-rhythms-391d879494df
haven't checked if it is 100% correct but there's a fun trick with the histo object
Elegant use of `hist`. Exactly what I needed.
Nice! I hadn't noticed the rotation problem either until I came across your version.
Btw... If you add [zl.rev] and [zl.rot 1] at the end of all those "wrong-calculated" euclidean generators, you'll end up with the correct Godfried patterns.
At least with the ones I've been trying.