Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Red Faction 1 - mono sound #18

Open
pachuco opened this issue Sep 26, 2020 · 10 comments
Open

Red Faction 1 - mono sound #18

pachuco opened this issue Sep 26, 2020 · 10 comments

Comments

@pachuco
Copy link
Contributor

pachuco commented Sep 26, 2020

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
Copy link
Owner

kcat commented Sep 26, 2020

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
Copy link
Contributor Author

pachuco commented Sep 26, 2020

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
Copy link
Contributor Author

pachuco commented Sep 26, 2020

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

RedFaction_logs_withEAX.zip

@pachuco
Copy link
Contributor Author

pachuco commented Sep 29, 2020

I've adjusted panning power as such: pachuco@f0041ed
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
Copy link
Contributor Author

pachuco commented Oct 1, 2020

#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
Copy link
Owner

kcat commented Oct 1, 2020

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
Copy link

rafalh commented Oct 3, 2020

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 added a commit to rafalh/dsoal that referenced this issue Oct 4, 2020
This change allows using SetPan API for buffers with DSBCAPS_CTRL3D flag
when DS3DMODE_DISABLE mode is active.
Fixes panning in Red Faction if EAX is enabled.
Partially fixes kcat#18
@ThreeDeeJay
Copy link

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
Copy link

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
Copy link

mirh commented Mar 13, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants