One of the hardest things for an independent developer to find when starting out is music. It's not difficult finding royalty free or Creative Commons licensed music for your games, but it is difficult finding music that has a decent quality and that "fits" your game. You can spend literally days searching through the public domain sites and never find anything that captures your attention and hope that you eventually find your diamond in the rough, or you can just give up and go hire someone (or just go visit Incompetech.com like everyone else).
However, before you decide, what if I told you there was another option? It’s called procedural generation, and you'd be surprised just how good music made this way can sound!
Procedural generation is not something new and games have been using it for a long time to generate worlds, randomise item drops, or create unique characters, but it’s very rarely used for music. This is because the human ear is trained from a very early age to accept certain structures, harmonies and frequencies as "musical" and trying to get a machine to choose which of these things is going to be musical to the ear is a difficult task.
But music is, at its heart, a mathematical thing, with scales and harmony having a defined and documented mathematical base… and being mathematical means that it can be programmed too! You can set certain start conditions within a program and have it generate a musical piece based on those conditions. Things like instrument, tempo, base scale, structure, etc... can now all be set as "seeds" for the random generator and a complete musical piece created from that. Obviously, how it sounds will vary greatly as there are a vast number of algorithms out there that can be used and an infinite number of variations (as well as programing skills!) on them. But some can give exceptional results with a bit of practice and learning, and below I've listed some of the best or most interesting generators that I’ve found.
I should point out here that there are remarkably few generators of this type actually available currently - which is a bit of a shame I think - and one of the ones on this list can no longer even be bought, but I've included it because the free version is still pretty fun to play with. Procedural generation of game content has become commonplace and we see it being used in a lot of games, but that content doesn't usually apply to the music (with the grand exception being No Mans Sky). I hope that we'll see a resurgence of interest in this idea, because I think it's still got potential...
Also note that most of these programs only export as a midi file, which may put you off. However there are many tools available for converting midi into mp3 - as this Google search shows - although one of my favourites is the fantastic GXSCC and its Famicom retro sounds!
Wolfram Tones was a very quirky music generator and was definitely not be to everyone’s tastes. However, with a bit of patience and trial and error it could produce some fascinating results. It worked by taking simple programs from Wolfram’s computational universe, and using music theory and Mathematica algorithms to render them as music. The beauty if that approach was that sometimes it was reminiscent of familiar musical styles and sometimes it was like nothing ever heard before…
Note that the whole last paragraph is in the past tense as sadly it seems that in the last few months the Wolfram Tones site has broken and is not being maintained - which is somewhat of a shame as it was an interesting and fun tool to use. Personally I found it fun to work with but wasn't too impressed by the final output - which sounded very odd and not always harmonious - but I didn't spend too much time tweaking stuff, so it could be that with a bit of effort more complex and melodic compositions could have been created. Although it's currently broken, I mention it here so that you can bookmark it and come back to it later to see if they have updated or fixed things...
Sound Helix is quite a fantastic open-source tool for generating music, but be warned that it’s not for the faint hearted! It takes data in the form of an xml file and then parses that through a Java app to generate the finished piece, meaning that it has a very steep learning curve and won’t be to everyone’s taste. However if you check out the examples provided with it - like this one, which is pretty decent - and think that it can do what you need, then it will certainly pay off to invest the time needed to learn its inner workings, especially if you are looking for modern, upbeat or ambient music, which is what this seems to excel at.
CgMusic was created by game developer Maciej Biedrzycki and was developed as part of his Masters thesis specifically to fill the gap between small development teams with little money and full studios with a budget for music. This program is not by any means the most powerful tool I've found out there, but it is definitely one of the most accessible. It provides a comfortable and clear UI that permits you to “play” with values and learn what they do without too much knowledge of music theory, and yet it is still powerful enough to create pieces that are convincing and useful. The only downside to this package is that the documentation for the scripting language it uses is not available in English, however I think that for everyone except the most courageous or advanced this isn't too much of an issue.
MusiGenesis works by adding randomly-generated notes to a “song” and letting you decide whether to keep or delete each one. By keeping what you like and deleting what you don’t like, you can quickly create a unique piece of music that has been formed in part by you and in part by the machine. This two-way approach to generating random music works really well and it's great fun to tinker with the program and see what you can come up with. Sadly that's all you'll do with it, as it appears that the website and purchase orders are no longer maintained, meaning that all you can get is the demo - you could try the contact email and see if you get any responses too - which won't let you export as any format other than the proprietary one the program uses. So, no MIDI, mp3, or wav available, but it's still good fun and there are other ways to capture audio which could be possibly be used.
I saved the very best for last here, as Abundant Music is by far the most outstanding piece of music generation software available currently in my opinion. It is Web based, so you can compose in your browser, and it has a huge array of options for you to tweak and play with. Unfortunately I found that the user interface was not all that great and was quite difficult to navigate around to start with, but once you’ve been using it for a while you’ll soon get used to it.
The program itself allows you to create some surprisingly complex - yet natural sounding - tunes, and you see them too thanks to the 3D background showing the piano roll! Just about everything you can think of can be given a specific or random seed, and you can modify the structure (chorus, verse, bridge etc…) as well as choose the instruments to be used. This means that Abundant Music is pretty massive in scope and it can be daunting to start with but I'd say it's very much worth the effort to learn, as it was by far the best of all the tools I've found so far.
I feel that this article wouldn't be complete without two further things being mentioned... The first is called Fake Music Generator, and it's a really nifty little tool that won't only generate a song for you, ut a whole album! Complete with fake names, titles and composers as well as the album cover art... The msuic itself isn't that great, but after listening to about a dozen songs, there were at least two that I could actually use, which is a pretty good ratio. However you have to download the sounds to listen to them as there is no preview widget built into the page which is a bit of a pain.
The second mention goes to LPMG (Lemon's Procedural Music Generator) which was created using GameMaker itself! While it's by no means perfect it's still fun to play with and creates some passable results. The fact that it was created by a GameMaker community member makes it all the more impressive...
My final impressions on procedural music are that it is a subject that isn't explored enough and has the potential to greatly help out small development studios. As a tool to flesh out prototypes before hiring a musician it's great and should certainly be considered, but for final games I think it still has a way to go, although the sheer quirkiness of the music most generators produce could be a bonus for some styles of puzzle or ambient games, so don't rule it out completely.