UDK Horizontal Music System using Kismet

There is a need for a custom music solution when using the Unreal Development Kit. The default music system known as UTMapMusicInfo is limited and not completely functional as a complex music system. Using Kismet instead provides a strong visual scripting language with many possibilities for triggering sound.

Horizontal and vertical arrangements are well used techniques for creating music systems for games. This article will focus specifically on a horizontal setup. We will explore the benefits of vertical arrangement in a future article.

The best way to visualize a horizontal arrangement is to think of a single stereo track playing back in a DAW. This track can play only one file at a time, and each file has to contain the entire stereo mix intended to be heard. Each individual piece of music needs to be completely independent of the others because only one piece is heard at a time. For the purposes of a game the music needs to be able to loop endlessly, waiting for a specific player action to transition into the next piece.

Horizontal arrangement techniques have been used since the dawn of game audio. The earliest gaming systems generated the musical score on the fly with limited number of polyphony and channels. Once music was sampled and streamed off a disc only one stream could play at a time, necessitating the use of a horizontal arrangement. A typical setup would have the music system changing according to different conditions or game states. Once a condition was met the music system would stop playing the first piece of music and move on to the next. Game states that are commonly used would be: health remaining, power-ups, time running out, ambient, action, death, winning, and losing.

Horizontal music systems are still a very common approach to playing back music in games. Arcade games, casual games, and others with a linear style of gameplay often necessitate a horizontal setup. Mobile games are often limited by hardware restrictions and a horizontal setup can offer the best solution.

When considering a horizontal music system it is important to determine how one piece of music will transition into the next. Transitions can happen immediately, at the end of the current musical loop, or after a certain number of beats. In addition the transitions either happen as a hard cut from one to the next or as a crossfade over time. For this example each musical transition happens immediately once the previous cue has finished. This maintains the linear nature of the music and keeps the everything on time and in sync.

Looping music in Kismet

In the UDK there are a couple of ways to loop a soundcue. The first is using a ‘Looping’ soundnode directly in the soundcue itself. This is best for ambient level sounds where you need a looping sound but don’t need the control of Kismet. The main problem with using ‘Looping’ node is you don’t have much control over how the file plays back dynamically in game.

In Kismet you can set the ‘Finished’ output back to the ‘Play’ input on a PlaySound node. This triggers the soundcue to play over again once it reached the end of the file. You can then use other Gate node to stop playback. As the player triggers different events in the game it causes one Gate to close and another to open re-directing the ‘Finished’ output signal to reach the ‘Play’ input of the next PlaySound node.

Description of project

I am using the Racer Starter Kit (link here) provided by Epic Games to create and test my horizontal music system. It is one of their UDK Development Gems and contains everything needed to get started with a simple game project. It is a linear race course that uses a map based off of the EpicCitadel map provided with the UDK. There are a series of Touch Triggers placed throughout the race course. I used these as checkpoints and use the triggers to move the music system forward as the player drives through each one. You can use any number of checkpoints triggering the music system.

This Horizontal music setup is not only limited to linear checkpoints or triggers. Any number of parameters or game states could drive the music system. Basically if it has an output in Kismet it can be hooked in to this system.

Here is how the logic flows through the Horizontal music system:

  1. When player spawns in the level PlayerSpawned triggers the first PlaySound to start playing. It also sends a stop message to all other Playsounds in case they were still playing.

  2. When this first PlaySound is done playing it fires the FINISHED output.

  3. This feeds to the input of two Gates. The first defaults to open and triggers the first PlaySound again, and the second defaults to close and triggers the second PlaySound.

  4. The first Gate remains open, continually looping the first PlaySound, until the Touch Trigger is used and closes the gate preventing the first PlaySound from looping again.

  5. The second Gate is triggered to open by the Touch Trigger. This allow the first PlaySound, once finished, to trigger the second PlaySound to start playing. Thus transitioning seamlessly from once musical loop to the next.

  6. The second PlaySound is also connected to another similar chain of Gate and Triggers continuing though the musical progression as needed.

Next time we will discuss a vertical Music System. If you have any questions contact me chris.at.engineaudio.com or post a comment below.

  Return to blog...

1 Comment

  1. Creating Sound – This Week In Audio – Russia’s Greatest Love Machine
    February 15th, 2013

    [...] Latham of EngineAudio has posted a tutorial on how to get a horizontal music system up and running in UDK. So what are you waiting for?  Go bathe in the glory of the easily accessible audio and visual [...]