Friday, February 14, 2014

Bjorklund algorithm

In doing research for another class, I came across an algorithm that I think might be worthy to discuss on this blog (even though it is more "computer science" than "software engineering"). It is called the Bjorklund algorithm and was discussed in a paper called "The Euclidean Algorithm Generates Traditional Musical Rhythms" by Godfried Toussaint (published in 2005). The link is here. Bjorklund's algorithm was developed by, you guessed it, a guy named Eric Bjorklund. Interestingly enough, he published papers on this algorithm while working at Los Alamos Laboratory (in 2003). He was tasked with the problem of maximizing evenness in the operation of components such as high voltage power supplies of spallation neutron source (SNS) accelerators used in nuclear physics. His solution was to use an algorithm that is based on the Euclidean algorithm for finding the greatest common divisor of two numbers. This allowed him to evenly distribute pulses over a given set of intervals for the purpose of setting the timing of the SNS accelerators.

Of course, it wasn't long before musicians and ethnomusicologists began to see the importance of Bjorklund's algorithm, and the Euclidean algorithm in general, when it came to generating rhythms in music. Euclidean rhythms can be found in nearly all world music, such as the rhythm where 3 pulses are distributed over 8 pauses, which can be represented as [x . . x . . x .], with "x" being a pulse and "." being a pause. According to Toussaint's paper, this 3,8 rhythm is very common--in "Cuba it goes by the name of the tresillo and in the USA is often called the Habanera rhythm used in hundreds of rockabilly songs during the 1950’s." The paper lists tens of other Euclidean rhythms used in music from the Middle East, Africa, Greece, and many other countries around the world.

Though I have never played a musical instrument, I do know a little about music and its mathematical properties so it is not a surprise to me that there would be a simple algorithm that can generate these rhythms. However, it is incredible to me that it can generate so many rhythms that are found all over the world. The Bjorklund algorithm itself has been coded in several languages, including Java and Python. The algorithm itself can be somewhat tricky to implement and, if you do it incorrectly, it can be difficult to find a corner case where it will produce incorrect output. However, once you download and/or code the algorithm, you can used it to "play" a MIDI synthesizer (such as in Java) to produce some very nice rhythms. I have also read about people incorporating the Bjorklund algorithm into Max For Live to produce some very nice songs based on these rhythms.


No comments:

Post a Comment