Playsound volume discrepancy between OpenAL and FMOD EX

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Gez
 
 
Posts: 17831
Joined: Fri Jul 06, 2007 3:22 pm

Playsound volume discrepancy between OpenAL and FMOD EX

Post by Gez »

Something I have noticed when playing through the Golden Souls mod, MAP07: Ghost House. In OpenAL mode, the map is unbearably noisy and loud, and sounds as if it was on fire. In FMOD EX it sounds as it always did. I quickly discovered the issue came from the candles that have this line of code:

Code: Select all

A_PlaySound("DSCHAFIR", CHAN_BODY, 0.1, 1)
Her's a minimal example map. With the FMOD EX backend, the fire sound from the candle is very faint though you can still hear it (especially with music off). In the OpenAL backend, it's played at full volume.
Attachments
candlenoise.zip
(12.64 KiB) Downloaded 59 times
User avatar
VoidMage
Posts: 165
Joined: Thu Dec 02, 2010 10:42 am

Re: Playsound volume discrepancy between OpenAL and FMOD EX

Post by VoidMage »

This is just a guess, but there seems to be a slight inconsistency in openal code.
Change in OpenALSoundRenderer::StartSound3D
alSourcef(source, AL_GAIN, SfxVolume);
to
alSourcef(source, AL_GAIN, SfxVolume*vol);
User avatar
Csonicgo
Posts: 1193
Joined: Thu Apr 15, 2004 3:28 pm
Location: Leeds

Re: Playsound volume discrepancy between OpenAL and FMOD EX

Post by Csonicgo »

VoidMage wrote:This is just a guess, but there seems to be a slight inconsistency in openal code.
Change in OpenALSoundRenderer::StartSound3D
alSourcef(source, AL_GAIN, SfxVolume);
to
alSourcef(source, AL_GAIN, SfxVolume*vol);
The same issue also came up when testing DemonSteele in OpenAL. I had assumed it was the sound format, but looks like I was incorrect.
unknownna
Posts: 215
Joined: Sat Oct 06, 2007 4:45 pm

Re: Playsound volume discrepancy between OpenAL and FMOD EX

Post by unknownna »

Here's an example WAD requested by Edward-san:
complex_sound_01.zip
zdoom -iwad doom2.wad -file complex_sound_01.zip +map map01
(243.77 KiB) Downloaded 65 times
It contains a monster (PlasmaGunner) from Complex Doom. It seems that you can hear the weapon sounds at full volume from any distance. For some reason it doesn't seem to happen when using vanilla sounds.
Edward-san
Posts: 1774
Joined: Sat Oct 17, 2009 9:40 am

Re: Playsound volume discrepancy between OpenAL and FMOD EX

Post by Edward-san »

The fix mentioned by VoidMage does not work with the complex example wad, though it helps with the candle one.
User avatar
VoidMage
Posts: 165
Joined: Thu Dec 02, 2010 10:42 am

Re: Playsound volume discrepancy between OpenAL and FMOD EX

Post by VoidMage »

...OK, this part is a bit nasty and I don't have a good solution yet...
The problem with that wad is that those sounds are both 3D and stereo.
Once I've downmixed those two sound to mono, they were played at correct volume.
Even FMOD doesn't deal with it quite correctly on its own - FMODSoundRenderer::StartSound3D has a workaround for that case where it halves the volume of each channel (I wonder how good that works while the sound has more than two channels).
OpenAL backend doesn't have any workaround for this yet and my initial googling says it won't be pretty.
It seems that people tend to solve this in a similar way, that FMOD seems to do, that is play each channel independently...
Yuck.
User avatar
Chris
Posts: 2940
Joined: Thu Jul 17, 2003 12:07 am
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Re: Playsound volume discrepancy between OpenAL and FMOD EX

Post by Chris »

3D positioning and non-mono sounds don't mix. Most 3D audio APIs don't handle this (dsound even explicitly removed it after dx7), or can only handle it in limited capacity (either applying only attenuation with no 3D positioning, or effectively down-mixing to mono). I have considered adding a toggle in OpenAL Soft to do one of these, but really, if the sound is meant to be played in 3D it should be mono, rather than having the engine or audio API second-guess how to play the sound.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49053
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Playsound volume discrepancy between OpenAL and FMOD EX

Post by Graf Zahl »

It should do what the previously used API does with it in order to ensure compatibility. Having FMod and OpenAL do different things is the worst outcome of all.
User avatar
Chris
Posts: 2940
Joined: Thu Jul 17, 2003 12:07 am
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Re: Playsound volume discrepancy between OpenAL and FMOD EX

Post by Chris »

Graf Zahl wrote:It should do what the previously used API does with it in order to ensure compatibility. Having FMod and OpenAL do different things is the worst outcome of all.
Sure. The easiest thing to do would be to use manual gain handling when StartSound3D tries to play a non-mono sound, and change the manual gain to set the source's gain instead of its distance. That won't do 3D positioning for multi-channel sounds, but it should fix the volume. I'll see what I can do tomorrow.
User avatar
VoidMage
Posts: 165
Joined: Thu Dec 02, 2010 10:42 am

Re: Playsound volume discrepancy between OpenAL and FMOD EX

Post by VoidMage »

Just my opinion, but in this context, position is about as important as volume, so 'the easiest way' would probably be also wrong.

Downmixing at load for 3d sounds sounds the best, but might be hard to implement, as it seems it's unknown at load we'll be playing that particular sound as 3d.
User avatar
Chris
Posts: 2940
Joined: Thu Jul 17, 2003 12:07 am
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Re: Playsound volume discrepancy between OpenAL and FMOD EX

Post by Chris »

VoidMage wrote:Downmixing at load for 3d sounds sounds the best, but might be hard to implement, as it seems it's unknown at load we'll be playing that particular sound as 3d.
Right, and it's a possibility (at least from the backend's POV) for a multichannel buffer to be played in 3D and non-3D, so you'd potentially have to manage two separate buffers.
User avatar
VoidMage
Posts: 165
Joined: Thu Dec 02, 2010 10:42 am

Re: Playsound volume discrepancy between OpenAL and FMOD EX

Post by VoidMage »

...unless alBufferData was moved from Load stage (LoadSound/LoadSoundRaw) to Play stage (StartSound{,3D}), but that could result is some noticeable delays...

...or so it seems...
User avatar
ibm5155
Posts: 1268
Joined: Wed Jul 20, 2011 4:24 pm
Contact:

Re: Playsound volume discrepancy between OpenAL and FMOD EX

Post by ibm5155 »

Can confirm the same problem with cursed maze, I can hear the monster heart beat from everywhere.
Also there's a weird sound happening over the teleport time, idk how to describe, but it sounds different from fmod
User avatar
ReedtheStrange
Posts: 226
Joined: Sun Sep 11, 2011 3:27 pm

Re: Playsound volume discrepancy between OpenAL and FMOD EX

Post by ReedtheStrange »

I'm also having some similar issues with OpenAL. It makes it very confusing and frustrating when trying to figure out where an enemy is, and that's even when it's a map that I made. I have noticed that spawn and attack sounds attenuate properly, but sounds using the A_Playsound function don't attenuate no matter what I change the DECORATE values to.

FMod Ex does not have this problem however. One difference that I've noticed with Fmod, however, is that sounds cut each other off (which makes some of my longer machinegun sounds sound very awkward). Any rapid-fire weapon with and echo to the firing sound loses a lot of its effect.
User avatar
edward850
Posts: 5886
Joined: Tue Jul 19, 2005 9:06 pm
Location: New Zealand
Contact:

Re: Playsound volume discrepancy between OpenAL and FMOD EX

Post by edward850 »

ReedtheStrange wrote:One difference that I've noticed with Fmod, however, is that sounds cut each other off (which makes some of my longer machinegun sounds sound very awkward). Any rapid-fire weapon with and echo to the firing sound loses a lot of its effect.
That's not FMOD, that's Doom. Actors will only play one sound per channel.
Post Reply

Return to “Closed Bugs [GZDoom]”