Monday, November 26, 2012

Fun and Challenges with Procedurally Generated Music


Here's a fun story.

When we were developing the initial prototype for Conway's Inferno during the 2011 Global Game Jam, we actually implemented a system for procedurally generating music for each level. It's still there, so you can check it out if you're interested.

The procedural generation was pretty darn simple and looked something like this:
  1. Scan each column of the game grid at a fixed rate. 
  2. For each column scanned, count the number of certain objects. For instance, the number of people is recorded in num_people, the number of trees in num_trees, etc. 
  3. Once a count is recorded for each object, choose a sound to play from a list of sounds for each object. (i.e. people_sound <- people_sound_list[num_people Mod len])
  4. For each type of object found in the column (i.e. count > 0), play the chosen sound. 
The goal was that the player's interactions with the level would actively change the music played by the level. Since we had a different set of sounds for, say, living cells and graves, the tone of the music would change significantly as the player killed all the cells. Meanwhile, environmental objects such as trees and rocks would provide percussion.

So you might notice if you play the new version of the game on iOS that it doesn't have any of the original procedurally generated music. What happened? Well, there were a few issues with the procedural system. First up, the general response from the public:

Not a compliment

Now if you've never heard of Crazy Bus, view the video below at your own peril. Personally, I kinda suspect Crazy Bus is just piping its own game code into the audio output stream or something. So in a way it's also procedurally generated "music", but obviously not the kind you'd ever want to be compared to.


Now, I think Conway's music is definitely better than Crazy Bus's, but we also could have improved it a lot if it weren't for the 48 hour constraint of the Global Game Jam. 

Unfortunately, another issue with the procedurally generated music came from the fact that levels that play well don't always intersect with levels that sound good. For instance, here's a shot of level 2 from the original prototype. 

Broken level 2

It may not be obvious, but this level is actually broken design-wise. The original goal of the level was to teach the player that trees could be set on fire to cause explosions that would reach cells one square away.

In the original version, there was just a simple line of cells to the tree in the center (instead of a T-shape) so the only way to win the level was by setting the center tree on fire. After we modified the level to sound better, the player could win by setting any of the inner cells on fire, which was no different than level one. Whoops! This is a good example of how easy it is to break the design of fragile puzzles if you're also trying to design for good audio.

For a fixed version that actually produced the same music as the broken version, check out the revised level 2 (now level 3) from the iOS version below.

Fixed level 2 (now level 3)

Ultimately, the problems of getting our system to sound good while at the same time playing nice with designing fragile puzzles were too much for our limited development time, so we ultimately scrapped the system in favor of a simple looping track.

While our exact implementation of procedurally generated music wasn't quite up to snuff, it was a pretty fun problem to play around with. For an example of a game that I think does procedurally generated and/or interactive music pretty darn well, check out Everyday Shooter on PSN.



Rich Vreeland's January also does some cool stuff with interactive music generation.

Thanks for reading!




No comments:

Post a Comment