mstop4 / FMODGMS

🎶 GML bindings to the FMOD Studio low-level API for GM:S and GMS2. Can be used in Windows, macOS, and Linux games.
https://quadolorgames.itch.io/fmodgms
BSD 2-Clause "Simplified" License
62 stars 18 forks source link

No way to start a sound with 0 volume, popping sound when Setting Channel Volume #33

Open TsukiruP opened 1 year ago

TsukiruP commented 1 year ago

Using GMS 1.4.

I want the sound to start at 0, in case I want to fade something in or the volume setting is set to 0. But FMODGMS_Snd_PlaySound will always knock it back to 1. So I try to set the volume afterwards using FMODGMS_Chan_Set_Volume then causes a popping sound. Even doing similar in the Starter project causes another popping sound with the original music.

I know it's definitely possible because SonicForGMS (GMS1) doesn't have any popping but I can't make heads or tails of how it achieves it.

BPzeBanshee commented 1 year ago

Can confirm, it's a feature of FMOD but not currently supported in this extension.

At first, the cause seems clear: the call to play a given sound resets all channel parameters and FMODGMS has no way currently hooked up to manage Group settings nor does it provide a way to start the sound paused, which means volume is set to full, and changing volume afterwards leads to an audible effect despite the documentation page clearly stating it has measures to stop this from happening.

The bigger fundamental issue here is that a created channel appears to have almost no populated information on it at all until a sound is played, matching the above FMOD docs that state you can't actually create a FMOD channel before playing it. Getting mute state or playback state from a created channel before playing a sound using it will return false and then generate an error that FMODGMS_Util_GetErrorMessage will then catch. The presence of creating channels beforehand then, seems to be something @mstop4 has come up with presumably for dealing with GM's real/string extension limits and is similar to what I had to do with my Audiere wrapper GMALP.

Adding a way to set the paused flag in sys->playSound and then updating the channel with whatever you want GML-side would serve as a gap-stop fix for this, but it seems to me the 'proper' fix would be to populate the internal 'channels' with default information, then on FMODGMS_Snd_PlaySound, start it paused and update it with that metadata.

As for SonicForGMS, it's a moot point but I suspect whatever build you had likely used GMS1's internal audio, which would've had pop-free fadein as it allows global/per-sound/per-instance volume, so unfortunately there's no code there that is helpful to this case.

TsukiruP commented 1 year ago

I've moved to using other sound systems but to add some other odd details: It seems the lack of popping was entirely dependent on what sound files I used. The music in SonicForGMS just happened to not cause popping.