# Euclidean Algorithm to Generate Beats (Paper and Starting patch)

MaxMSP

Marcos
Nov 12 2008 | 11:47 pm
Stumbled upon this site and this paper. Talks about generating beats and such using Euclid's algorithm and how it relates to world music:
Paper: http://cgm.cs.mcgill.ca/~godfried/publications/banff.pdf
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.

• Marcos
Nov 12 2008 | 11:48 pm
Another code example:
Share
• Nick Inhofe
Nov 13 2008 | 1:30 am
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.
• Nick Inhofe
Nov 13 2008 | 1:37 am
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.
• Nick Inhofe
Nov 13 2008 | 1:42 am
Ok. This should have all the files in one zip. I also dropped the print object that was in the patch for testing.
• Marcos
Nov 13 2008 | 3:07 am
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.
• Marcos
Nov 13 2008 | 3:49 am
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?
• Nick Inhofe
Nov 13 2008 | 4:51 am
#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.