Euclidean Algorithm to Generate Beats (Paper and Starting patch)
Stumbled upon this site and this paper. Talks about generating beats and such using Euclid’s algorithm and how it relates to world music:
Site with Example and Code: http://ruinwesen.com/blog?id=216
I wanted to implement this in MAXMSP but I have a feeling I will need to just call in some external Java or C code. Below is what I have so far, all you do is select the number of HITS you want in a certain time frame (beats) and hit compute…all it does so far is generate a list of 1’s (the hits) followed by 0’s (the rests). The real algorithm is supposed to go from there, but I’m not sure how to implement it using MAX objects. Anyone care to look into this? I can easily do any combination by hand, but the whole point would be to automate it and let the user decide all the parameters.
----------begin_max5_patcher---------- 1163.3oc0Yt0iahCEG+4jOEHdNyHeia69z1pJ02pT09TqVshPbm5cASTvnc1 ope2WvFRH2.aBwgUQJP.h4+4mOmiO19GKW3tN+UZgqyu37UmEK9wxEKjWp9B KZ98B2r3WSRiKjOlaRdVFkKbWotmf9pPd8OSKJSEL9KNegtKupMadfTFmljW xkOEp4heKmK3wYT4+721whSae7s6nEUMerfky+yczDgRavvvmAqbfddxC.b8 AD3Yfyez7GYajMV95+5IOTaqwKyX7TpPJcX6qHVj78Jg1o4UMNQdvyu9aLoS aWK2B1aR4BQU29bs18ET8VyKEsuVP8E+4xk0es5Fg76yy1VJnSKaQfHIMgPo 4G0KZglhVTPW1Blur82yEwoNuiFK166ZNJwRqU4rF.6kj.SIojNsjz+7toYC I+H6FPHzO7.Bw8hPRjwHD10YbFfPN8eprjyH31cLtv4Sb5vXrKOLNuGjHS1Q hjoU8B6GHvm8h7fgA2aqW3r1Yu8odEh+cKUIY20w7WbW435djHGDNXuQBGLQ BGL5YO87VNlKnQvk0kBQkmVuD3RADXhw1HP4..7Z65OwFO1XfSWm7tSpS3Lq zz9W7EscPOiLAHRaGqb98zMavcCIpn9u7gO+IyB6wFOlbikqB68mIg8uk5PS XoENvq6SXdbOI3hzAMbRQeYQlAA2.cPSGcJpGNnvHGCjuoNFD4PhpgGIQiKf .Lk17w4HzypMNQOxCoLUUhf.6Y2Yzhh3WnmY3Pm1Of5OSUNRDdrwBpoH.aND 9PSRR2R4abJnhICKistILR53DPd3CcTWxT0mAKZ5niFRIvHoDL.oxmNNJgu2 EPcs4xol4JBiuRoQcXCLZrrgDdkVWu4b.mxjNSU7DLzzzL9JeCB5Pk11IIyI r3lsbiK1.gQOHSerSx.5ORe8FazlSxHkUHdJNIoLqhcg8VVIqdUzLqylLVPD 4eXINryLJuVL+jUZADYboEAgOHO+q3rT9FS6wOGg2BXr.RUVpMG9rmhLFFQl ilPiiiTSMSM1oMWXlpVXMc2UQPsoeVwUrW34UROkk72cMKyWaYnZuOTSH0q2 5QBLeEA75Tp1EZ7aZkQmvoA+Tuv2L+NeiGrVQoPxs328+lLVdirJN6mupLix KGJp730NhInYM66Io5FqptaXyQneyIXTyI9sORUQDUm8q5.xqNqB0t3.ApIT 2aX79oqWaMMpsaQSZlrjzNo8K+BuoParkxhZ99Ho1dmFP2e5Ri2TyH7AjdOS VJaQ417dxdzK0T80OFyE4k6RZ4X6pe5bPXanEBFeu.95g8MpyC8c1lMTd2EO OisYadU2xdWvK1oajlfCoIrU0T8tCMHmPO.MAmWZBgzfSm.y6NmH53iGXWMg 0USP602gmebBpSXmuUkjNYLQ10CGpiGNxtYwqWN3A0Dz29ZZnLlPf80DZ.MY Y2oHcbmrKlpWy3gcmHVUS5TSvI59tiof4GlNIHednIzLTSZkwDM6FrCBrZYJ 5jHvtE8FpwnJ9VkQ5T1jcSLoSN.KWBtl8Zyqhc8tA+npe7yk+GfIgweI -----------end_max5_patcher-----------
Another code example:
Here is a max/msp implementation that I came up with. I can’t guarantee that it is 100% mathematically sound, because like the lisp implementation, its a bit of a hack.
However, I did do a unit test and compared the output of my patch with the results in the paper. Every result of my patch created the same patterns, except many of them needed to be rotated using [zl rotate] for the patterns to start at the same time as the examples in the paper.
Also, keep in mind that the list generation is not instant and probably isn’t suited for changing patterns live/on the fly. Data moves to and from several colls to sort everything so I would expect a bit of a delay to create a list, especially if there is a lot of other things going on.
Also, I just realized that the help file has a sound generator called blip~. Its just a simple thing I put together for testing stuff but if you want the help file work properly just put the attached file in your search path.
Ok. This should have all the files in one zip. I also dropped the print object that was in the patch for testing.
Thanks I look forward to testing this out and seeing how you did it. I’m mad at myself for not being able to do it, argh! the rotation isn’t a problem! I’ll let you know how it pans out.
Quote: Nick Inhofe wrote on Wed, 12 November 2008 20:42
> Ok. This should have all the files in one zip. I also dropped the print object that was in the patch for testing.
Looks good, still going through it to see how you did everything. In the coll #0 rMerge 1, What does the #0, rMerge and 1 mean/do?
#0 is a unique identifier so you can have multiple instances of ndi.bjorkland. Each instance internally shares its data between colls, but that data won’t be passed across intances. The 1 after the name just says that the name isn’t a textfile to be read. This is covered in the coll reference/help file.
Quote: marcoskohler wrote on Wed, 12 November 2008 15:48
> Another code example:
If you see Ruby code you want to try in Max, you can use my Ruby object: http://compusition.com/web/software/maxmsp/ajm-objects
Copy and paste coding is so easy ;)
(but I had some issues copying directly from my web browser to Max, it was converting some of the characters to garbage. I pasted into a plaintext editor and then copied from there into Max textedit and it was fine.)
----------begin_max5_patcher---------- 849.3oc6XssbaBCD8Y6uBMLoyjLiCUBLWbmzm6ePeIISFAnXqTPhQHZbZR92 qtfuDahK9B9o5GvlcWVN5rWzJ+5vANI74jJGv2.2BFL30gCFXDoELn49ANE3 4o43JiYNLxy7jmbFYUIIykFwYjGIhb9yKT7HmIqn+gnUNwE1HkUWPY4DowUn UB40xMkRyL9U8ttFstSY3BiSc9IQjgY3E5rtP9RIwtZbb.22npDKSmQYSePP RkVsnvXEn.iCzWCf5qnHWH3d8S79vg5Ki5HijxKJHL4VTRkjTVcz7Aba9vqK 7QKK5HyZFgB0e4O9nVzJPlPDKdYpUAsntX8UQ6K3joo7btvhGnabn5SznV+E RircwSyzL8GcWDLHNdTq+Zc2IEzpTbtAaP2Isx6day69GTdHUmZ.bRvro6Lk rI536YhNA+O5rmQmw8ZzwaxIL5zdKzR7u.H.ZO5X300NnAm9NnMDRro2osa5 ASHEjpJ7Tx1apPqTICI0RB3Bzc2MBbgWevNg8E63AizeMw1pM3zltLUfSN5c WZoNJ5vXiQcaGWuP6tOv9nBJmiyLUx8vPHwGDs7O6qrfVfmfAQ1nL5TVhLou JQ7GaqT75kZjRAojvx.UDYuLXJr2nEaBQnWeTlTL+I.9oBWQcxK8Bsf5sFpS L67FcbzhlHHYTYaGhArZOmKKqyqHUi.lA4u5NA.ThqUR.e2JBbMvZhQEQ7f4 Nk1Kar6qM5uxUxefpsRPJvTVFQnrpwnurzIFCl8hbVgR6s2a7pQkqjppsAYb vaFAuoUsz1atAfrBVhglG300LABdeymBBnOZeCfaVgLsUpZlF3Pj0BVyybmP IeAokSYjTdMyvbnw6eZjJ9WVKK3YjOO4ZbKIWse5mePXjeuL2RhSV3X3t1wp Y5utt4UjuIIb73ki9bROvnMX2GmXD4efGYrYJOjoryOp0xNCwYxG13ORv3Os 7OxEU7ZQ5hnPyj6fUi+mQpjTFVR4r0rI3C1LilkQXquXKnYkbU3rABeRboqH JnCHJ7rhH0TYpCGraDo66tOPBEG6Fnxmisa4r5liDqgcf81WrdjPZiW2mfI3 4ESvNfoImUH42wJQzYCQwcItcdCacAQdmWH40ALEcDPRcy6C+KPovfCL -----------end_max5_patcher-----------
Max 4 version:
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 168 45 50 196617 deferlow;
#P comment 87 116 34 196617 steps;
#P number 87 132 35 9 1 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 29 132 35 9 1 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 29 180 68 196617 pak 1 1;
#P message 29 207 94 196617 distribute $1, $2;
#P newex 168 266 30 196617 grab;
#P newex 168 20 48 196617 loadbang;
#P window linecount 0;
#P message 29 349 224 196617;
#P window linecount 1;
#P newex 29 320 62 196617 prepend set;
#P newex 29 295 72 196617 mxj ajm.ruby;
#P user textedit 168 73 412 253 32776 3 9 "def distribute(pulses, steps)
pauses = steps – pulses
per_pulse = (pauses / pulses).to_i
remainder = pauses % pulses
rhythm = 
pulses.times do |pulse|
Thanks guys, will look into the Ruby object. For now I created a patch that uses what Nick made, has 6 tracks (For Ableton’s Impulse for example) and lets you select the midi-notes, velocity, etc. If you want to hear how it sounds just in MAXMSP you should send a port "yoursynthdevice" to all the noteouts.
Quote: marcoskohler wrote on Wed, 12 November 2008 22:07
> Thanks guys, will look into the Ruby object. For now I created a patch that uses what Nick made
That was just an FYI for future reference. Since you have something that works, there’s no particular reason to use the Ruby version unless you want to mess with the algorithm and find Ruby code easier to work with. Pure max patches are going to be more efficient most of the time.
Forums > MaxMSP