kcat / dsoal

A DirectSound DLL replacer that enables surround sound, HRTF, and EAX support via OpenAL Soft
GNU Lesser General Public License v2.1
385 stars 51 forks source link

Red Faction 1 - mono sound #18

Open pachuco opened 4 years ago

pachuco commented 4 years ago

In Red Faction 1, all sounds except music will be mono and come from inside head. That is, only distance volume attenuation is done, with no panning. Enabling hrtf makes things worse.

For test, I've used SoftOAL 39f4ea6 and my own XP DSOAL fork. The fork should function about the same(though, some functions have been redirected to real DirectSound and will not log), but I had friend check on his win10 PC to be sure.

Video recordings courtesy of 3DJ: https://streamable.com/zpuouq DSOAL with hrtf and EAX https://streamable.com/8409wb real DirectSound without EAX

I've also attached logs of me running RF1 with XP DSOAL, as well as batch used to run game. I've kept interactions with game few. Start game directly in level, walk forward, pick remote charges, turn 90 right, throw charge and watch it stick, turn left 90, detonate, quit via console. RedFaction_logs.zip

kcat commented 4 years ago

The fork should function about the same(though, some functions have been redirected to real DirectSound and will not log)

Which functions are those? From the DSOAL log, it seems to be using plain old DSound, not DSound3D. There's no apparent attempt to test for hardware capabilities or to use EAX, and sound positioning is done with SetVolume for distance and SetPan for left-right panning (and even then, the pan amount is rather small). It even specifies to place buffers in software. I don't know what the game normally does. but it's not trying to use 3D effects.

As far as the sounds being mono, it may be worthwhile to expand the panning width, but that won't fix the underlying issue of it not using hardware.

pachuco commented 4 years ago

The functions are these: https://github.com/pachuco/dsoal/blob/master/bypass.c Maybe the game is reacting to something it detected in dsound for it to give small panning values.

Also, I am a dum-dum and forgot to enable EAX in options when recording logs. Enabling it doesn't improve stereo image, nor enable echo effects in starting mine level(maybe fails for previous reason?).

pachuco commented 4 years ago

I've re-recorded above logs with EAX enabled this time. DSBufferProp_QuerySupport(DSPROPSETID_VoiceManager) is checked for.

RedFaction_logs_withEAX.zip

pachuco commented 4 years ago

I've adjusted panning power as such: https://github.com/pachuco/dsoal-XP/commit/f0041edcf3d4d9f94c1c17bf0718240b8c4b7135 This fixes the "mono sound" in RF1. Needs checking for other games, though.

What remains now is DSPROPSETID_VoiceManager and whatever else the game may check for after it is implemented.

pachuco commented 4 years ago

https://github.com/kcat/dsoal/pull/19 Now that DSPROPSETID_VoiceManager is done, another piece of puzzle appears.

"DS8_CreateSoundBuffer Requested 3D algorithm GUID: {00000000-0000-0000-0000-000000000000}" "DS8_CreateSoundBuffer Buffers with 3D and panning control ignore panning"

So the game now does 3d DSound calls, but seems to mix them with regular DirectSound SetVolume and SetPan. EAX reverb works dandy fine, but sound only gets distance amplitude, with no positioning. Logs attached.

RedFaction_logs_withEAX_VMfix.zip

kcat commented 4 years ago

It seems to set the listener position/orientation regularly with movement, but all the sound buffers are set to DS3DMODE_DISABLE upon creation and use panning for positioning, which makes the listener position/orientation meaningless (and DSOAL doesn't apply panning for buffers that have DSBCAPS_CTRL3D, even when 3D mode is set to disabled; I suppose that would need to be changed). For EAX, it just sets preset environment 0 (Generic) at the start and leaves it alone.

Oddly it uses DSBCAPS_CTRL3D | DSBCAPS_MUTE3DATMAXDISTANCE on sound buffers, despite not using 3D distance and positioning stuff. Makes me wonder if some other query is not returning proper information so it's only partially recognizing 3D calls.

rafalh commented 4 years ago

I know a lot of game internals (I'm developer of Dash Faction modification for Red Faction) and I can ensure you that the game never really uses 3D simulation provided by DirectSound. It calculates panning and uses SetPan API for 3D sounds even when buffers have DSBCAPS_CTRL3D flag. I think buffers are created with DSBCAPS_CTRL3D because otherwise EAX effects wouldn't work (I tried to remove that flag and got no EAX effects). If you disable EAX in game options game no longer uses any 3D API. There are 3 problems with dsoal at this moment that I know:

ThreeDeeJay commented 3 years ago

https://youtu.be/v2QNGPwS2X8 DSOAL XP with hrtf and EAX https://youtu.be/MOOXkeTX7Eo real DirectSound without EAX Just in case, re-uploaded the clips referenced in the main post cuz streamable removes after some time. Anyway, bonus: https://youtu.be/bSo0rq3lCgA Real sound card with EAX https://youtu.be/1C4fKGHViyg DSOAL on Windows 10

ThreeDeeJay commented 2 years ago

Yesterday I decided to try this game with the latest DSOAL and to my great surprise, both EAX and 3D audio seem to be finally working! Thanks to @rafalh and his great work fixing audio in Dash Faction. Video and details: https://youtu.be/ZnulyCI8QlY

mirh commented 1 year ago

Of note that you might or might not have noticed, DSBCAPS_CTRL3D behaviour with DSBCAPS_CTRLPAN is pretty different (as in: they are supposedly incompatible) if you go from IDirectSound to IDirectSound8.