In the same way that we can create complex sound effects that change depending on the events of the game, it is also possible to do the same for the game's background music. This allows the music to adapt to the circumstances, for example, to convey the correct emotion for the moment, or provide a sense of tension when danger draws near.
Music that is played in a non-linear fashion like this is known as interactive music (if the player directly controls the changes) or adaptive music (if the music reacts to the game environment, but not necessarily to the player). There are two main approaches to creating interactive music.
In this approach, the audio system modifies the mix of the song in real-time depending on events occurring in the game. This can consist, for example, of adding new instruments to the song, or making the music play faster or slower to match the gameplay.
The easiest way to implement this type of interactive music...