<aside>

Hello! My name is Morgan and I’m a game music composer. In my time collaborating with game developers, particularly during game jams, I’ve noticed a disconnect when it comes to the technicalities of how to creating dynamic, interactive audio.

This is a resource I’ve created to help both musicians and game programmers navigate the fundamentals of how to connect the game engine Unity with the audio middleware FMod to empower everyone involved in the process to be more equipped to create cool game audio, even in a game jam setting.

✨ You can find more about me here

pic01.JPG

</aside>

▶️ Slides from Galaxy Games Fest

<aside>

💡 First Time Setup

⚒️ Project Setup

Scripts

Audio Manager

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FMODUnity;
using FMOD.Studio;

public class AudioManager : MonoBehaviour
{
    //--------------------------------------------------------------------
    // Creates a place in the UI to select your FMod event file
    //-------------------------------------------------------------------- 
    public EventReference musicEvent;
    
    //--------------------------------------------------------------------
    // Setting up the instance of the event
    // (in Start we will put the Event we selected above into this variable)
    //--------------------------------------------------------------------
    private EventInstance musicEventInstance;
    
    //--------------------------------------------------------------------
    // Setup this audio manager and make sure there is only one of it
    //--------------------------------------------------------------------
    public static AudioManager Instance { get; private set; }
    private void Awake()
    {
        if (Instance != null && Instance != this)
        {
            Destroy(gameObject);
            return;
        }

        Instance = this;
        DontDestroyOnLoad(gameObject);
    }

    //--------------------------------------------------------------------
    // On game start, create an instance of the music event and play it
    //--------------------------------------------------------------------
    private void Start()
    {
        musicEventInstance = RuntimeManager.CreateInstance(musicEvent);
        musicEventInstance.start();
    }

    //--------------------------------------------------------------------
    // Method to stop the music event, allowing the
    // ADSR envelope fadeout settings from FMOD
    //--------------------------------------------------------------------
    public void StopMusic()
    {
        musicEventInstance.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
        musicEventInstance.release();
    }
    
    //--------------------------------------------------------------------
    // Method for setting a parameter
    //--------------------------------------------------------------------
    public void SetMusicParameter(string parameterName, float value)
    {
        musicEventInstance.setParameterByName(parameterName, value);
    }
    
    //--------------------------------------------------------------------
    // Method for playing a one-shot sound
    //--------------------------------------------------------------------
    public void PlayOneShot(EventReference sound, Vector3 position)
    {
        RuntimeManager.PlayOneShot(sound, position);
    }
}

FMOD Events Manager

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FMODUnity;
using FMOD.Studio;

public class FMODEvents : MonoBehaviour
{
    // -----------------------------------------------------------------
    // This creates the UI to select/drag in the FMOD file paths
    // for all your sounds. Just copy and paste this line and
    // rename for as many sounds as you need.
    // -----------------------------------------------------------------
    [field: SerializeField] public EventReference exampleSound { get; private set; }

		// -----------------------------------------------------------------
    // This sets up the FMODEvents manager and ensures there is only one
    // -----------------------------------------------------------------
    public static FMODEvents Instance { get; private set; }
    private void Awake()
    {
        if (Instance != null)
        {
            Debug.LogError("Found more than one FMOD Events instance in the scene.");
        }

        Instance = this;
    }
}

Controlling Sounds from any script