How is writing music for video games different than writing music for albums?

When composers say they write music for video games, they’re usually referring to a process that’s often substantially different than writing music for an album or a single that will be downloaded on iTunes and streamed on Spotify. Although it’s possible to get your song from an album placed in a video game such as Rock Band, what I’d like to share with you in this post is what you’ll likely encounter if you want to start writing custom music for video games.

Why me?

To be honest, I’m relatively a nobody when it comes to music for games. That said, I do have a decent amount of experience and success with writing music for video games, and I think you might be interested in hearing about what I’ve learned over the past decade, especially if you are just starting out.

In addition to releasing lots of albums and publishing hundreds of tracks for things like film, TV, commercials, etc., I’ve also composed music for around 15 games, and countless game prototypes. Many of these games have been played millions of times. From super-simple web games, to mobile games, to downloadable PC/Mac games, all the way to a 3rd-person shooter launch title for Amazon’s Fire TV, I’ve composed a wide range of music for lots of different platforms. And as you can read in my bio, I was the lead game-play programmer for many games. During my time as a game programmer, I also worked on audio-specific aspects of games, such as audio engines/tools, worked with third-party audio software such as Wwise, as well as implemented audio and music in games.

In what ways is writing music for video games different?

In this article, I’d like to cover some ways in which writing music for video games is different than writing a standard music track. I’ll also try to include some tips and tricks that you might be able to use in your own game projects. These are the topics I’ll be discussing.

  1. Lots of Types of Music
  2. Loops
  3. Intros and Outros
  4. Shuffled Loop Blocks
  5. Playlists
  6. Layering
  7. One-Shots and Stingers
  8. Positioning Music in 2D and 3D Space
  9. Quality and Encoding Issues
  10. Frequency Issues on Mobile

Even though writing music for games is usually really fun, it can be very challenging at times. I doubt most people realize how much thought and effort can go into making music for games.

I’ve personally used most all of these techniques below at one time or another for one or more games. Some are super simple, but some are much more complex. Let’s start by looking at the type of music you’ll likely need to create when working on a game.

1. Lots of Types of Music

When you write music for an album, you have to think about things like whether or not the music has a cohesive sound and all of the tracks sound good together and/or tell a story. This is also important with game music. However, each track on an album usually follows the same format: 2-6 minutes of music with an intro, verse, chorus, bridge, and ending. For game music, you have to be prepared to create all sorts of formats of music. Here are some different types of music you might need to create:

  • Loading screen music
  • Main menu music
  • Sub menu music
  • Musical sound effects and stingers for menus and in game
  • Pre-game music
  • Level start music
  • Main game level music
  • Level end music (win music and lose music)
  • Music for side games and mini games
  • Event-based music
  • Boss battle music
  • Win game music and lose game music
  • Cutscene and in-game cinematic music
  • End credits music
  • Trailer music

And to complicate things even further, many games have different themes for each level or sets of levels, which means that you might need to create several themed versions for much of the music above. For a medium-size game, a composer might create a hundred separate music files for the game.

Creating music for a new game project can be a daunting and complicated task… so normally, you try to plan out all of the music you think will be needed in the game before you start working on it, similar to how you would spot a movie to determine what music cues you need.

Being organized is very important for a game composer. Not only do you need to keep track of all of the different themes, variations, and versions of the music above, you also need to be able to do “simple” things like name all of the music files in such a way that the audio programmer, who will be putting your music into the game, can easily understand and follow your changes. What a bummer if you spend hours creating a new version of a track, only to discover that an old version of that track made it into the published game… all because the audio programmer thought he was using the correct audio file or he didn’t realize there was a new file that he should have used instead!

2. Loops

As a musician, you’re probably already very familiar with the concept of loops, since most digital audio workstations nowadays have tools to easily loop sections of music. Loop ArrowFor game music, this concept is leveled up! 🙂 It’s one thing to use a pre-made loop in your music; it’s another to create a pleasing, seamless loop that might be played 200 times in one sitting! Loops are the go-to music type for most games.

At its core, a music loop is a section of music that you can immediately play again after it ends without any noticeable glitches, pops, tempo problems, cut-outs, etc. Ideally, the listener wouldn’t even recognize that the same section of music started playing again. The length of the loop can vary greatly; the music might be just 10 seconds long, or it might be 3 minutes long.

Not all types of game music should be loopable, but most games use this technique all over the place for a few main reasons:

  • Less music that the developer has to pay the composer for.
    • The composer only needs to write say 30 seconds of music that gets looped as many times as needed to cover the play time. For example, that one 30 second loop might be played 10 times in order to cover a 5-minute level.
  • Smaller file size.
    • File size and space is super important for games, especially when distributing games on mobile devices. The less space the music takes up, the less time the player needs to wait for the game to download and load, the less processing power and memory is required of the system, and the more space that the developer has to include other types of assets into the game.
  • Great for times when the developer doesn’t know how long the player will stay on the same screen.
    • For example, imagine the player is on a screen that shows a slot machine with exciting, anticipatory music looped in the background. The music should continue playing indefinitely until the player finally pulls the handle of the slot machine, which he might do within a second or within a minute.

Looping music has its problems, though. Here are some gotchas that you need to watch out for when creating loops:

  • Starting a loop.
    • Since the music needs to loop, the start of the loop track cannot fade in or start with the type of intro you’d normally compose for the beginning of a traditional song. Therefore, the audio programmer would need to make sure to fade in the loop when it first starts, or you need to create a separate “intro” track (see below) that the audio programmer plays just before the start of the first loop.
  • Repetitiveness.
    • Normally, when you write a song, you want a cool hook or a cool sound that sticks out and makes a statement. Something that catches the attention of the listener. For games, this is usually a very, very bad idea… especially in loops. Unlike a listener who might only listen to your song once or a few times a day, a player might hear your loop back-to-back a hundred times in an hour. If you have an instrument or sound in your track that sticks out, it will quickly become annoying to the player. Likewise, if you repeat sections of your song within the loop (like a single loop that is verse, chorus, verse, chorus… sort of like you would do in a normal song), then you’re in effect creating a smaller loop, which means the player is going to hear those sections way more often than is desirable.
    • As a composer, you need to walk that fine line between a loop that is memorable and interesting, but also non-obtrusive and fits well into the background so that the player can focus on the game. It’s an art.
  • Reverb tails and decays are especially problematic.
    • Traditionally, at the end of a track you play a final crescendo and hit, or you let all of the instruments fade out into nothingness. This causes lots of problems as soon as you try to loop that track. If you want to stay on the beat when the track loops, you need to end the track immediately, without any reverb tail or decay of the instruments that were playing at the last beat. But if you loop the track like that, it will usually sound pretty horrible. There are three things you can do to fix this:
      1. Use an advanced audio engine in the game that will play the entire track, including the long tail, but starts another audio thread that plays another copy of the track before the entire track has finished playing (aka while the tail is still playing). The problem with this approach is that not all audio engines do this, and it requires more audio processing, which possibly mean less processing time for the main game.
      2. Start off the loop with a big crash or sound that makes the loss of the tail less obvious. Be cautious of the repetitiveness issue I mentioned above if you use this approach.
      3. Copy the tail into the beginning of the loop. This trick is pretty cool, but trickier to implement. 🙂 To do this, you render out your track, including the tail. Then you copy just the tail portion and paste (mix) it into your loop at the beginning. The result is that you’ll hear the tail when the music loops. The hard part here is making sure the start of the loop still sounds good if you play it as is, or if you fade it in. Sometimes it is weird to hear the tail of something as soon as the loop starts.
    • When you do need a big ending sound, you are probably better off creating a separate “outro” track that the game will play after the looping section. See the “intros and outros” section below for more details.
  • Looping with non-matching DC offsets causes pops!
    • When you look at a wave file, you usually are looking at a those squiggly lines that go up and down from a center line. As you might recall from my article about how speakers work, those lines basically represent the pushing and pulling of a speaker diaphragm. If you zoom really far into the waveform, you’ll notice the wave smoothly goes from one value to another, and “never” jumps. What happens when a value jumps? Well, that means the speaker is supposed to move the diaphragm immediately from one position to another position. Obviously, that can’t happen in real life… and the result is a popping or clicking sound! So, you want to avoid jumping between values at all costs.
    • Those values are called “DC offsets,” where a value of 0 means that there is no offset (aka the speaker diaphragm is not being pulled or pushed by the driver). When the DC offset travels between pushing and pulling, it passes the 0 value, also known as a “zero crossing.” So, a very safe approach to avoid pops and clicks is to only slice and loop audio at zero crossings. If you look around, most audio editing programs have an option to snap your cursor to the nearest zero crossing; you should normally use that feature before copying or cutting audio to create your loops. If you can’t find a suitable DC offset, you’ll probably need to apply a quick fade on your audio so that the DC offset reaches 0 at the start and end of the loop.
  • Watch your keys and modulations!
    • Make sure that the loop starts and ends on keys/chords that are complementary. Your loop is likely going to sound really bad if you modulated in the middle of your loop, unless you take extra precautions to make sure that the loop transition makes sense musically.
  • Transitioning from one loop to another loop.
    • In practice, as you’ll read about below, games can have multiple loop blocks that can be mixed and matched to create some variation. That’s great, except when you consider that the starts and ends of all loops need to be able to seamlessly work with the starts and ends of all other loops. Can you say crazy-town?!

When creating loops, you need to remember that the song arrangement needs to match the game play. Therefore, it usually makes most sense to split up the parts of the song into their own loops and then let the audio programmer mix and match them as appropriate. For example, you might have a verse loop, a pre-chorus loop, a chorus loop, and a bridge loop, and then let the game decide when to move on and play each type of loop.

3. Intros and Outros

As soon as you start creating loops, you’ll immediately run into the issue of how to nicely start and stop looping. That’s where intros and outros come in. An “intro” is a short piece of music that is played before starting to play loops, and an “outro” is a short piece of music that is played when the looping stops.

Train tracksIntros and outros are often separate audio files that you create by slicing off the beginning of a track and the end of a track. In effect, they are the parts that are left over when you slice the track to create a looping section. Therefore, these tracks are often less than 3 seconds long. That said, intros and outros can also be much more complex and include whole sections of music that you otherwise wouldn’t hear. Since it’s usually weird to hear the song “start over” every time it loops, it makes more sense to chop off the intro and ending, and only play them once at the start and end of the looping section.

To make your life easier, more advanced audio engines, such as Wwise and FMOD, offer ways to annotate tracks so that you only need to create one track that includes the intro, loop, and outro, as opposed to creating three separates files. Basically, you load your single track and then specify where the intro ends, what section of the song should loop, and where the outro should begin. These types of features make life much easier on the audio programmer and composer, and offer a lot of flexibility for how the music is played in game.

Intros and outros have many of the same transition problems that loops have, as I mentioned earlier. However, you can experience an additional problem with outros: in many games, the outro needs to play immediately based on an event. Obviously, in many cases it will sound horrible if you immediately play an outro, if you are at a random position in the loop. A couple ways to deal with this include:

  • Wait to play the outro until the loop reaches the next beat or measure.
    • To do this, the audio engine or game developer needs to have a way to track and use BPM and time signature info for each track.
  • Wait for the loop to finish playing.
    • If the loop is short, or there is not a lot of time left in the loop, this shouldn’t be a problem. In all other cases, this approach probably won’t work because the game would wait too long before playing the outro.

4. Shuffled Loop Blocks

The next step up from simply looping one section of music over and over again is to have several loop blocks that can be mixed and matched as needed.

For example, instead of creating a single loop, a composer might create three variations on the loop. Let’s call them loop blocks A, B, and C. The audio programmer can then play the loop blocks in any order. In fact, here are a few common methods of playing the blocks:

  • Random.
    • Most audio programmers code this up at first because it is easy. Every time a loop block ends, the game randomly chooses another block to play.
    • For example: A > C > C > A > C > A > A > B > A
    • As you can see from the example above, this method isn’t ideal because it doesn’t ensure that all blocks are played roughly the same amount of times, or that a block isn’t repeated immediately after being played.
  • Shuffled.
    • This is usually a much better choice than random. The game first randomly shuffles the loop blocks to create a list. Then, every time a loop block ends, the game plays the next block in the list. At the end of the list, the game shuffles the list again and continues from the start of the list.
    • For example: C > A > B > B > C > A > B > A > C
    • As you can see from the example above, the distribution of blocks is much better than random, but we still have the problem that blocks can be repeated immediately after they were just played. This is caused when the list is re-shuffled and the first block in the new list happens to be the last block in the old list.
  • Shuffled with no repeats.
    • This is the same as the “Shuffled” version above, except that if the game ever detects that a new shuffled list will result in a repeat, it simply randomly swaps out the first block in the new list with any other block in the list.
    • For example: C > A > B > C > B > A > B > A > C

Game developers can continue adding more advanced features to looping blocks, such as choosing which blocks to play based on what’s going on in the game, the health of the player, the threat level, etc.

5. Playlists

Looping isn’t the only game in town (pun intended)! 😉 In fact, there are several popular approaches for playing music in games, especially for the main game and level music. Games can and often do incorporate each of these approaches.

The easiest to implement is the playlist approach. It’s what it sounds like. The game has a list of full songs to play and simply plays one after the other. The songs are usually complete tracks with intros, verses, chorus, bridges, endings, etc… like you would hear on the radio.

A playlist can have just one track, or it may contain many tracks. Usually, though, a game doesn’t have many tracks because of file size and memory limitations.

You can shuffle the tracks in the playlist in a similar manner you can shuffle the loop blocks mentioned above.

6. Layering

Cake LayersThis is where it starts getting really fun and challenging for a composer! 🙂 As games get more immersive, the audio has to get more advanced to keep up. For music, that usually means employing some type of layering technique. By layering, I mean playing multiple music tracks at the same time based on one or more parameters.

Layering can be controlled by any number of parameters, but probably the most common is the “threat level.” By threat level, I mean how “in danger” the player is at any moment.

  • For example, as the player approaches an enemy or dangerous area, the threat level increases. The more enemies or dangers there are nearby, the higher the threat level. As the player defeats the enemies or runs away from the dangers, the threat level decreases.
  • When the threat level is low, the music is calm. When the threat level starts to increase, the music starts to get more serious and exciting. And when the threat level is high, the music gets really exciting and possibly even frantic.
  • The threat level can be a simple discrete number, such as 1, 2, 3, 4, or 5. Or, it can be any floating number in a scale of say 1 to 100. It depends on what the developer wants.
  • The threat level can be influenced by lots of other things, such as the player’s health, his progression in the game, items he’s collected, etc.
  • Most importantly, the music needs to seamlessly transition between these states!

Layering comes in many forms. Here are two common techniques:

1. Cross-fade between two or more layers at a time.

  • With this technique, the game starts by playing the base layer and then cross-fades between layers based on the threat level or other parameters. For example, the game might play Layer 0, and then start cross-fading into Layer 1, and then just play Layer 1. Later, it might start cross-fading Layer 1 into Layer 2, and then eventually just play Layer 2. As the threat level decreases, this process plays out in reverse, back down to Layer 0.
  • This means at any time an individual layer contains all of the musical information needed to stand on its own.
  • Here are what the individual track layers look like for an example game that uses just three layers:
    • Layer 0 contains just the low-threat music. For example: just pads and strings.
    • Layer 1 contains the Layer 0 music combined with more upbeat music. For example: pads, strings, light percussion, lead instrument playing a melody with tension, etc.
    • Layer 2 contains Layer 0 + 1 music combined with the maximum exciting music mixed in. For example: pads, strings, light percussion, lead instrument playing a melody with tension, more lead instruments, horn stabs, big drums, crashes, cymbals, bass, etc.

The effect of this is pretty awesome… the player can go from a serene environment into full on battle mode, and then back again, all seamlessly and naturally.

To implement this, the audio programmer usually uses hysteresis or some similar logic, so that the cross-fades aren’t too jarring or keep going back and forth based on small variations.

As you can see, it is possible to transition in and out of a layer at any time within the life of the layer. As a composer, that means each track layer needs to work well with the other track layers. Here’s one way I accomplished this for a game:

1. I started by creating the highest, most intense layer first, which includes everything. In other words, since I had a 3-minute looping track, the track was at full throttle the entire 3 minutes. This is because the game might transition to this layer at any given moment when the threat level increases… so the track needed to be really intense the whole way through.

2. Then, for the layer below, I took out some of the more intense drums, cymbals, and stabs until I felt that the music was still tense, but not overly so.

3. This continued until the base layer, which ended up having just ambient and atmospheric sounds and pads.

In order to limit the amount of processing and memory usage, it’s best to only play a maximum of two layers at a time using this technique, but the concept can be used to cross-fade between any number of layers at the same time.

The other common layering technique is to stack layers on top of each other.

2. Stack layers

  • This technique involves playing more and more layers until it creates the desired effect. In the end, you might have several layers all playing at once to create a big, intense battle sound.
  • Because more audio tracks are playing at the same time, this technique is more processor and memory heavy.
  • Here’s what the layers would look like in this case for a game that used three layers:
    • Layer 0 contains just the low-threat music. For example: just pads and strings.
    • Layer 1 contains just the more moderate music. For example: just light percussion, lead instrument playing a melody with tension, etc.
    • Layer 2 contains just the heavy, more exciting music. For example: just big lead instruments, horn stabs, big drums, crashes, cymbals, bass, etc.

The cool thing about this technique is that the audio programmer can mix each layer to taste or based on the threat level. It also allows for more variations by lowering the level of a middle layer without lowering the bottom-level or top-level layers.

7. One-Shots and Stingers

OnceOther music that you don’t usually need to create for an album project are called “one-shots” or “stingers.” These are basically musical sound effects that are usually played based on an event in the game. They can be thought of as elaborate sound effects. 😉 Here are some examples of when stingers might be used:

  • The player collects an item.
  • The player wins a prize.
  • An end-boss enters the screen.
  • The player’s health reaches a critical level.
  • The player reaches a milestone.

Some things you need to watch out for when creating stingers:

  • Make sure the stinger can be heard and distinguished over all of the other music during actual game play.
  • Make sure the stinger is in a desirable key based on the underlying music being played.
  • The audio programmer might need to ensure that the stinger is played on the next beat or measure of the music, so that the stinger feels like part of the musical experience (if that is what is desired).

Since one-shots can often be played many times in a game, it is important to have enough variations. Additionally, the audio programmer can use similar techniques that they use for general sound effects: slightly varying the pitch, volume, and start time each time the stinger plays.

In fact, the idea of using music more like sound effects can be taken to the extreme, where most or all of the sound effects come from instruments or out-takes from the music. For example, you could use a single strum of the guitar part as the sound played when a button is clicked. The sky’s the limit!

8. Positioning Music in 2D and 3D Space

You’re most likely already very familiar with the differences between 2D mixing and 3D mixing… but maybe just not in those terms. In games, sounds can be played as 2D or in 3D space.

When you create an album, you usually publish your music in stereo… that’s two channels: one left channel and one right channel. You’re in effect working in 2D space. To deal with this, you usually use panning techniques to move sounds around between the far left and far right. Once you set your levels, all sounds will always play in the same panning position no matter how many times a listener plays the song. If the audio programmer sets up your music to play as 2D in the game, it will be as if you’re listening to normal music: the left channel will play in the left speaker, and the right channel will play in the right speaker.

In 3D space, however, this is not the case. Music positioned in 3D space will sound different based on how close the player is to the source audio and in which direction the player is facing. As the player gets closer and closer to the sound source, the audio sounds closer and closer, until finally the player is standing on the audio source.

If you’re familiar with the gimbal lock problem, you might notice it rear its ugly head here: if the player is standing directly on the audio source, which way is left and which way is right? Furthermore, if the player starts turning in circles, the audio might start moving around in stereo space erratically. To fix these problems, the audio programmer can set up the audio source so that it basically turns into 2D mode once the player gets close enough. At that point, if the audio source is stereo, the left channel will map to the left speaker, and the right channel to the right speaker, no matter which way the player is facing. And of course, your music can also be placed as a mono track in 3D space.

You might be asking yourself why a game would ever want to play music in 3D space. Well, there are some good reasons, actually. Here are a few example cases where you might want music playing from a point in 3D space.

  • The player in the game should hear music coming out of an object in the scene, such as a radio sitting on a desk.
  • The player walks out of one room that is playing music into a hallway where he can hear the old music coming from the room he just left, as well as the music coming from another nearby room.
  • The player gets musical cues that indicate danger near an object as the player walks close to that object.

Traditionally, most music you hear in games is being played as 2D.

9. Quality and Encoding Issues

As an audiophile, you would love nothing more than your music to be presented in a lossless format, so that it sounds to the player as if he is listening to a CD or even better. The reality of the matter, however, is that game developers usually run out of space, processing power, and memory very quickly, and a common place to find savings is by cutting away that high-quality audio sound. This is especially true for mobile games, where space and computing power is often much more limited than a game console or desktop computer.

Press TogetherEven though you wrote say 100 MB worth of lossless audio for the game, the game developer might only allow you 5 MB! How does that work? Well, your music is going to be encoded and compressed… like mad! It’s common for game developers to encode your WAV files into a format such as OGG or MP3. MP3, however, has various technical problems, such as built-in gaps, which make it harder to work with when wanting to loop audio.

The game developer will keep squashing the audio size by doing more and more aggressive compression until they feel they’ve reached the point where the audio is noticeably bad. At that point, they’ll usually go back one or two levels so that the audio still sounds decent, but the file size is dramatically lower than the lossless size.

I’ve noticed that each type of music responds differently to encoding, or at least the encoding artifacts are more noticeable with some types of music. So the audio programmer or game developer might need to play around with the encoding levels for each track to make sure they maximize savings while maintaining the integrity of the music.

10. Frequency Issues on Mobile

The last item I want to talk about is how music can sound drastically different on mobile devices than it does on your desktop or in your recording studio. This might be obvious, but when you are creating music for mobile games in particular, you want to keep in mind that most users won’t be able to hear low frequencies when listened to on the mobile device’s speakers. NOTE: I’m not referring to listening on headphones on a mobile device, since that will generally produce great sound.

There have been times early on when I finished a track, only to discover afterwards that I couldn’t hear over half of my track when played on a mobile device speakers because most of the track was in the lower frequencies: lots of bass, low rumbles, etc.

All hope is not lost, however. You might want to check out bass enhancer plugins such as Wave’s MaxxBass or similar that allow you to adjust the harmonic levels of lower notes. Basically, the idea is that a listener can interpret sounds based on the collection of harmonic frequencies that they hear, so that they think a low fundamental bass note is being played, even though they can’t actually hear that frequency. To put it simply: by enhancing the harmonics of bass notes, you’ll most likely be able to “hear” the bass on a mobile device.

Creating music for games is a lot of fun!

Congrats on getting all the way through this stuff! I hope I didn’t scare you off with all of those details above. And I hope I didn’t give you the wrong impression. PuzzleComposing music for games is a blast, and I highly recommend it, despite its challenges!

As a reward for getting through this article, I’m pleased to show you this picture of a partially-completed puzzle that you can try to finish in your head. Good luck with that! 🙂

Do you have some helpful insights about creating music for games that you think others would benefit from? If so, why not share them with everyone by using the comment system below!

Happy gaming!

Leave a Reply