Bach 14 Canons: a project for Sonic Pi

Those of you familiar with my work using Sonic Pi will know that I enjoy coding classical music to run on Sonic Pi. One composer I particularly like to use is J.S. Bach. Recently I came across a collection of 9 Canons which he wrote, which were only “discovered” in 1974. There is a superb video which illustrates the history and the composition of these Canons.

Having seen it, I thought that it would make a good project for Sonic Pi to generate the parts for the canons, many of which are produced by a process of inversion where the parts are essentially mirrored and turned upside down. At other places parts may be reversed, or played at half or quarter speed. All of these are possible for Sonic Pi to perform, without cheating and writing out the parts completely.

Having got the code working, I thought it would be nice to illustrate Sonic Pi playing some of the canons using its own synths, and others by exporting midi commands to Ableton Live and reimporting the audio produced by virtual harpsichord instruments back to Sonic Pi. I also wrote a simple Processing sketch to display images of the music being played, and used OSC messages to select the particular image, so that they could be changed in time with the music. I’m sure that Bach would have enjoyed using Sonic Pi too!

I hope to write a fuller article on this, and to publish the code eventually, but for the moment you can enjoy seeing a video on you tube of the results, or just to listen to the canons on SoundCloud


Wonderfully done! Thanks for the Bach 14 Canons on Sonic Pi! Looking forwarding to playing with code if/when you release it.

1 Like