Max-only Euclidean Sequence/Rhythm Generator


    May 16 2020 | 2:30 pm
    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

    • Jun 23 2021 | 6:50 am
      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
    • Jun 26 2021 | 9:10 am
      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
    • Jun 27 2021 | 2:32 pm
      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