FMOD Integration?

Hello,

Do you have any plans to support FMOD? There are several issues with the audio manager (or how it is used) and I'm considering leveraging fmod. Before I dig into updating the Audio Manager to utilize FMOD do you already have plans for this integration?
 
There are currently no plans. If your changes are generic so you are just swapping out the audio manager or something like that let me know and I'll see if I can incorporate them into the next version.
 
Hi,

Did you have any joy integrating with FMOD? I'm not a coder and it seems like it'd be quite involved. I have to use FMOD for the music therefore I would lose the sfx from UTPS.

Thanks
 
I tried a lot of different implementations trying not to be invasive editing too many core classes. I actually was successful by creating fake audio files and naming them the same as the event in fmod. For example if you have an event called footsteps inside the Player folder. I named the audio file “FMOD_Player_Footsteps.wav. Since all audio passes through the audio manager I edited the AudioManager to look at the name of the audio clip to see if “FMOD” was present in the string. If it was present, I called an event on an FMOD_AudioManager I created to play the sound. If it wasn’t, then it just plays the audio using the built in manager. I passed the name of the audio clip and edited the string to convert it into an FMOD event reference. So “FMOD_Player_Footsteps.wav” became “event:/Player/Footsteps. Once that worked I just created audio clips for all of the events and assigned them to the abilities, weapons and other events. It’s really hacky but it works really well. I only used this implementation on Character controller elements and it was the only way to get all of them to work without modifying all of the core classes. For other things like pickups and music I’m using the Unity FMOD scripts.

I will post more details and my scripts once I get home.
 
Thanks for your reply. That's excellent news, hacky is absolutely fine by me, I'll give it a try. If you get a chance to post scripts as well that'd be the icing on the very helpful cake.

I was concerned about using the FMOD scripts along with unity's audio because the FMOD docs advised against it but it seems to be working so far. You haven't had any problems with conflicts?

Cheers again
 
This is the FMOD_AudioManager script. I added this to a GameManager gameObject that is in my scene.
It uses the EventHandler that comes with Character Controller to listen for an event to play the sound and then uses the FMOD Unity integration to play it at that spot.

C#:
using UnityEngine;
using Opsive.UltimateCharacterController.Events;

public class FMOD_AudioManager : MonoBehaviour
{
        private static FMOD_AudioManager s_Instance;
        public static FMOD_AudioManager Instance
        {
            get
            {
                if (!s_Initialized)
                {
                    s_Instance = new GameObject("FMOD Audio Manager").AddComponent<FMOD_AudioManager>();
                    s_Initialized = true;
                }
                return s_Instance;
            }
        }
        private static bool s_Initialized;

    private void Awake()
    {
        EventHandler.RegisterEvent<Transform, string>("PlayFMODSound", Play);
    }
    public void Play(Transform location, string eventName)
    {
            FMODUnity.RuntimeManager.PlayOneShot(eventName, location.position);
    }

    public void OnDestroy()
    {
        EventHandler.UnregisterEvent<Transform, string>("PlayFMODSound", Play);
    }
}

Then I edited the AudioManager script starting at line 468 inside the PlayInternal method. Since all sounds that are played by the controller go through this script, it looks at the name of the audioClip to see if it has "FMOD" in the string. If it does then it creates the FMOD Event Reference string using the name of the audio clips and executes the event on the FMOD_AudioManager script that plays the sound.

C#:
/* CUSTOM CODE */
            if (clip.name.IndexOf("FMOD") == 0)
            {
                string eventName = clip.name.Replace("FMOD_", "");
                eventName = "event:/" + eventName.Replace("_", "/");
                Debug.Log(eventName);
                EventHandler.ExecuteEvent("PlayFMODSound", gameObject.transform, eventName);
            } else {
            /* END CUSTOM CODE */

In FMOD I have my events in a folder structure like this...

FMOD_Events.PNG

In Unity I took an existing .wav file and simply renamed it so that the name matched the naming convention needed by the Audio Manager. Then I duplicated that file and just changed the name.

FMOD_Unity.PNG

Then I just assigned those audio files to the Start and Stop AudioClip fields on Character Controller. I also added the Shoot, Reload, and DryFire audio files to my weapons.

FMOD_Unity2.PNG

You can also use this method for Surface Effects. And as I said, I used the standard FMODUnity components for all other sounds like music, environmental elements and pickups. With this method, anywhere that you use an audioClip in Character Controller you can use this method.

Let me know if you need anything else.
 
Hi all, this really helped me. I got the weapons working just fine through your "hack" among other things, I really am thankful.

I just wanted to know how you got the footsteps to work? so for grass, I found the audio files under the Footstepongrass script but when I name the audio files accordingly the sounds wont play through like the weapons do.

Can you shed some light on how you got the footsteps to work?

Thank you!
 
This is the FMOD_AudioManager script. I added this to a GameManager gameObject that is in my scene.
It uses the EventHandler that comes with Character Controller to listen for an event to play the sound and then uses the FMOD Unity integration to play it at that spot.

C#:
using UnityEngine;
using Opsive.UltimateCharacterController.Events;

public class FMOD_AudioManager : MonoBehaviour
{
        private static FMOD_AudioManager s_Instance;
        public static FMOD_AudioManager Instance
        {
            get
            {
                if (!s_Initialized)
                {
                    s_Instance = new GameObject("FMOD Audio Manager").AddComponent<FMOD_AudioManager>();
                    s_Initialized = true;
                }
                return s_Instance;
            }
        }
        private static bool s_Initialized;

    private void Awake()
    {
        EventHandler.RegisterEvent<Transform, string>("PlayFMODSound", Play);
    }
    public void Play(Transform location, string eventName)
    {
            FMODUnity.RuntimeManager.PlayOneShot(eventName, location.position);
    }

    public void OnDestroy()
    {
        EventHandler.UnregisterEvent<Transform, string>("PlayFMODSound", Play);
    }
}

Then I edited the AudioManager script starting at line 468 inside the PlayInternal method. Since all sounds that are played by the controller go through this script, it looks at the name of the audioClip to see if it has "FMOD" in the string. If it does then it creates the FMOD Event Reference string using the name of the audio clips and executes the event on the FMOD_AudioManager script that plays the sound.

C#:
/* CUSTOM CODE */
            if (clip.name.IndexOf("FMOD") == 0)
            {
                string eventName = clip.name.Replace("FMOD_", "");
                eventName = "event:/" + eventName.Replace("_", "/");
                Debug.Log(eventName);
                EventHandler.ExecuteEvent("PlayFMODSound", gameObject.transform, eventName);
            } else {
            /* END CUSTOM CODE */

In FMOD I have my events in a folder structure like this...

View attachment 1816

In Unity I took an existing .wav file and simply renamed it so that the name matched the naming convention needed by the Audio Manager. Then I duplicated that file and just changed the name.

View attachment 1817

Then I just assigned those audio files to the Start and Stop AudioClip fields on Character Controller. I also added the Shoot, Reload, and DryFire audio files to my weapons.

View attachment 1818

You can also use this method for Surface Effects. And as I said, I used the standard FMODUnity components for all other sounds like music, environmental elements and pickups. With this method, anywhere that you use an audioClip in Character Controller you can use this method.

Let me know if you need anything else.

You have WAV files when using FMOD? I'm just getting to grips with FMOD but I thought all the audio was included in a .bank file and there was no specific WAV files?
 
Top