Euclidean Algorithm to Generate Beats (Paper and Starting patch)

Nov 12, 2008 at 11:47pm

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:

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.

– Pasted Max Patch, click to expand. –
#40813
Nov 12, 2008 at 11:48pm
#144784
Nov 13, 2008 at 1:30am

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.

#144785
Nov 13, 2008 at 1:37am

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.

#144786
Nov 13, 2008 at 1:42am

Ok. This should have all the files in one zip. I also dropped the print object that was in the patch for testing.

#144787
Nov 13, 2008 at 3:07am

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.

#144788
Nov 13, 2008 at 3:49am

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?

#144789
Nov 13, 2008 at 4:51am

#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.

#144790
Nov 13, 2008 at 5:00am

Quote: marcoskohler wrote on Wed, 12 November 2008 15:48
—————————————————-
> Another code example:
>
> http://blog.noizeramp.com/2008/10/26/rhythm-generation-with-an-euclidian-algorithm/
—————————————————-

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.)

– Pasted Max Patch, click to expand. –

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|
rhythm

#144791
Nov 13, 2008 at 6:07am

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.

#144792
Nov 13, 2008 at 7:38am

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.

#144793

You must be logged in to reply to this topic.