Dynamic interactive game music (blog post from LD40)
  • 1st Jan 2017
  •  • Tags: 
  • music
  • Last updated on 28th Apr 2023

This is a blog post I wrote about dynamic music in LMMS for Ludum Dare 40, for our entry, "Video Games". Thanks again for Bastien for tolerating my weird music ideas :)

🔗How to write dynamic interactive music for your game

Something I've done a few times now for games is composing a piece of music, or rather pieces of music, that overlap, fade in and out accordingly with the rhythm or atmosphere of the game. It's such a fun thing to do and I love seeing it in games like Super Mario Galaxy or Zelda: Skyward Sword. However there are a few things to take into account during the creative process to make that sweet layered audio nectar without it being too cloying.

First of all, a cool sequencer! FL Studio is probably the most common, but since we're all budding programmers let's go for a nice, open-source equivalent: LMMS. I won't explain how to use it, you can find a ton of great tutorials online. It's really simple to pick up :)

lmms.png

In this guide, I'm going to go through the creation of the music for our entry, Video Games. Be sure to give it a try to see what I'm talking about!

🔗Layering or crossfade?

There's two distinct poles of how to arrange your tracks dynamically, crossfade which involves maybe 2 to 4 complex tracks that fade into one another but never play together for more than a second, and layering which can involve as little as 2 but up to maybe 10 simple tracks, which can come in and layer onto the previous one to "assemble" a whole song. The choice between the two will affect a lot of factors in writing the song, such as density, song length, instrument choice...

Make sure you've talked with your programmer as to which direction you're taking! Programmers unexperienced with sound programming or music theory may have difficulty making everything sound right. Luckily for me, the awesome @bastienre4 is always interested in dynamic music, and its always such a pleasure working with him.

🔗Crossfade technique

This is the kind of thing you see in a lot of Nintendo games, and makes for a really dynamic mood-setting that adjusts to the game state, without having abrupt transitions or changing in overall ambience.

So in our sequencer, we need to write 2 to 4 complete songs.

The idea is to write tracks that stand up on their own, that feel dense and rich without needing other effects to support them. So write 3 songs layered in the same project and make sure the harmonies vaguely match up. What's cool with this technique is that you can make songs that are very similar (such as the tracks you hear when walking around Skyloft in Skyward Sword) or drastically different, which really smoothly changes the mood accordingly.

We did this kind of thing for LD32, in our game The Guardian.

🔗Layering technique

This technique really makes the music important in the game, since so many layers can pop in and out at any time. Each track would almost always be paired with a game element that's being activated or deactivated accordingly, such as band players playing their part of a song, or machines in a factory making a distinct noise.

This is what we'll be doing for the project at hand, our entry in this Ludum Dare. We need 6 tracks (which is a lot) So let's get started!

missile

It's important to remember that at a single time, ALL the tracks could be playing at the same time, so we can't make them musically dense or heavy, or the end result will be a fuzzy mess. When choosing instruments make sure to keep clear, simple sounds with little distortion. I'm deciding to make 1 melody and 1 drum beat for each track, which means that they'll be able to stand on their own a little bit more than with a lone melody. Here's the first track I made. It's for the "Missile" minigame, in which you have to keep moving away from a missile heading towards you, so a sense of movement and rhythm with a tinge of urgency is the way to go. I'm using a combination of a squarewave and sawtooth wave, on different octaves each, for a slight chiptune feel. For the drums, I'm going for a simple hihat on every beat.

More tracks! alltracks

Important things to remember when writing all these tracks:

  • Keep the total time short! For game music not to be super repetitive you need to have variations and different parts to your music (a longer track). When in our game, variations will come along naturally as different layers come in and out, so it can stay interesting while being super short. Plus let's be real, you essentially have to write 6 songs! Here I only had 8 seconds of music.

  • No harmonies in individual tracks! You should let harmonies play out between tracks, not within the same track. Also pertinent for the next item:

  • Let each track be a component of a whole! This means 2 things: 1. don't make tracks sound too much like each other, and 2. don't make tracks too musically dense. On the first point, try to make tracks rhythmically different, vary the overall note length, the rate notes are played... maybe one track would have notes every beat and off-beat, maybe another one would have a long, drawn-out melody. The direction I took with this (which I would recommend) is to have each track fulfill a traditional role in the song - in my song I had the bassline done by "Room", some light chords done by "Flappy", an energetic rhodes riff done by "DDR", a long, drawn-out melody done by "Paddle" (which became the main melody in the end? maybe...) and quick-paced melodies done by "Jump" and "Missile". So of course its a similar situation for the drums, the bass drum is mainly present in "Flappy" and a tiny bit in "Room", but nowhere else!

  • Vary melodic directions! if that's how to say it? What I mean is, let some melodies be very short and repetitive, and others longer. You can see in my song that the "Room" motif is played over the space of four "Missile" motifs. This will mean that a simple motif could be played first, then when a longer one is revealed the listener discovers new complexities they wouldn't have noticed with the simple one.

  • Don't forget harmonic accord! It's easy to write all these tracks independently and forget that they have to go together. Once you write a track, listen to it alongside every other track individually. Make sure there's no clashes anywhere with dissonant notes. If a bit sounds weird, try shifting the note up or down a bit, to make it the same chord as the other track, and it will probably fit. Also listen to the tracks all at the same time, and make sure there isn't one that overshadows the others.

On that note, in LMMS to listen to an individual track, click on the "Solo" button beside the "Mute" button for a track (that little red thing): solo

To add other tracks and listen at the same time, just unmute them: unmute

🔗Exporting

Once everything sounds sweet, it's time to export the tracks. Use the "Mute" or "Solo" buttons to select only the track you want to export. Then click on Project -> Export. export

In LMMS you can export as .WAV or .OGG, which is great cause they're two file formats very commonly used in programming.

If you're still using LMMS (which is great! do!) once you choose where you want to export the file, be sure to check "export as loop". That way the silence at the end can be removed, and you can send your file directly to your programmer :D

I might add a few programmer's notes to this once I talk to @bastienre4 about it :)

🔗If you want to know what all this was talking about, be sure to check out our entry in LD40, Video Games!