openal-soft icon indicating copy to clipboard operation
openal-soft copied to clipboard

Classic XRay engine (32 bit) and OpenAL Soft reverb

Open donizettilorenzo opened this issue 2 years ago • 27 comments

Using a build from the master tree the reverb is ALWAYS active (in the intro videos too!) and the only paradoxical way to disable it is to "enable" EFX in menus/config files

Tested in Shadow of Chernobyl, Clear Sky, Lost Alpha, Call of Chernobyl 1.5R6 ...... all 32 bit versions of the engine. It's something related to EAX/EFX activation.

OGSR 64 bit doesn't have any issue.

donizettilorenzo avatar Mar 22 '22 13:03 donizettilorenzo

Building the DLL without the EAX support (ALSOFT_EAX) solves the issue.

donizettilorenzo avatar Mar 22 '22 13:03 donizettilorenzo

This uses OpenAL EAX natively, correct? Not through DSound/DSOAL?

What may be happening is OpenAL Soft is setting all sources to send to a reverb effect by default. Unlike DirectSound, OpenAL doesn't have a CTRL3D flag to indicate the source should or shouldn't get 3D/effect processing. At most, non-mono sounds don't get 3D spatialized, although it's not exactly clear whether EAX should care about that, since as far as I know, effects can apply to multichannel sounds with OpenAL, unlike DSound (and since OpenAL sources are created separate from buffers, it can't know at creation time whether it's mono/3D or multichannel/2D).

So there's some options I can think of, but will need testing with Creative drivers to know the proper behavior.

  1. Multichannel sounds don't get EAX effects, so regardless of what EAX properties are set, when a source plays a multichannel buffer, it ignores the EAX properties, and only uses them when playing mono buffers.
  2. EAX properties reset to default when a buffer is attached to a source, according to whether the buffer is mono or multichannel.
  3. Only the active sends reset to the default when attaching a buffer, according to whether the buffer is mono or multichannel.
  4. All sources start with no active sends, the 2D default, instead of the 3D default with one active send for the primary effect slot, and doesn't reset when setting a buffer on the source.

kcat avatar Mar 22 '22 22:03 kcat

Native EFX (with the "F")

What about adding EAX control to the config file / configurator of OpenAL Soft so we can customize the behaviour by application? And always about old XRay engine games, as I asked in the past, there's any way to avoid partial sound dropping (music, ambient sounds) after a quicksave/data fetching (tipically AI related)? Shipped wrap_oal.dll (or the Creative redist one) is OK

donizettilorenzo avatar Mar 22 '22 23:03 donizettilorenzo

Native EFX (with the "F")

What about adding EAX control to the config file / configurator of OpenAL Soft so we can customize the behaviour by application?

You can, with

[eax]
enable = false

That will prevent the extensions from appearing in the extension list, and even preventing the app from getting the EAX functions with alGetProcAddress (and if it still manages to get and call them somehow despite that, they will fail and do nothing).

If disabling EAX solves the problem, then what's likely happening is the app is making some EAX call even though it uses EFX. Making the EAX call "initializes" EAX for the device, which in turn causes all sources to initialize EAX defaults including the default active effects, which brings it back to what the expected behavior should be for sources with EAX.

Ideally sources shouldn't need to "initialize EAX". They should be able to initialize normally regardless of whether EAX or EFX (or nothing) is used. As far as I can tell, the EAX defaults match up with normal OpenAL/EFX defaults, except the default active slots, which at least from the EAX API headers, is different for 2D and 3D.

And always about old XRay engine games, as I asked in the past, there's any way to avoid partial sound dropping (music, ambient sounds) after a quicksave/data fetching (tipically AI related)?

I'd need to know what's causing the sounds to stop. https://github.com/kcat/openal-soft/issues/174#issuecomment-792004112 is the only mention of it that I see, but if it's fine with Creative's wrapper, I don't know why it would be a problem for OpenAL Soft. I'd need more info about what makes those sounds different and why they would stop like that. Any log warnings or errors? Any AL errors?

kcat avatar Mar 23 '22 02:03 kcat

[eax] enable = false

It's working!

donizettilorenzo avatar Mar 23 '22 18:03 donizettilorenzo

"I'd need more info about what makes those sounds different and why they would stop like that. "

Ambient (weather, fauna) sounds and music. Normal Save (menu) has no issue. Quicksave shows the issue and the AI loading (when AI goes from offline to online, in fact a dirty solution is to extend the range of AI liveness) too.

donizettilorenzo avatar Mar 23 '22 18:03 donizettilorenzo

This could be my oversight. Initial value of Room parameter in Host OpenAL for EAX2 is -10000 (muted reverb).

bibendovsky avatar Mar 23 '22 19:03 bibendovsky

This could be my oversight. Initial value of Room parameter in Host OpenAL for EAX2 is -10000 (muted reverb).

Fixed that with commit 964a11ef629fa3a89e827516a47949c858ce864c.

Ambient (weather, fauna) sounds and music. Normal Save (menu) has no issue. Quicksave shows the issue and the AI loading (when AI goes from offline to online, in fact a dirty solution is to extend the range of AI liveness) too.

So streaming sounds? I don't see anything out of place in the source here. Are you using a build from that, or something else?

kcat avatar Mar 24 '22 06:03 kcat

This could be my oversight. Initial value of Room parameter in Host OpenAL for EAX2 is -10000 (muted reverb).

Fixed that with commit 964a11ef629fa3a89e827516a47949c858ce864c.

Actually, the default value of -1,000mB seems to be correct. That's a linear gain of about 0.32, which matches EFX's default reverb gain. I think the issue is what I mentioned up before, that either sources shouldn't default to having any active fx slots, or the active fx slots (if not all source EAX properties) should reset to default when a buffer is set on a source (and use mono=3D default, mutlichannel=2D default).

kcat avatar Mar 24 '22 06:03 kcat

Fixed that with commit 964a11e.

Sorry, I don't get it how this commit fixes the problem. EAX properties already initialized with proper default values (eax_ = EAXREVERB_PRESETS[EAX_ENVIRONMENT_GENERIC];). Why to initialize then each field separately with same default values (eax_.<field> = <value>;)? Also, the value of EAXREVERB_DEFAULTROOM is -1000. You need to use EAXREVERB_MINROOM to set room's value to -10000 only for EAX2. EAX3 and later uses EAXREVERB_DEFAULTROOM value.

bibendovsky avatar Mar 24 '22 07:03 bibendovsky

I think the issue is what I mentioned up before, that either sources shouldn't default to having any active fx slots, or the active fx slots (if not all source EAX properties) should reset to default when a buffer is set on a source (and use mono=3D default, mutlichannel=2D default).

Room value -10000 effectively mutes the reverb effect on FX slot initialization. Tracking the sources, buffers, .etc, IMHO, will over-complicate the system.

bibendovsky avatar Mar 24 '22 07:03 bibendovsky

Sorry, I don't get it how this commit fixes the problem. EAX properties already initialized with proper default values (eax_ = EAXREVERB_PRESETS[EAX_ENVIRONMENT_GENERIC];). Why to initialize then each field separately with same default values (eax_.<field> = <value>;)? Also, the value of EAXREVERB_DEFAULTROOM is -1000.

Right, sorry, I was one 0 off.

You need to use EAXREVERB_MINROOM to set room's value to -10000 only for EAX2. EAX3 and later uses EAXREVERB_DEFAULTROOM value.

This confuses me since all the EAX versions are accessing the same underlying functionality. As it is, an app can create and use sources before making any EAX calls, and it doesn't seem right to me that making an EAX call (EAXGet especially) will change what sources are doing (alter any playback properties, make sources start using effects, etc), or change the default properties future sources are initialized with. Apps can also use GUIDs for different EAX versions side-by-side (I've seen DSound apps that'll poke at properties for all EAX versions 1-4, even if it just sticks with 1 or 2 during play). So how would it set a different default property for EAX2 than 3, 4, or 5?

kcat avatar Mar 24 '22 07:03 kcat

So streaming sounds? I don't see anything out of place in the source here. Are you using a build from that, or something else?

I don't know if every dropped source is related to a streaming sound but I know they're the ambient sounds (and the music) in game. But it's likely. No, I'm talking about SoC original 1.0005 exe in this case, but the problem can appears in CS and CoP too. In SoC is really evident (just quicksaving or running around until a new group of AI goes online - you notice it by the classic instant freeze and after the freeze ambient sounds and music drop - so press ESC to go into the menu and another time to return in game and the issue solves itself)

donizettilorenzo avatar Mar 24 '22 07:03 donizettilorenzo

No, I'm talking about SoC original 1.0005 exe in this case, but the problem can appears in CS and CoP too. In SoC is really evident (just quicksaving or running around until a new group of AI goes online - you notice it by the classic instant freeze and after the freeze ambient sounds and music drop - so press ESC to go into the menu and another time to return in game and the issue solves itself)

It might be the bug referenced in #174 then. If the stream underruns, the engine doesn't properly restart it. I don't know why it would underrun with OpenAL Soft and not the wrapper driver.

kcat avatar Mar 24 '22 10:03 kcat

With no "heavy" mods installed it seems that 1.0005 is fine with OpenAL Soft. Good enough.

donizettilorenzo avatar Mar 24 '22 18:03 donizettilorenzo

This confuses me since all the EAX versions are accessing the same underlying functionality. As it is, an app can create and use sources before making any EAX calls, and it doesn't seem right to me that making an EAX call (EAXGet especially) will change what sources are doing (alter any playback properties, make sources start using effects, etc), or change the default properties future sources are initialized with. Apps can also use GUIDs for different EAX versions side-by-side (I've seen DSound apps that'll poke at properties for all EAX versions 1-4, even if it just sticks with 1 or 2 during play). So how would it set a different default property for EAX2 than 3, 4, or 5?

I have tested getting / setting the reverb's room in HOAL (except EAX1 - in my case it's unsupported) and, it seems there is a separate reverb state for each version. The effective (audible) value is the last one.

For example, if you set the room to -9999 (mute) in EAX2 and then to -999 (almost default) in EAX3/EAX4/EAX5 you will hear the reverbed sound. Getting the room value in EAX2 will return -9999, and in EAX3/EAX4/EAX5 it will be -999.

bibendovsky avatar Mar 26 '22 15:03 bibendovsky

64 bit XRay 1.5 (Clear Sky) builds too are affected

https://github.com/abramcumner/xray15/releases/download/cs-1.8.0/cs_cs-1.8.0_x64.7z

donizettilorenzo avatar Mar 29 '22 12:03 donizettilorenzo

I have tested getting / setting the reverb's room in HOAL (except EAX1 - in my case it's unsupported) and, it seems there is a separate reverb state for each version. The effective (audible) value is the last one.

Makes me curious if sources, fx slots, contexts, etc, also keep separate state for each version. And if so, whether it applies all properties for the last committed EAX version, or leaves unchanged properties alone.

For instance, if you set a non-default EAX2 source property (e.g. EAXSOURCE_DIRECT), then a different non-default EAX3 source property (e.g. EAXSOURCE_ROLLOFFFACTOR), does the changed EAX2 property audibly revert back, or stay as-is?

Similarly, if you defer a non-default EAX2 source property, then set (non-deferred) a non-default EAX3 listener/context property for, does the EAX2 property value get committed and does the source audibly change to the EAX2 value?

kcat avatar Mar 29 '22 15:03 kcat

For instance, if you set a non-default EAX2 source property (e.g. EAXSOURCE_DIRECT), then a different non-default EAX3 source property (e.g. EAXSOURCE_ROLLOFFFACTOR), does the changed EAX2 property audibly revert back, or stay as-is?

It's reverted back.

Similarly, if you defer a non-default EAX2 source property, then set (non-deferred) a non-default EAX3 listener/context property for, does the EAX2 property value get committed and does the source audibly change to the EAX2 value?

It's unknown. In my case, HOAL does not respect the deferring at all.

bibendovsky avatar Mar 29 '22 18:03 bibendovsky

Now it's OK :D

donizettilorenzo avatar Apr 18 '22 20:04 donizettilorenzo

You can, with

[eax]
enable = false

Why there's no switch in the configuration UI? ( alsoft-config )

donizettilorenzo avatar Apr 26 '22 18:04 donizettilorenzo

TIL there's a GUI configurator. https://github.com/kcat/openal-soft/tree/master/utils/alsoft-config It simply hasn't been updated yet.

EDIT: this was fixed in 9b330e41279884ced8b4d3ddaa63e023f4eb31e9

mirh avatar Apr 26 '22 19:04 mirh

For some reason in OGSR 64 bit ( https://github.com/OGSR/OGSR-Engine/releases ) XRAM feature is not detected (using 1.22):

[07.05.22 16:49:27.616] SOUND: OpenAL: enumerate devices... [07.05.22 16:49:27.616] SOUND: OpenAL: EnumerationExtension Present [07.05.22 16:49:27.616] devices OpenAL Soft [07.05.22 16:49:27.616] SOUND: OpenAL: system default SndDevice name is OpenAL Soft [07.05.22 16:49:27.659] SOUND: OpenAL: All available devices: [07.05.22 16:49:27.659] 1. OpenAL Soft, Spec Version 1.1 (default) eax[0] efx[yes] xram[no] ..... [07.05.22 16:49:27.662] SOUND: Selected device is OpenAL Soft [07.05.22 16:49:27.674] [OpenAL] EFX: present

It is only available through DSOAL/EAXEFX and not "directly"?

donizettilorenzo avatar May 07 '22 15:05 donizettilorenzo

Looks like it ignores EAX for OpenAL Soft devices and only uses EFX: https://github.com/OGSR/OGSR-Engine/blob/main/ogsr_engine/xrSound/OpenALDeviceList.cpp#L95 (it also ignores EFX for non-OpenAL Soft devices and only uses EAX).

It also erroneously checks for "EAX_RAM" through alcIsExtensionPresent with OpenAL Soft, instead of "EAX-RAM" through alIsExtensionPresent (not that it matters as far as functionality goes; OpenAL Soft simply pretends buffers are put into "hardware" or are "accessible", there is no behavioral difference at all).

kcat avatar May 07 '22 16:05 kcat

Thanks! In the next minor release (1.22.1) the configurator will be updated, right?

donizettilorenzo avatar May 07 '22 17:05 donizettilorenzo

Yes.

kcat avatar May 07 '22 17:05 kcat

No, disabling with the line is not working

Il giorno mer 23 mar 2022 alle ore 03:47 kcat @.***> ha scritto:

Native EFX (with the "F")

What about adding EAX control to the config file / configurator of OpenAL Soft so we can customize the behaviour by application?

You can, with

[eax] enable = false

That will prevent the extensions from appearing in the extension list, and even preventing the app from getting the EAX functions with alGetProcAddress (and if it still manages to get and call them somehow despite that, they will fail and do nothing).

If disabling EAX solves the problem, then what's likely happening is the app is making some EAX call even though it uses EFX. Making the EAX call "initializes" EAX for the device, which in turn causes all sources to initialize EAX defaults including the default active effects, which brings it back to what the expected behavior should be for sources with EAX.

Ideally sources shouldn't need to "initialize EAX". They should be able to initialize normally regardless of whether EAX or EFX (or nothing) is used. As far as I can tell, the EAX defaults match up with normal OpenAL/EFX defaults, except the default active slots, which at least from the EAX API headers, is different for 2D and 3D.

And always about old XRay engine games, as I asked in the past, there's any way to avoid partial sound dropping (music, ambient sounds) after a quicksave/data fetching (tipically AI related)?

I'd need to know what's causing the sounds to stop. #174 (comment) https://github.com/kcat/openal-soft/issues/174#issuecomment-792004112 is the only mention of it that I see, but if it's fine with Creative's wrapper, I don't know why it would be a problem for OpenAL Soft. I'd need more info about what makes those sounds different and why they would stop like that. Any log warnings or errors? Any AL errors?

— Reply to this email directly, view it on GitHub https://github.com/kcat/openal-soft/issues/675#issuecomment-1075858951, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOZJ3JVJQDCOPRTBFIVEBDVBKA2LANCNFSM5RK5U2JQ . You are receiving this because you authored the thread.Message ID: @.***>

donizettilorenzo avatar Oct 11 '22 08:10 donizettilorenzo