Dynamic Music

You will be glad to know that we all survived a) the Gaslamp Games Christmas Party, and b) the Snowpocalypse in Vancouver, with only minor cases of frostbite and damage to clothing. However, this has made today’s blogpost a bit on the late side and we apologize. People have wanted to hear about this for awhile, so as a special treat – let’s look at Clockwork Empires’ dynamic music system.

The motivation for trying something different with Clockwork Empires and music stems from Dredmor. Dredmor had a great soundtrack, but we heard a lot of people comment that, after a certain point, there was only so much of the soundtrack that you wanted to hear in a game that has over a hundred hours of playtime. To fix this, we got inspired by a piece of technology that the Introversion guys developed for their cancelled spy-thriller, Subversion. Specifically, this video. The other inspiration was the Director from Left 4 Dead 2, which tracks player “mood” to adjust the flow of gameplay. Why not just build something that tracks the “mood” of the story, but simply uses it to change the music to suit your narrative? After all, we are a game that is all about narrative.

Clockwork Empires tracks six indicators internally. Ambience, Battling, Discovery, Producitivity, Tragedy and Insanity:

  • Battling goes up when you’re fighting,
  • Discovery goes up when you’re discovering things (exploring the map, doing research, SCIENCE, etc.),
  • Productivity goes up when you are performing acts like industrial construction and goods production,
  • Tragedy goes up when people die or are hurt, stuff is destroyed, and people are upset.
  • Insanity goes up when… well, the madness spirals and all know the rule of the Invisible Geometers’ invisible fist-analogues.
  • Ambience is just always on, but it can be pushed out by other tracks.

As somebody sussed out, internally this is just loading six (or however many) tracks of music from the disc and mixing them. Individually, Matthew Steele (who you may remember from Dungeons of Dredmor) creates six tracks for one “song”. In this case, these six tracks are little snippets of Chromium (All our musical tracks seem to be named after metals this time around, which is interesting.)

Ambient (Chromium)

Battling (Chromium)

Discovery (Chromium)

Productivity (Chromium)

Tragedy (Chromium)

Insanity (Chromium)

We put all the scoring information that is generated by the game, with weights to sort of make it work correctly, into a histogram. We let information that is older than a certain number of game ticks fall out of the histogram, and we put new information into it as it arrives. The result is that you don’t get harsh changes and transitions between new modes. Then, based on a set of rules (“don’t mix track P with D”, “if Insanity is over 50 start playing the insanity music”) that is customizable for each track, we get a dynamic mix that adapts to your gameplay. The magic, due to Ryan, is that we are able to efficiently load, decode, and mix a lot of streaming OGG files together very, very quickly. Mixing six tracks of music takes a little over 2% of the CPU available on my laptop, which is last year’s Macbook Pro. What you get might sound a bit like this:

Mix Demo

although this is chopped together very rapidly to show you two different sorts of “musical textures” you might get; in the real game, everything has smoother and longer transitions.

For those interested in the specifics of music, Mr. Steele has been going back and forth on the question of “what is steampunk, anyway?” While building the game, we have been trying to allow for a variety of different instrumentation for different moods. Prepared piano, a la John Cage, shows up at various points, and various tracks are peppered with recordings made from the Mellotron, an old tape-based keyboard from the 60’s that you may remember from such hits as the Beatles’ “Strawberry Fields Forever”. It provides the distinctive Dredmor strings that you hear on tracks like “Diggle Hell is a Real Swingin’ Place”, and so far I believe it is mainly used for flutes and choir. Some other old synthesizers are used as well, such as the Polymoog (famous for its use by Gary Numan on his hit “Cars”) and the Hammond Novachord, an antique tube-based instrument from the early 30’s and the first true synthesizer ever invented. The whatever-the-heck-you-hear on the Insanity Tracks is created by a more modern instrument, the Poly Evolver by Dave Smith Instruments. And, on top of that, we have the usual assortment of strings, brass, kalimbas, woodblock, and cowbell.

Posted in Clockwork Empires | Tagged , , , , , , , ,
20 Comments

20 Responses to “Dynamic Music”

  1. Headjack says:

    Babbage will have your head for this.

    { reply }
  2. Matthew says:

    In the mix track, things went from good to bad to tragic. Is this a concentrated version of CE gameplay? Hmm!

    { reply }
  3. Alistaire says:

    So will there be multiple melodies, all with variations based on mood?

    Or will it be like Simcity 4, where you have the tracks playing based on how far your city has developed; in the beginning it all sounds peaceful, but whenever you plunk down huge clockwork factories the music starts to sound epic and it feels as if you’re doing amazing stuff for his majesty, King Ebenezer of the empire.

    { reply }
  4. Ruigi says:

    Any of you guys played Civ2 Fantastic Worlds? There’s this track called “The World of Jules Verne”

    Any chance we could get some massive organ?

    { reply }
    • Ruigi says:

      Another cool use of soundtrack in gameplay was from Sid Meier’s Alpha Centari. I remember when you played as the Human Hive, it would play this cool riff whenever you founded a new settlement.

      { reply }
  5. Faldrath says:

    Mellotrons make everything cooler. I heartily approve.

    { reply }
  6. Wootah says:

    Despite it being short, this has been one of my favorite CE blog posts. The music sounds fantastic and sets the mood extremely well. The mixing demo was good and I can’t wait to hear it all rolled together.

    Questions for the Developers
    1. Are there any variances in tempo and pitch based on the rating system?
    2. I assume there will be more than than these 6 tracks for the 6 moods, but are there going to be tracks that are written to play concurrently, like tracks with variations in arpeggiation for various background instruments — similar to what is done for many electronic music?
    3. If older systems cannot afford the processing power, will the game detect, or will there be an option to just play traditional tracks?

    { reply }
  7. Riley says:

    Rock it out M@. 🙂

    Way to apply creative uses of your amazing musical skills to a company that loves retro as much as you do. 🙂

    { reply }
  8. Althea says:

    This is AWESOME. Game music design isn’t talked about enough.

    { reply }
  9. Jabend says:

    Sounds very interesting indeed, but I have one question. Will music play universally (playing battle music because my border patrols are exterminating the routine invasions of mushroom men, regardless of if I am watching the fight or not) or will music play depending on what is viewed? (moving the camera across the map causes shifts in music as I scroll past the various factory, research, and asylum districts)

    { reply }
  10. Essence says:

    Those samples. They need more cowbell.

    { reply }
  11. Aegis says:

    Never can have enough cowbell 😀

    { reply }
  12. Lorrelian says:

    With this unique method of mixing tracks, will there be a traditional soundtrack release or is that somehow precluded? I know I’d throw some money at those tunes…

    { reply }
  13. Kazeto says:

    It sort of reminds me of Total Annihilation (and then many other games after it), where there was just distinction between battle music and non-battle music but it was so innovative for the time you were all jolly when playing it.

    That being said, I really like this post and the idea described therein.

    { reply }
  14. Jumonji says:

    Hey, have you guys ever heard of the theremin? It’s an instrument that gives one that weird noise that’s common in older sci-fi films. (Example of the creator playing his own instrument: http://www.youtube.com/watch?v=w5qf9O6c20o ) It’s actually really interesting; no idea if that would be of any interest for you guys at all :3

    { reply }
  15. Greg says:

    I love dynamic music. I’m a total nerd for it. Back in the day when games used Amiga MOD format music (and its derivatives) it seemed to be more common, and died out a little with the fidelity promised by PCM (redbook CD audio and later mp3/ogg).

    Recently, Diamond Trust of London demonstrated an interesting technique using sample sets and a random seed, plus game states influencing the progression. There’s a youtube video on it, which I won’t link to avoid spam filters.

    Wizardry 8 used an interesting system – rather than live-muxing multiple streams, they had pre-recorded different flavors of songs into 30 second clips, and then did logarithmic crossfade between them when the situation demanded a change. Youtube has plenty of Wizardry 8 videos too. Although your system is superior to this, just thought I’d mention it.

    Anyway, very much looking forward to whatever system you cook up. Awesome.

    { reply }
  16. Intrinsic says:

    When you said “what is steampunk, anyway?” i instantly thought of the music from the classic Amiga game The Chaos Engine, a wonderful steampunk inspired action romp with awesome music that just screams steampunk to my ears.

    http://www.youtube.com/watch?v=3enImd8QVQ4

    { reply }

Leave a Reply to Faldrath { cancel }

Your email address will not be published. Required fields are marked *