dsoal icon indicating copy to clipboard operation
dsoal copied to clipboard

Red Faction 1 - mono sound

Open pachuco opened this issue 3 years ago • 10 comments

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

pachuco avatar Sep 26 '20 12:09 pachuco

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.

kcat avatar Sep 26 '20 16:09 kcat

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 avatar Sep 26 '20 18:09 pachuco

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

RedFaction_logs_withEAX.zip

pachuco avatar Sep 26 '20 19:09 pachuco

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 avatar Sep 29 '20 08:09 pachuco

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

pachuco avatar Oct 01 '20 18:10 pachuco

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.

kcat avatar Oct 01 '20 22:10 kcat

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:

  • It doesn't support DSPROPSETID_VoiceManager which is required by Red Faction when EAX is enabled
  • It doesn't allow SetPan when DS3DMODE_DISABLE is used (Red Faction sets that mode for all sounds when EAX is enabled)
  • SetPan has very little influence on sounds - Red Faction only uses values in [-1000, 1000] range. If a sound source is exactly at direction [1, 0, 0] from a listener the game passes value 1000 to SetPan which should make the left channel to be attenuated by 10dB. When using dsoal+openal soft I don't really hear any attenuation. When I use native DirectSound I do. When I changed panning range to [-10000, +10000] panning was noticeable but when I tried native DirectSound I noticed such range is much too big. I think the formula that is used to change panning value into 3D coordinates should be changed in some way to properly handle low pan values. Maybe clamping pan values to [-1000, +1000] range and then normalizing to [-1, 1] would be a good idea. It would be worth checking what values other games pass. I can't imagine they would pass as high pan values as 10000 (100dB attenuation) for left/right directions.

rafalh avatar Oct 03 '20 14:10 rafalh

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 avatar Jul 24 '21 12:07 ThreeDeeJay

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

ThreeDeeJay avatar Feb 24 '22 13:02 ThreeDeeJay