I've got five sounds now for a game I'm working on currently. In the game, you can fight against other civilizations in big battles, but you can also settle on planets in peace.

Some of the songs are more violent, while others are quite peaceful. The question is: what is the best practice for changing between the songs. Is it better if I just look "is it peaceful or not" when the old song ends and then play a new one or should I do that every single frame and change the songs immediately.

The first alternative would sometimes play silent songs in battles (because the song started before the battle and isn't finished yet) and the second one would switch between to different-fast songs properly at the wrong moments so the player would hear a cut.

So I'd like to know what is more natural for the player or if there is a different possibility.

PS: The songs are between 300 and 500 seconds long.

  • 2
    \$\begingroup\$ I'd say this is primarily opinion based. It's a design decision that you need to make. You can play the whole songs, or you can fade between them at the appropriate times. Play test it and see what you think works best. \$\endgroup\$
    – House
    Commented Aug 31, 2013 at 16:12

2 Answers 2


There are actually some fairly standard approaches for designing music playback in a game. When designing a music playback system, problems you face involve creating smooth transitions, ensuring there is enough variety, and creating a sense of interactivity with the music. Your question title, "changing background music smoothly" tells me your main concern is transitions so that's what I'll primarily be addressing for each method.

Method 1: Layers and Stems

One approach for creating smooth music playback systems in games, what Patrick Hughes called the "AAA way", is to build your music up in layers (also sometimes called stems) such that there's no single definitive version of the track. Instead, you might have a single base track running consistently, with melodic, rhythmic, harmonic variations that get played over it.

You usually (credit again to Patrick Hughes) build these around common motif that runs through each element layer in a piece of music, or even througout all music in the game. A good example of a non-melodic motif is Martin O'Donnell's use of the Phrygian scale in Halo games (http://www.1up.com/features/music-halo-reach). Normally, each of these component music tracks are aligned to be playing in sync on a timeline with each other. Although it is possible to create music layers that do not necessarily depend on a consistent tempo and synchronized timeline, or can work well in multiple tempo and timeline contexts.

Because each layer is designed to work together, it's entirely possible to have a single layered music track that just plays throughout the entire game, making slight transitions between layers within itself to signify game state changes.

Method 2: Branching

You say you have music tracks already produced, so this implies you've already got a specific direction in mind: branching music. With branching music, your primary concern is the transition between music tracks that have been specified to play at particular sections of the game. You can achieve variety by breaking your individual music segments down into loops that have a couple of different versions, so that the same version never plays twice in two iterations and doesn't always start out the same way.

One way to handle transitions in simple branching music is to write more music that purely acts as a transition from these existing music tracks to others. Even if it's not feasible to cover every possible music transition, you can also use the "connector tracks" to make a music track end early in the case where you're trying to avoid simple fade-in, fade-out music changes.

Method 3: CCC-Combo

It's also important to note that the two major approaches discussed here (layers and branching are what they're typically called) can coexist conceptually. "Branching" is such a simple term and description of what's happening that you could very well be branching between layered music systems. This often requires a semi sophisticated playback system, so you have to balance what's worth your time to implement.

Method 4: Pragmatism and Simpler Music Playback

And, of course, you could always just fade-in and fade-out your music as needed. No shame if that's what feels right, or it's not feasible to write connector tracks. Better this than hard cuts to completely unrelated piece of music--that would sound pretty awful.

I'd also like to address your "silent songs" idea. It's not bad, but what happens when you start playing one 300-second track for 5 seconds, then you get immediately into a state where you need to transition to another track? Waiting for the remaining 295 seconds to go by seems impractical if you really care about making that music transition.

However, if the music is purely background music, and its fundamental purpose is to provide to simply set an overall mood, then "simple background music list" is a perfectly legitimate way to think about it. At this point you are talking about a music playlist like you'd build in iTunes or Windows Media Player (is that still at thing?) so you should implement it with that in mind.

Further reading

To learn more about standard approaches for designing music playback in games, you should take a look at learning materials for two of the largest interactive audio middleware tools that see common use in the industry, FMOD and Wwise.

Wwise has good reference material on this page. The "Making Interactive Music for Games" article is especially good as it goes into further depth about the information I've written here. The FMODTV Youtube Channel has videos with Stephan Schutze that cover FMOD Studio as a whole--including the parts of it that can be used to design music playback systems. Learning how these tools approach this problem can help you think about how to address your own game's needs.

  • \$\begingroup\$ +1 good coverage and great explanations on how they work! \$\endgroup\$ Commented Aug 31, 2013 at 20:57

Length of songs is irrelevant. The AAA way is to have all the music built around a theme and then to fade in/out variants like your "more violent" and "quite peaceful" as needed. With the common theme the music just seems to flow, but it does take a good composer and a ton of production work.

The indie way would be to fade out the old music before fading in the new, you won't get hear the cuts and can have dissimilar musical pieces. I really like your "silent songs" idea, very good and will keep the player from getting fatigued even during normal play.

You don't want to check every frame, but only on state transitions like "a battle just started" and "I just lost" if at all possible. This is because of the next point:

For transitions you want to keep a timer so you don't porpoise back and forth, once you've changed to a new song let it play for at least that time.

Everything else about your question is a matter of taste and style and can only be decided upon by trying it out in the actual game to see how it feels. Fast transitions versus slow fades, how long are the silence gaps, how many transitions over time, how sensitive is the choice to transition, etc...

Audio isn't a slam dunk, and excellent audio is a thing of beauty.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .