• Register
Post news Report RSS Adaptive Music: How the Music System in "Just Keep Running" Works

For JKR, I wanted the soundtrack to be responsive to what was happening in the game. So, we developed a relatively simple but effective Music System, and in this article, I explain how it works and how it was executed!

Posted by on

Adaptive Music: How the Music System in "Just Keep Running" Works

Written by Victor Ahlin, creator of "Just Keep Running"

PLEASE NOTE: This article contains spoilers for Level 1-3 of the game. You have been warned


Intro

Before I started making games, I had already gotten into music production. In fact, I still make music to this day (Victor Ahlin on most major streaming platforms, fyi ;D). So, of course, a good bit of thought went into the game's soundtrack. And with the help of FMOD (not sponsored), I could set up a system that reacts to what's happening in the game and actively modifies the soundtrack to suit the momentum and intensity of the game. So, for anyone curious, here's how the Music System in "Just Keep Running" works!

The System

A visual showcase of the Music System

The system is relatively simple. Each piece of level music is divided into three states of rising intensity; Calm, Alert, and Action. Each track also has optional states that I can utilize if I want the soundtrack to shift a little bit during a specific section of the game (such as in 1-3 when the player is prompted to escape, you can hear the soundtrack slightly shift as the cutscene gets closer to the BOOM!)

The Music System looks at what is going on in the game each update cycle, and (if a custom section of the soundtrack isn't currently playing) it determines and changes the music's intensity using a variety of factors.

  • If the player is not in a stage, the music state is Calm.
  • If the player is in a stage and the stopwatch is ticking, the music state is Alert.
  • If the player is in a stage, and either of the following is true... (a) they've started a Time Trial, or (b) the player is being attacked by an enemy (such as a Roof Turret), the music state is Action.

The Setup

An image showing how I set up a soundtrack in FMOD

The setup for a music track is not super complex. Once the Music System changes its state, it sends that state to FMOD, which causes the current state to try to transition to the next state as smoothly as possible without disruptively interrupting the current one, taking into account the beats per minute of the track so that the transition can happen in time with the music.

The current state keeps looping until either a transition is ongoing or the track is stopping, which is determined by the "Reached Level End" parameter. This is so that while the song is fading out and reaches the end of that state, all the instruments cleanly chime out.

An image showing the Level Music Manager in Unity's Inspector


The script also has some variables to track the momentum of the game.

"Tension Release Wait" determines how long the music should stay in Alert or Action while the player is outside of a stage before transitioning back to Calm so that if the player quickly leaves a stage and enters another one, the music won't try to quickly transition between both states. This tends to sound very artificial and ruins the momentum of both the game and the soundtrack.

The horribly named "Shooting Pause Timer Length" variable determines how long the soundtrack should stay in Action once an enemy attacks the player. The timer resets every time an enemy attacks the player and transitions back to Alert or Calm after that timer has run out.

In Conclusion

While this system isn't perfect, it is simple yet easily customizable; if I wanted to do more with this system, I could! Plus, it's a neat introduction to Adaptive Game Audio and Music. I will talk more about FMOD and Adaptive Game Audio in a future article. But for now, if you want to learn more about Adaptive Music in video games, I'd recommend checking out Game Maker's Toolkits video "Adaptive Soundtracks in Games". It showcases some neat and complex uses of adaptive audio than what goes on in "Just Keep Running", and I think it's a really interesting video!

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: