No sound in Unity WebGL build

Hi,

I managed to create a HTML5 WebGL build of my Unity project using FMOD and everything works fine when I load it locally on Firefox. However, when I upload the project to itch.io, there’s no sound. I’ve tried Chrom, Firefox and Opera, none of those give me sound.

Is there something I’m missing? I have followed all the instructions of the documentation. I am using libfmodstudiounityplugin.bc. FMOD 2.00.09 (Unity Verified) and Unity 2019.2.21f1 Personal.

Please help!

Here’s the project on itch.io if this can give you any information: https://worthless-idea.itch.io/bdsmcq

Hi Raphael,
Thanks for that . I can see how you dont get sound, it looks like the broswer ‘click / interact to get audio’ is not being used. Try clicking on the unity logo as it starts up and you will get sound.

With web browsers, you will have to cause the mixerSuspend/resume code in FMOD to be called from user input, you can make a prompt in your own app to make this happen.

See in /Assets/Plugins/FMOD/RunstimeManager.cs that ‘OnApplicationPause’ is used to execute the suspend resume logic, mentioned in https://fmod.com/resources/documentation-api?version=2.1&page=platforms-html5.html#safari-and-chrome-browser-user-interaction-requirement-use-for-all-browsers

It has to come from a callstack that is triggered from a user interaction. It cannot typically be passively called without a click or tap involved.

if you get crackling you might want to look at altering buffer sizes with lowlevelSystem.setDSPBufferSize in the same .cs file where setOutput/setSoftwareChannels/setSoftwareFormat etc are called.

FMOD does not run in a thread so if the framerate is slow, it may miss mix opportunities to keep a continous stream.

Hi brett,
I try to change le DSPBufferSize, but nothing change, i have always the crackling effect with Chrome.
I add this : result = coreSystem.setDSPBufferSize(2048, 8); in the RuntimeManager.cs
But no effect, i use FMOD 2.00.10 and Unity 2019.3.13

Hi Yom Nuts.

Can you show me where you put that line? Was it before the system init call?
What was the result return code?

It’s on the Initialize function
result = coreSystem.setAdvancedSettings(ref advancedSettings);
CheckInitResult(result, “FMOD.System.setAdvancedSettings”);

result = coreSystem.setDSPBufferSize(2048, 8);
CheckInitResult(result, “FMOD.System.setDSPBufferSize”);

if (!string.IsNullOrEmpty(Settings.Instance.EncryptionKey))

And the result code it’s OK

ok im guessing your update is not calling fast enough. Are you loading from file or stalling updates in any way? Strip back your own code and just let the sound play with nothing else happening to make sure it is not the game code.
HTML5 audio mixing has to be treated very carefully compared to a normal platform, as there are no background threads.

I’m not doing anything special, just call StudioEventEmitter and I don’t limit the FPS.
It’s really just on Chrome that it does that.
And i don’t understand this question "Are you loading from file or stalling updates in any way? ", i load my bank by the Streaming Assets folder, and in the FMOD settings i select specific bank to load with Master.strings & Master in first.
You can try the version here http://noisette.guillaume.free.fr/Sadhana

hi,
your demo actually played without any glitches for me. It might be to do with the speed of the CPU.

by loading - i mean your own game data… not just fmod loads.
I wanted you to test it with nothing but sound playing, and no gameplay. ie a black screen.

If that works, and you reintroduce gameplay elements and it starts stuttering , then that is the thing to look at.

This is the point i’d start looking at the profiler in the browser and see what is throttling the audio.

I finally found the problem, it comes from having several cameras in perspective in the scene…
So many PostProcess was applied and so many ressources allow to that

thanks for the update and to see you resolved your issue.

Could you share… How did this cause an issue? And what was your solution?

I have a scene with 2 cameras — main camera and a UI camera but no post-processing.

Yeah I run into similar problems, especially long ambient sounds are crackling.
I do have multiple cameras, and it does seem to get worse where more particles are on screen.

Frame rate is really fast though, so I don’t know what’s up. I’ll try if enabling / disabling Graphics Jobs helps.