Implementation Guide - AlexisBliesener/Bewitched GitHub Wiki

Overview

The purpose of this document is to provide a basic understanding of how audio content is implemented into Bewitched using the FMOD middleware. For this project, Garrett will be in charge of implementing their audio content themselves, but in case a developer wants a better understanding of the audio implementation process, this document will come in handy.

Step 1: FMOD

After audio content is created in a DAW and bounced into audio files, the first step in implementation is to program the necessary logic, parameters, and adaptive changes to audio in the FMOD project. Each piece of audio is organized into an FMOD event where audio is played and adaptively changes during game runtime based on parametric changes called in code. The overall mix between different events and event groups can also be changed at runtime. Other features such as spatialization and easy randomization of sound effects makes FMOD a very useful tool for handling sound effects and music for Bewitched

As a developer, you will NOT need to worry about the FMOD project. The FMOD project itself is actually not in the git repo to avoid problems with version control overwriting any progress (no pushing the wwise... ifykyk). Instead, FMOD events and other data is compiled onto .bank files where unity can access them without needing the whole project file. These .bank files are located in the FMODAssets folder at the top of the project folder.

Step 2: Unity

After FMOD adds .bank files into the FMODAssets folder, you can start creating and playing events through code. Currently, most events are started via methods in AudioManager.cs in order to limit unnecessary audio code in each script.

Important concepts

  • If you get a pop-up message in Unity mentioning fixing line endings, fix the line endings. Don't hit ignore!!!!!

  • (VERY IMPORTANT) in order for FMOD to work in your scene, your camera needs to have an FMOD Studio Listener script attached to it and NOT the Unity audio listener. This is basically just a replacement for the default Unity component.

  • Events need to first be "instantiated" in order to be interacted with. Think of it like a non-static object that's defined in the FMOD project and instantiated in C# code.

    • This can be done through AudioManager.TryPlayOneshot() if you need to play an event that doesn't need to be changed during runtime (aka. a one-shot), or you can play it using AudioManager.TryGetReference() to get an event reference which you can then instantiate by calling RuntimeManager.CreateInstance(). (Might also add a TryPlayInstance() method that plays an instance and returns the instance).

    • To start or stop an event instance, use the FMOD.Studio.EventInstance.start() and stop() methods respectively.

    • Events need to be "released" in order for them to be destroyed after they're done playing. This can be done through the FMOD.Studio.EventInstance.release() method but it's automatically done in most AudioManager methods.

  • You can change an event's FMOD parameters through EventInstance.setParameterByName(). See Audio-Hit-List in the wiki to see the params of every event and what they do.

  • I will also be using Snapshots in order to adjust the overall mix during runtime. They're basically save states for different mixing settings in the FMOD Project and are instantiated, started, and stopped in the same way that events are.

  • VCAs will also most likely be used for adjusting audio volume in a settings menu.

For more details on each event: see the Audio-Hit-List where I go much more in-depth on every audio event and snapshot and any adaptive changes they need to undergo at runtime.

Things you should NOT touch at all

  • FMODAssets folder and .bank files
  • .gitignore and .gitattributes lines having to do with FMOD
  • The FMODStudioSettings scriptable object