FMOD Programmer Sounds in Unity

Programmer Sounds are designed to play sounds directly from a group of audio files via a received callback. This happens using audio tables or directly by playing back sounds located in the file system. Audio Tables are a group of audio files that are not assigned to an event but are created in the FMOD Studio application. These sounds can be accessed using a string key. The use of Programmer Sounds allows for an efficient implementation of dialog systems, where the Sound Designer creates a single event as an event template and plays all the audio files inside that event.

Download the Unity & FMOD Project for this tutorial. If you get any errors after opening the project, please delete the FMODStudioCache.asset file, as it will still contain the old path to the FMOD Studio Project.

Preparation for using Programmer Sounds in Unity

In FMOD Studio we create a new event and insert a programmer instrument into the first track:

FMOD Studio Programmer Instrument
FMOD Studio Programmer Instrument

In Unity, we create a subfolder under Assets/StreamingAssets and store our audio files there:

Unity subfolder inside StreamingAssets
Unity subfolder inside StreamingAssets

Back to FMOD Studio, go to the Banks tab and right-click on a bank (in our case the Master Bank) and select New Audio Table -> New Audio Table:

FMOD Studio "New Audio Table" option
FMOD Studio “New Audio Table” option

In the lower part of the window we select the folder where our audio files are located:

FMOD Studio Audio Table source directory
FMOD Studio Audio Table source directory

Keep in mind that you don’t need to use audio tables if you’re directly playing audio assets through a programmer instrument, but they are useful when working with dialogue and localisation.

Code for FMOD Programmer Sounds in Unity

Check out the appropriate scripting example located in the FMOD-Unity documentation page:

There will be minor code differences depending on the version you’re using. Copy and save the example to a new script.

Insert the script into any GameObject as a component and in the inspector select the event we created in the first step.

If you are just playing audio assets through the programmer instrument (without using audio tables), change the audio string keys in Unity’s Update method to include the file extensions. The audio files should be located in Application.streamingAssetsPath, but you can also change this path (currently set in the CREATE_PROGRAMMER_SOUND callback, when the Sound is created).

In Play Mode, you will hear the respective audio files while pressing the keys 1-3.

↑ To the Top