Monday, March 07, 2011

Music Generation Thoughts Part 1

I've been working on a simple artificial intelligence to generate music. I use my own software for music and this has lots of advantages (beyond cost, which was the original motivation for programming it!)

My original idea was based on frequency analysis, that is of notes as in letter-frequency analysis, not of the frequencies of sound waves. The aim is to analyse existing music and produce original music based on it using probabilities. This is quite complex though.

Music has several components, pacing and timing as well as melody, chords which go with the melody, counterpoint, and lots of repetition. A tune is more creative at the start, with the initial idea or theme often being repeated later, so any artificially intelligent composer must mimic these features. I decided to give the tables self-feedback which should help with this. Music is surprisingly repetitive when analysed, but it can also vary in key, which could confuse the computer. To a human, the notes might even sound the same, although in a different key. As music is designed for humans, there are also issued of boredom, if the same features repeat too often.

Also creativity can back-feed. I write music forward to back, I guess most composers do the same (although I can see that adding bits into other movements, here and there, bits and notes from previous ideas might also work). Sometimes a change made at the end would add more structure to the piece when some changes are made to the beginning.

The ultimate key to artificial creativity though is analysis of existing forms, self-creation, then self-criticism and analysis, evolution even, until a desirable form is reached. The computer will have to know what is good and bad music.

There are lots of ways to analyse music. Currently I'm looking at timing and have built tables the the frequency of note on the beat, half beat, quarter beat etc. Then there is global patterns, the computer must have some scope beyond the local to see the shape of the whole tune. Then very local patterns, the patterns in repeating themes.

The ultimate goal should be to identify these patterns, and be able to generate and recognise them.

My plans so far are very simple and involve just one voice. More would be a matter of seeing more patterns beyond a single track, and more instruments or volumes would really complicate things!

Anyway, today I've build the basics into my software and added a simple set of analysis tools with the ability to create any number of analysis tables, save and load them, and perform simple calculations on melodies. As the software is essentially my virtual studio I've got no end of tunes to feed it. The ideal would be to feed it some Mozart or something and have it generate an original tune in the same style.

This blog entry is a definite ramble! And like many such rambles partly designed to flesh out my thoughts.