Maikovsky: Composing Folk Music with Markov Chains

Posted October 14, 2018. 154 words.

This week I used Markov Chains to create folk music. It is output in ABC and rendered using ABCjs.

Turnpike To Martindale's Trip

The music it makes is a little bit strange and it doesn’t really understand how many beats should be in a bar, but if that is a problem up the iterations. Keep raising the iterations and eventually you might even hear a tune that you know!

Under the hood, it is relatively simple. I started by downloaded about 300 folk tunes from sourceforge. After making an Ajax request to load them, it “parses” each tune into a data structure that is easy to work with. Then two Markov Chains are generated for the title and for the music, the other attributes are just chosen randomly.

Tunes can be played back with or without chords, and on any instrument. Click here to start.

StatCounter Pixel