project reality header
Go Back   Project Reality Forums > Project Reality Support > General Technical Support > Software & Operating Systems
01 Nov 2024, 00:00:00 (PRT)
Register Developer Blogs Members List Search Quick Links
Software & Operating Systems Discussion on Computer Software & Operating Systems

Reply
 
Thread Tools Display Modes
Old 2022-04-30, 15:32   #1
[R-COM]bad_nade
Support Technician
Supporting Member

bad_nade's Avatar
Lightbulb Win10 DirectSound3D, positional headphone audio & stuff

Hello!

This is not a question nor is this an instruction. This is just a piece of general information without too much technical details. Someday I might write more technically detailed guide on how to setup a system like what's described here but don't hold your breath waiting that to happen. Feel free to ask and comment if you know more than me, or you want to know more.

Ever since I returned to PR in early 2021, I've been trying to setup my gaming audio as good as it's possible in Windows 10. These are some of the things I've done to make PR sound great.

That being said, I never liked the sound quality, or lack thereof, of SoundBlaster X-Fi cards nor did I like their clumsy drivers and management software. I actually sold my Auzen X-Fi card when it was still almost new in favor of my current sound card, an ancient Asus Xonar Essence STX. So I have very little experience with EAX 5. Maybe in the distant future when it's properly reverse-engineered and implemented in the software I use, I can finally enjoy EAX 5 in its full glory. Until that happens, this is what I got.

One of biggest impact on audio in legacy games was Microsoft's decision to retire DirectSound and DirectSound3D (DS3D). After that there was no more hardware accelerated audio API available, and games had to fall back to inferior software audio.

Thankfully, DirectSound is now quite well reverse-engineered and there is a nice piece of software called dsoal that, when dropped in place of the dsound.dll, can emulate pretty much the full functionality of DirectSound and transfer DS3D API calls to OpenAL.

When paired with an OpenAL driver named OpenAL Soft, which in turn is capable of doing positional audio for headphones with a method called HRTF (head-related transfer function), this setup gives what I think is the best positional audio that's currently possible with a legacy game like PR running on Windows 10. The HRTF I'm using came from publicly available Ircam dataset (IRC 1043 for those who are interested).

Another method to get similar results is to use software called HeSuVi, but on my opinion it doesn't give as crisp and clear result as dsoal + OpenAL Soft does.

This is an excerpt from my PR Launcher's support info, showing that "hardare" audio is indeed enabled.
Spoiler for Support Info:
Code:
                Type: Online
   Last Used Profile: True
          View Intro: False
          Fullscreen: True
        Display Mode: 1920x1200@60Hz
  Display Mode Valid: True
     Graphics Scheme: High
       Multisampling: Off
               VSync: False
     Terrain Quality: High
     Effects Quality: High
    Geometry Quality: High
     Texture Quality: High
    Lighting Quality: High
     Dynamic Shadows: High
      Dynamic Lights: High
   Texture Filtering: High
   Statics Lod-Scale: 1,0
Overgrowth Lod-Scale: 1,0
      NoLods Terrain: True
      Audio Provider: Hardware
      Provider Valid: True
       Audio Quality: High
                 EAX: True


Here's a small example of what can be achieved with the setup similar to mine (I use different OpenAL driver). Not my video but this is the one that sparked my interest on the subject. Put on your headphones in normal 2 channel stereo mode, turn off all the possible 3D effects they might have, and listen. You should be able to tell the directions where different sounds come from. Not just side to side but front to back.
bad_nade is offline
Last edited by bad_nade; 2022-04-30 at 20:08..
Reply With Quote
Old 2022-04-30, 20:38   #2
[R-DEV]Mats391
PR:BF2 Lead Developer
Supporting Member
PR Server License Administrator

Mats391's Avatar
Default Re: Win10 DirectSound3D, positional headphone audio & stuff

Sounds interesting. Maybe you could make a video with PR sounds? I feel vanilla bf2 sounds dont do it justice.

Mineral: TIL that Wire-guided missiles actually use wire
Mats391 is offline Reply With Quote
Old 2022-05-02, 11:26   #3
PBAsydney
Supporting Member

PBAsydney's Avatar
Default Re: Win10 DirectSound3D, positional headphone audio & stuff

Used to be able to use X-FI MB3 software to get full EAX functionality to pretty much any on-board sound card, but Creative took down the activation servers so it's not possible to install it anymore.

I'll definitely take a look at this and see how it works.




HITREG CARRY
PBAsydney is offline Reply With Quote
Old 2023-02-02, 07:53   #4
[R-DEV]Mats391
PR:BF2 Lead Developer
Supporting Member
PR Server License Administrator

Mats391's Avatar
Default Re: Win10 DirectSound3D, positional headphone audio & stuff

Bumpy, could you post your settings and maybe setup guide? If this really improves audio, might even add it into Launcher as advanced audio option

Mineral: TIL that Wire-guided missiles actually use wire
Mats391 is offline Reply With Quote
Old 2024-02-04, 13:08   #5
[R-COM]bad_nade
Support Technician
Supporting Member

bad_nade's Avatar
Default Re: Win10 DirectSound3D, positional headphone audio & stuff

I've been away from PR for a while (over a year, actually) but I never gave up the idea of writing more about this. I'll see what I can do. There a couple of problems, though. First one is language barrier. While I can read and write short forum messages in English, writing any kind of technical guide on a language I don't completely understand, is an ovewhelming task. It would be a bit overwhelming for me even in Finnish. Second, I don't truly undestand this Windows & gaming audio either. I consider myself as a nerd, I've been arond computers since forever and I get my living from knowing how to work with an on computers but the whole audio side of computing is mostly black box for me. Lot's of guessing and trial-and-error is what got me here and I still cannot say if its the best possible audio setup for PR. I also might have over-coplicated this for myself, as I always do.
bad_nade is offline
Last edited by bad_nade; 2024-02-04 at 17:19..
Reply With Quote
Old 2024-02-07, 21:07   #6
[R-COM]bad_nade
Support Technician
Supporting Member

bad_nade's Avatar
Default Re: Win10 DirectSound3D, positional headphone audio & stuff

Ok, here we go. Open source virtual headphone surround sound for PR, vanilla BF2 and BF2142. Took me three days just to write the initial version of this post, not counting the numerous post-publish edits.

Mandatory disclaimers
  1. I'm no expert on this.
  2. There is no tl;dr version.
  3. I don't do YouTube videos.
  4. Your mileage may vary.
  5. I wrote the first post in this thread almost 2 years ago. While I try my best to answer your questions, don't expect me to answer any faster than that.
  6. This is only my personal take on the subject. I'm not saying this is the best, the easiest, or even the only way. This is just how I did.
  7. The computer I'm currently typing on and which I also use for playing PR, was originally installed in 2013 and it has been my daily driver ever since. I've only done in-place upgrades of Windows and replaced some hardware, but I have never reinstalled Windows. It means that I have probably forgotten many registry hacks etc. I have done to this computer over the years to make things work.
  8. This is purely software-based emulation of something that used to happen in hardware and thus requires some additional CPU power. If your computer is already struggling with PR, this might not be for you.

Note: The DirectSound replacement (dsoal) that was mentioned in the first post is not needed at all. OpenAL Soft provides us with all the required functionality, including X-FI emulation with EAX. dsoal is needed when playing legacy games that do not have OpenAL support and only use DirectSound. In PR, vanilla BF2 and BF2142, while dsoal works and can be used, it wouldn't make any difference because sounds need to be routed to OpenAl Soft anyway.

Another note: PR Launcher seems to do extra checks related to sounds. Because of that settings that work in vanilla BF2 won't work in PR. For example, I haven't managed to enable X-FI UltraHigh sounds with EAX in PR while it works fine in vanilla.

Installing the software
Spoiler for Install:

Software portion of this goes just like it has always been done with BF2 and mods: Update the BF2OpenAL.dll.
  1. Go to https://openal-soft.org/, download the latest OpenAL Soft and unzip it somewhere. As of this writing the latest version is 1.23.1.
  2. In the bin\Win32 folder of the unzipped file, find the soft_oal.dll and rename it to BF2OpenAL.dll.
  3. Copy the BF2OpenAL.dll to the folder where you installed PR. If a file with the same name already exists, rename it first and save it as a backup.
You can repeat the third step for vanilla BF2 and BF2142.


Configuring OpenAL Soft and the HRTF
Spoiler for Configure:

This part is the reason why many headset manufacturers provide their own, usually branded and trademarked version of HRTF (like Windows Sonic, Dolby Headphones, Razer Surround etc.) When dealing with open source software, setup becomes so much more complicated than "check-the-checkbox" method of a commercial product.

The easiest way is to use OpenAL Soft built-in HRTF (MIT KEMAR) and call it a day. It might not be perfect and there probably are much better options, but the better ones are also much, much harder to set up. I know how do it but it but I'm not going to eplain it in this post.

For me the built-in HRTF gives completely messed up perception of direction of sounds. I replaced it with another HRTF that was genrated from IRCAM dataset (IRC_1013 or IRC_1043, depending on my headphones) and it was a huge improvement. Well worth the trouble of downloading and listening dozens of sample sounds. Spatial sound is highly personal thing, though. What works for me probably won't work for you, and vice versa. That's why you might as well start with the easiest option.

OpenAL Soft reads its configuration from the file %APPDATA%\alsoft.ini. Open or create it with Notepad (Start -> Run -> notepad "%APPDATA%\alsoft.ini") and copy-paste these lines into the file. This is as close as possible to the bare minimum that still works. My personal alsoft.ini has only two more lines that are required for loading HRTF from external file.

Code:
[General]
stereo-mode=headphones
stereo-encoding=hrtf
resampler=cubic

[eax]
enable = true


Configuring Windows
Spoiler for Windows:

In the Windows Sound Control Panel (Start -> Run -> mmsys.cpl) find your default playback device and change its speaker layout to Stereo by pressing the Configure button. After finishing the wizard, double-click the same device, go to Advanced tab and change the default format to 24 bit, 44100 Hz to avoid resampling when playing PR. Resampling is no big deal and the cubic resampler in the alsoft.ini does good job, but I like to keep things as close to bit-perfect (or Hertz-perfect) as possible.

Turn of all other sound enhancements and equalizers.


Configuring PR
Spoiler for Game:

Turn your sound settings to Hardware/High. If you are playing vanilla BF2 or BF2124, you can enable X-FI/UltraHigh.

And you're done. Put on your headphones/headset and start playing.

If you're lucky and the OpenAL Soft's built-in HRTF is perfect match for you, you should be able to tell the direction a sound is coming from. Not only front-back-left-right direction but up-down as well, and with smooth transitions as you and sound sources move around in the game.

If you're not lucky and sounds do not feel like they are coming from direction they should, then you either have bugged setup or the built-in HRTF is not suitable for you. In the first case, continue to Debugging section. Otherwise you have to dive into world of selecting a better HRTF. I can help you with that but I can't do it for you.


Debugging
Spoiler for Debugging:

OpenAL Soft recognizes two environment variables that can be used to enable debug logging.

ALSOFT_LOGLEVEL
Specifies the amount of logging OpenAL Soft will write out:
0 - Effectively disables all logging
1 - Prints out errors only
2 - Prints out warnings and errors
3 - Prints out additional information, as well as warnings and errors

ALSOFT_LOGFILE
Specifies a filename that logged output will be written to. Note that the file will be first cleared when logging is initialized.

I tend to keep ALSOFT_LOGLEVEL at 3 all the time. When playing PR, the log file does not increase over time and it’s just a few kilobytes in size. It's also cleared every time I start playing, so it's no issue to log everything all the time.

There is lots of useful information in the log but the single most important line you want to see is:
Code:
[ALSOFT] (II) 1st order + Full HRTF rendering enabled, using "<whatever hrtf you selected>"
If that line is missing, then there is no positional sound processing happening. Note that stereo sounds probably work just fine regardless.

Loading a game after every config change is time consuming, so I recommend downloading and installing the official OpenAL 1.1 Core SDK. Note that it's a completely different software than the OpenAL Soft we've been dealing with so far. The SDK comes with a bunch of pre-compiled sample applications that can be used for quick testing: https://www.openal.org/downloads/.

If you are going to use SDK sample apps, you have to update Window's 32-bit and 64-bit versions of OpenAL32.dll's the same way you updated PR/BF2/BF2142's BF2OpenAL.dll.

The 32 and 64 bit OpenAL32.dll's can be found in directories C:\Windows\SysWOW64 and C:\Windows\System32, respectively. In 32-bit Windows you will only have C:\Windows\System32.

OpenAL Soft includes command line tools for inspecting 32-bit and 64-bit system-wide OpenAL configuratios. The tools are openal-info32.exe and openal-info64.exe, respectively. They are located in the root of the distribution zip file.


Glossary
Spoiler for Glossary:

Short glossary, in layman terms, of acronyms you will encounter when dealing with OpenAL Soft and spatial sound in general.

MIT: Massachusetts Institute of Technology Media Lab

IRCAM: Institute for Research and Coordination in Acoustics/Music

CIAIR: Itakura Laboratory and the Center for Integrated Acoustic Information Research of Nagoya University

SCUT: South China University of Technology

KEMAR: Brand name of a dummy head used for recording various things.

SOFA: Spatially Oriented Format for Acoustics. Industry standard file format for storing spatially oriented acoustic data.

HRIR: Head-Related Impulse Response. Describes how sound, in relation to the physical location of the source, changes when traveling thru and around human body before reaching eardrum. It is calculated from sound signal that was recorded from ears of real human or dummy head in anechoic chamber when a speaker was moved around the listener. Recording was then processed into HRIR dataset that can be downloaded and used in other apps. HRIR is the data from which HRTF is calculated.

HRTF: Head-Related Transfer Function. A method for manipulating sound in a way that human brain thinks it's coming from another direction. The HRTF is the Fourier transform of HRIR. OpenAL Soft uses its own HRTF file format (.mhr) and the tool (makehmr.exe) for converting HRIR into .mhr file is included in the distribution zip file.


HTH
bad_nade is offline
Last edited by bad_nade; 2024-02-11 at 21:50..
Reply With Quote
Old 2024-02-11, 19:23   #7
[R-DEV]Mats391
PR:BF2 Lead Developer
Supporting Member
PR Server License Administrator

Mats391's Avatar
Default Re: Win10 DirectSound3D, positional headphone audio & stuff

Thanks for the instructions. I tried them and they work for me, but just as you, I have no idea what other registry edits might have impact. I tried a different method where you just add dsound.dll to the root before, but never got that to work.

The audio sounds quite different with this. Most notably everything seems to go quieter more quickly in distance. In tanks the listener obstruction works way better than with default and it is actually hard to hear stuff outside.
I also noticed some bugs tho. Mainly the stopping of looping sounds does not work correctly. If you jump out of a vehicle, the engine keeps running for couple of seconds until the loop is completed.

Mineral: TIL that Wire-guided missiles actually use wire
Mats391 is offline Reply With Quote
Old 2024-02-11, 19:54   #8
[R-COM]bad_nade
Support Technician
Supporting Member

bad_nade's Avatar
Default Re: Win10 DirectSound3D, positional headphone audio & stuff

To make dsound.dll work, you need dsoal version of it. There are older debug versions on the internet but compiled my own release build from the latest Git commit (52224b17832fda41d02153cf8f56d27cd94bf79a). The file must be placed in the same dir as PRBF2.exe. In addition to the dsound.dll you also need latest oal_soft.dll renamed to dsoal-aldrv.dll sitting in the same directory, and you have to enable Windows dll redirection by creating an empty file named PRBF2.exe.local. Based on my tests the BF2OpenAL.dll needs to be OpenAL Soft version as well. But like I wrote in the previous post, dsound/dsoal is not needed wth BF2.

With either method, plain OpenAL Soft or dsoal + OpenAL Soft, I was able to enable Creative X-FI UltraHigh with EAX in vanilla BF2. But when I tried to enable same settings in PR, launcher started complaining that I don't have hardware support and the Ignore checkbox on the dialog didn't help.

No matter which route you take the whole point of this is to get nice positional sound, and to get the best possible results requires some extra work. There are tons of different HRTF/HRIR's listed at
https://airtable.com/appayGNkn3nSuXk...oLjoZKWJDnLtTc
but so far I've been using only the Listen project created in 2002 - 2003 in France. The Listen project is also referred to as IRCAM, based on the research institue where recordings were performed. OpenAL Soft only provides .def files for four datasets and IRCAM is one of them.
http://recherche.ircam.fr/equipes/sa...ten/index.html

The idea is to listen all demo sounds using the same stereo headset you use for gaming, and pick the one that provides the best positional experience. Then you need to download the HRIR package matching the sample sound ID number from IRCAM's FTP site, extract it, create a .def file for that HRIR and finally convert it to OpenAL Soft HRTF format using makemhr.exe.

For someone proficient with computers this is quite straightforward yet laborious task. You also need an FTP app to download demo sounds and HRIRs because all modern browsers have dropped FTP support altogether. For creating the .def file, OpenAL Soft includes IRC_1005.def file as an example for IRCAM HRIRs. The IRC_1005.def file needs to be renamed and its content edited to match the sample number you selected earlier. Instructions are in the file.

For other datasets listed on the Airtable page there are no .def files which means they cannot be used with OpenAL Soft. I've been contemplating on learning how to create makemhr-compatible HRIR def file for an arbitary SOFA file but haven't had any time or energy for that yet.

Spoiler for Screenshots:


Vanilla BF2 works fine and sounds great. This is just with OpenAL Soft version of BF2OpenAL.dll (no dsound.dll).



No X-FI for you. Thankfully positional sounds works with Hardware/High as well.

bad_nade is offline
Last edited by bad_nade; 2024-02-11 at 21:32..
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 03:42.