FMOD and Unity Audio Enabled, building to WebGL

Hi,

Is it advisable to build for WebGL using both Unity’s native audio and FMOD?

I understand that this is considered generally safe for Desktop and incompatible for some consoles, but I’m unsure about WebGL. Our project is at a crossroads where the choice between all Unity audio, all FMOD, or a mix has to be made before proceeding.

Thank you!

Hi,

For building to WebGL it is fine to have Unity Audio enabled (Unity Integration | Trouble Shooting). However, it will limit the number of resources that FMOD has access to. It is advised to use one system alone, what is keeping you from moving fully to FMOD?

Gotcha. Thanks.

There’s a bit of concern on the programming side about using FMOD Programmer Sounds to handle a feature that relies on Unity Audio Clips loaded dynamically from a server at runtime (this post was from a member on our team: How to create programmer sound from AUDIOCLIP - #2 by Connor_FMOD).

I have to agree, the process does seem quite complicated compared to just letting Unity handle this feature and this causes some hesitation. I understand that Unity Audio would have to be enabled anyway for this to work. Since this Audio Clip feature is central to the game’s design, the question now is what is the most stable option going forward, and to what extent could we feasibly use both before facing bigger issues.

The intended use for FMOD in the project is, admittedly, fairly superficial compared to the Audio Clip feature (which is crucial), though the potential for WebGL performance gains (bank loading, better compression options, and generally getting more out of fewer assets) was a selling point for FMOD as well.

If it’s not too broad a question, does the case I describe above sound like a significant performance risk considering the way in which Unity Audio will have to be used alongside FMOD? I understand WebGL requires a streamlined approach as is.

Thank you

It is also possible to use a programmer’s sound to play an audio file. Depending on how you store the file you could avoid using Unity audio altogether, and it is less complicated than trying to use a Unity clip. Here is a topic where that is done: Playing audio source. How are you downloading and storing the sound before it is added as a Unity Audio Clip?

Hope this helps!

Hi Connor,

Thanks for the response and apologies for the late reply.

I would pursue the avenue you suggested and bypass Unity audio altogether, but we have a bit of legacy code in this project and I don’t think we could totally rebuild this feature.

The audio clips are playing in FMOD now but there’s one little hiccup when we run the WebGL build: it seems that the audio clips are playing at half speed. All other audio (whether from Unity or FMOD) is playing at the correct speed as far as I can tell. It’s only the audio clips via FMOD that have issues.

I suspect this is a sample rate issue but I’m not sure how to address it. Do you have any suggestions?

Thank you

An option may be to set the Pitch of the channel the sound is playing on to try to speed it up.

Hi Connor,

I’d like to follow up on this point, please. Here is what the programmer had to say about downloading and storing the sound before adding it as a Unity Audio Clip:

"
UnityWebRequest audioData = UnityWebRequestMultimedia.GetAudioClip(url, AudioType.MPEG);
yield return audioData.SendWebRequest();

            if (audioData.result == UnityWebRequest.Result.ConnectionError)
            {
                Debug.Log(audioData.error);
            }
            else
            {
                try
                {
                    clips.Add(DownloadHandlerAudioClip.GetContent(audioData));
                }
                catch (InvalidOperationException ex)
                {
                    Debug.LogError($"{ex.Message}. \nURL was {url}.");
                }
            }

We don’t write a file to disk. We request the file inside unity directly
"

I’d like to see if using a Programmer Instrument in FMOD to directly access the file is a possibility. Using a Unity Audio Clip in the middle seemed to have some issues, so we’re trying to simplify if possible.

Thank you,

Donovan

Hi Donovan,

I will link you to this forum post which explains using a Programmer Instrument to play an audio file.

Let me know if that helps!