Jump to content


Photo

Improve your TDM experience by playing with OpenAL Soft HRTF (better 3d audio)

hrtf positional audio vr 3d audio

  • Please log in to reply
80 replies to this topic

#51 Hiradur

Hiradur

    Member

  • Member
  • PipPip
  • 68 posts

Posted 31 January 2016 - 10:10 AM

Got this working with TDM, left to right sounds great, but I still have a hard time telling up from down.

 

In this case the default HRTF dataset is probably not matching your head shape well. With luck you will find one which suits your head shape better if you follow this guide: https://www.reddit.c...necraft/cagd3lb

 

How does the KHz setting affect the success of this system? I've read that I should set it manually in the config file to 44.1 at least for Thief 2. Normally my sound card is set to 96.000 btw. So do I need to change both the config file and the sound card settings to 44.1000 to make it work properly?

 

It comes down to for which sample rate you have HRTF datasets available. The problem with the Thief games is that they run at 22,050 Hz and the smallest sample rate you can generate HRTF datasets for is 32,000 Hz with makehrtf.exe. So you have to enforce a higher frequency in the OpenAL Soft config. The sample rate set in Windows doesn't have an effect because the chain goes like this: game sample rate -> OpenAL Soft sample rate (resample if necessary) -> Windows sample rate (resample if necessary).

The default HRTF datasets coming with OpenAL Soft are for 44,100Hz and 48,000Hz but you could generate some for 96,000Hz with makehrtf.exe if you desire.

 

For Thief games I recommend to enforce a multiple of 22,050Hz (44.1kHz, 88.2kHz etc.) to reduce resampling artifacts. For modern games I suggest to enforce nothing or enforce a multiple of 48kHz because that's what most modern games run at.


Edited by Hiradur, 31 January 2016 - 10:14 AM.


#52 SeriousToni

SeriousToni

    Beginner Contest 2012 Winner

  • Member
  • PipPipPipPip
  • 2204 posts

Posted 31 January 2016 - 10:13 AM

Thanks for clarification and sorry for all the dumb questions btw :blush:

I really want to get this working :)


"Einen giftigen Trank aus Kräutern und Wurzeln für die närrischen Städter wollen wir brauen." - Text aus einem verlassenen Heidenlager

#53 Hiradur

Hiradur

    Member

  • Member
  • PipPip
  • 68 posts

Posted 31 January 2016 - 10:41 AM

Thanks for clarification and sorry for all the dumb questions btw :blush:

I really want to get this working :)

 

There are no dumb questions, especially for game audio. There is a lot of wrong information on the internet (e.g. people claiming that EAX equals 5.1 surround sound) so just ask if something is unclear.


  • Deadlove likes this

#54 SeriousToni

SeriousToni

    Beginner Contest 2012 Winner

  • Member
  • PipPipPipPip
  • 2204 posts

Posted 31 January 2016 - 11:07 AM

So I set it up for my Thief 2 NewDark installation (installed with Taffer Patcher) and it also creates a log file now. Ingame in audio I have chosen "OpenAL" and I've set the frequency to 441000 Hz and activated hrtf both in the config file. I get an EAX like echo which changes from room to room (depending on the size) and also there seems to be at least stereo. But looking in my openal.log hrtf seems not to work properly. Asus GX mode is set to OFF and I've set its mode to 2 speakers.

 

Here is my log file for Thief 2

Spoiler

 

Dark Mod said something similiar:

 

Spoiler

 

EDIT: Is it because I have OpenAL installed too? I didn't know how to uninstall it / uninstaller wasnt working, so I just let it there and installed OpenAL Soft just again like you stated in post #001.


Edited by SeriousToni, 31 January 2016 - 11:24 AM.

"Einen giftigen Trank aus Kräutern und Wurzeln für die närrischen Städter wollen wir brauen." - Text aus einem verlassenen Heidenlager

#55 Hiradur

Hiradur

    Member

  • Member
  • PipPip
  • 68 posts

Posted 31 January 2016 - 12:02 PM

So I set it up for my Thief 2 NewDark installation (installed with Taffer Patcher) and it also creates a log file now. Ingame in audio I have chosen "OpenAL" and I've set the frequency to 441000 Hz and activated hrtf both in the config file. I get an EAX like echo which changes from room to room (depending on the size) and also there seems to be at least stereo. But looking in my openal.log hrtf seems not to work properly. Asus GX mode is set to OFF and I've set its mode to 2 speakers.

 


EDIT: Is it because I have OpenAL installed too? I didn't know how to uninstall it / uninstaller wasnt working, so I just let it there and installed OpenAL Soft just again like you stated in post #001.

 

Looks like you didn't change "#hrtf = auto" to "hrtf = true". hrtf = auto only turns on HRTF if OpenAL Soft detects headphones which I believe it only does when Windows detects headphones, which, from my experience, it rarely does.

 

It's safe to have Creative's OpenAL installed as well. It works like this: The game will first look for OpenAL32.dll in the same folder where the .exe file is. If it doesn't find it there it'll instead look at C:\Windows\system32 (32bit Windows or 64bit game on 64bit Windows) or C:\Windows\SysWOW64 (32bit games on 64bit Windows). So if you have e.g. Creative's OpenAL32.dll in C:\Windows\system32 and OpenAL Soft's OpenAL32.dll in the game folder only OpenAL Soft will be used.



#56 SeriousToni

SeriousToni

    Beginner Contest 2012 Winner

  • Member
  • PipPipPipPip
  • 2204 posts

Posted 31 January 2016 - 12:04 PM

You mean this?

## hrtf:
#  Controls HRTF processing. These filters provide better spatialization of
#  sounds while using headphones, but do require a bit more CPU power. The
#  default filters will only work with 44100hz or 48000hz stereo output. While
#  HRTF is used, the cf_level option is ignored. Setting this to auto (default)
#  will allow HRTF to be used when headphones are detected or the app requests
#  it, while setting true or false will forcefully enable or disable HRTF
#  respectively.
hrtf = true

I have set it up in the config file in my User folder, yes


"Einen giftigen Trank aus Kräutern und Wurzeln für die närrischen Städter wollen wir brauen." - Text aus einem verlassenen Heidenlager

#57 Hiradur

Hiradur

    Member

  • Member
  • PipPip
  • 68 posts

Posted 31 January 2016 - 12:08 PM



You mean this?

## hrtf:
#  Controls HRTF processing. These filters provide better spatialization of
#  sounds while using headphones, but do require a bit more CPU power. The
#  default filters will only work with 44100hz or 48000hz stereo output. While
#  HRTF is used, the cf_level option is ignored. Setting this to auto (default)
#  will allow HRTF to be used when headphones are detected or the app requests
#  it, while setting true or false will forcefully enable or disable HRTF
#  respectively.
hrtf = true

I have set it up in the config file in my User folder, yes

 

Yes, this. Is it in the right folder (%appdata%)? Because the log file indicates the value is not set:

AL lib: (II) GetConfigValue: Key hrtf not found


#58 SeriousToni

SeriousToni

    Beginner Contest 2012 Winner

  • Member
  • PipPipPipPip
  • 2204 posts

Posted 31 January 2016 - 12:16 PM

If I insert %APPDATA% into my explorer, I get directed to my user folder in AppData/roaming which exactly is here C:\Users\Toni\AppData\Roaming\openal\hrtf

There I have three files. the default-44100.mhr, the default-48000.mhr and the alsoft.ini in which I made the hrtf = true. This is correct, right?

 

This is what is in the file:

 

Spoiler

Edited by SeriousToni, 31 January 2016 - 12:17 PM.

"Einen giftigen Trank aus Kräutern und Wurzeln für die närrischen Städter wollen wir brauen." - Text aus einem verlassenen Heidenlager

#59 Hiradur

Hiradur

    Member

  • Member
  • PipPip
  • 68 posts

Posted 31 January 2016 - 12:23 PM

If I insert %APPDATA% into my explorer, I get directed to my user folder in AppData/roaming which exactly is here C:\Users\Toni\AppData\Roaming\openal\hrtf

There I have three files. the default-44100.mhr, the default-48000.mhr and the alsoft.ini in which I made the hrtf = true. This is correct, right?

 

alsoft.ini should go into C:\Users\Toni\AppData\Roaming\ not the the openal subfolder.



#60 SeriousToni

SeriousToni

    Beginner Contest 2012 Winner

  • Member
  • PipPipPipPip
  • 2204 posts

Posted 31 January 2016 - 12:39 PM

Omg you're so smart, thank you! :laugh:

 

Now it says hrtf key true and frequency 44100 found. Also ingame it seems to work properly. Especially in Thief 2 I can better find out where the sound is coming from. What an experience together with the room echoes, wow! Thank you so much, again for posting this guide! :)

 

EDIT:

The echoes are very strong in Thief 2 though (I don't hear any in TDM). I reduced them in the config file by -12dB.


Edited by SeriousToni, 31 January 2016 - 05:12 PM.

"Einen giftigen Trank aus Kräutern und Wurzeln für die närrischen Städter wollen wir brauen." - Text aus einem verlassenen Heidenlager

#61 Abusimplea

Abusimplea

    Advanced Member

  • Member
  • PipPipPip
  • 500 posts

Posted 16 May 2016 - 03:07 PM

I tried it - and it is great.

But in some missions i hear an annoying continuous beep sound around some electric lighting. Anyone else experienced that? How did you fix it?



#62 Spooks

Spooks

    Advanced Member

  • Member
  • PipPipPip
  • 508 posts

Posted 16 May 2016 - 03:33 PM

I'm pretty sure that's just a default electric light buzzing sound that some mappers have decided to put on their lights. I don't personally like it either, how I fix it is I try to get out of the room containing the light  :rolleyes:


My FMs: The King of Diamonds (2016)

 

Visit my Mapbook thread sometimes!


#63 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 9102 posts

Posted 16 May 2016 - 03:38 PM

Beep might be the bug where negative values are being sent to the audio driver. (Fixed in 2.04)


Please visit TDM's IndieDB site and help promote the mod:

http://www.indiedb.c...ds/the-dark-mod

(Yeah, shameless promotion... but traffic is traffic folks...)

#64 Abusimplea

Abusimplea

    Advanced Member

  • Member
  • PipPipPip
  • 500 posts

Posted 16 May 2016 - 04:27 PM

It definitely is not the default electric buzzing sound. It is more "pure" - like a synthetic low frequency (somewhere around 500 Hz i guess) sine.

 

When is 2.04 expected to arrive in the updater?



#65 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 9102 posts

Posted 16 May 2016 - 04:39 PM

We are targeting a July 1st release.

Beta is starting very soon:

 

http://forums.thedar...ic-beta-period/


Please visit TDM's IndieDB site and help promote the mod:

http://www.indiedb.c...ds/the-dark-mod

(Yeah, shameless promotion... but traffic is traffic folks...)

#66 lowenz

lowenz

    Advanced Member

  • Member
  • PipPipPip
  • 1922 posts

Posted 17 May 2016 - 04:14 AM

eager to test the new audio stack!


Task is not so much to see what no one has yet seen but to think what nobody has yet thought about that which everybody see. - E.S.


#67 The Black Arrow

The Black Arrow

    Member

  • Member
  • PipPip
  • 49 posts

Posted 17 August 2016 - 03:53 AM

Are the really no more samples other than 44k and 48k? I play at 192k.


Posted Image

#68 Hiradur

Hiradur

    Member

  • Member
  • PipPip
  • 68 posts

Posted 25 August 2016 - 07:37 AM

Are the really no more samples other than 44k and 48k? I play at 192k.

There aren't, but you can create some yourself with the makehrtf tool.

Anyway, I'd like to point out here that sample rates higher than 44.1/48 kHz may have a negative impact on playback quality. I don't want to go into the details myself but I recommend reading this article: https://xiph.org/~xi...neil-young.html
This article was created by the Xiph foundation, they guys behind the free and open source audio codecs FLAC, Vorbis, Opus and a few others.

Edited by Hiradur, 08 December 2018 - 07:44 AM.


#69 stgatilov

stgatilov

    Lead Programmer

  • Active Developer
  • PipPipPip
  • 1126 posts

Posted 28 November 2018 - 12:09 PM

*
POPULAR

Starting from 2.06, TDM uses OpenAL as the only way to produce sounds.

Moreover, on Windows it uses OpenAL-soft bundled into ExtLibs.dll.

It seems that by default HRTF is off.

 

I have an idea to enable HRTF by default.

It is a matter of distributing alsoft.ini and two hrtf data files alongside TDM (outside pk4 files).

Of course, it would most likely work only with headphones (although you can force it in config), and only with suitable sample rates (although you can also force it in config).

For other cases, HRTF will simply not be enabled.

Aside from that, I'll set cf_level to 2 for the case when player cannot load HRTF for some reason.

This is also going to resolve 4898.

 

Are there any downsides?

 

P.S. I have enabled HRTF with default dataset on SVN.


  • STiFU, Judith, PsymH and 4 others like this

#70 STiFU

STiFU

    Uber member

  • Development Role
  • PipPipPipPip
  • 3203 posts

Posted 03 December 2018 - 02:06 AM

 P.S. I have enabled HRTF with default dataset on SVN.

 

That's awesome!!!!!

Anyway, I'd like to point out here that sample rates higher than 44.1/48 kHz actually decrease audio quality even though marketing wants to make you believe otherwise. I don't want to go into details myself but if you are interested in why I recommend this excellent post and the videos it links to: https://xiph.org/~xi...neil-young.html

This post was created by the Xiph foundation, they guys behind the free and open source audio codecs FLAC, Vorbis, Opus and a few others.

Wow, that's quite the misleading generalization there. As an information theorist myself, I was quite surprised by your comment. However, skimming through that article, it became clear quickly, that nothing's wrong with the format per se, but with the cheaper range playback devices. Regardless, for internal signal processing tasks such as HRTF calculations, it might make sense to work at higher bitdepth and resolution first and downsample afterwards.


  • Anderson likes this

#71 Bikerdude

Bikerdude

    Mod hero

  • Member
  • PipPipPipPipPip
  • 20281 posts

Posted 03 December 2018 - 05:24 AM

That's awesome!!!!!

+1



#72 Hiradur

Hiradur

    Member

  • Member
  • PipPip
  • 68 posts

Posted 08 December 2018 - 07:31 AM

Are there any downsides?

Forcing HRTF causes incorrect filtering on speaker setups. Recent OpenAL Soft versions autodetect if headphones or speakers are used and turn on HRTF automatically. I think the autodetection only works if your audio jack is clearly labeled as a headphone jack in the OS (e.g. front outputs of onboard audio).

Wow, that's quite the misleading generalization there.

I was talking about audio playback but reading over the sentence again I could definitely have expressed it in a better way. I edited the above post to make it a bit more clear.

Edited by Hiradur, 08 December 2018 - 07:45 AM.

  • Anderson likes this

#73 stgatilov

stgatilov

    Lead Programmer

  • Active Developer
  • PipPipPip
  • 1126 posts

Posted 08 December 2018 - 09:01 AM

Forcing HRTF causes incorrect filtering on speaker setups. Recent OpenAL Soft versions autodetect if headphones or speakers are used and turn on HRTF automatically. I think the autodetection only works if your audio jack is clearly labeled as a headphone jack in the OS (e.g. front outputs of onboard audio).

Could you please be more specific about "incorrect filtering" ?

I think I tried both setting no value and hrtf = auto in alsoft.ini, but it did not enable HRTF for me with headphones plugged in.



#74 STiFU

STiFU

    Uber member

  • Development Role
  • PipPipPipPip
  • 3203 posts

Posted 08 December 2018 - 02:43 PM

Got this working with TDM, left to right sounds great, but I still have a hard time telling up from down.

In this case the default HRTF dataset is probably not matching your head shape well. With luck you will find one which suits your head shape better if you follow this guide: https://www.reddit.c...necraft/cagd3lb

I don't think it's necessarily the wrong HRTF data set because all those HRTFs are based on recordings that were located on a horizontal plane at ear height, so the model simply does not contain any information on how to filter verticality.
 
Regardless, if you feel like the 3D sound is not good enough for you, I followed the link posted by Hiradur to check out some other HRTF datasets and converted them all for you to try out. Download them here from my dropbox!
 
Howto use different HRTF datasets

  • Give these sounds a listen to find out which dataset fits best for you: http://recherche.irc...ten/sounds.html
  • Copy the files contained in this archive somewhere and find the file whose filename ends with your dataset number.
  • Open alsoft.ini
    • set hrtf-paths to the path where you copied the files (I just copied them in the TDM folder together with the alsoft.ini and TDM/openALSoft will find them automatically)
    • set default-hrtf to the filename without its extension, e.g., oalsoft_hrtf_44100_IRC_1049.
    • set hrtf = true
    • set stereo-mode = headphones
  • Make sure your Sounddriver is set to output 44100 Hz. (I am note sure whether a 48000 Hz file can be generated easily from these sources)
  • Launch TDM via batch to enable openAL Soft logging just to make sure everything has been loaded properly:
    set ALSOFT_LOGLEVEL=3
    set ALSOFT_LOGFILE=[your dark mod directory]\openallog.txt
    start TheDarkModx64.exe
    exit
  • Open openallog.txt, scroll to the end and check whether the mhr has been loaded correctly. It should read like:

AL lib: (II) GetLoadedHrtf: Loading [PATH TO YOUR MHR]...
AL lib: (II) GetLoadedHrtf: Detected data set format v1
AL lib: (II) GetLoadedHrtf: Loaded HRTF support for format: Stereo 44100hz


I have created the mhr files using openal-soft-1.18.2 because TDM also runs this version and won't be able to decode mhr files from newer versions. The attached archive also contains the python script that I used to generate the mhr files.


  • stgatilov likes this

#75 STiFU

STiFU

    Uber member

  • Development Role
  • PipPipPipPip
  • 3203 posts

Posted 08 December 2018 - 03:00 PM

Could you please be more specific about "incorrect filtering" ?

He means that HRTF-filtering does not work with speakers. HRTF-filtering emulates how the headshape and the shape of your ears interact with sound waves. With a perfect  HRTF-Model (taylored to you), you should be able to hear perfect 3d audio using regular stereo head phones. If you use speakers, however, the HRTF-filtering will be performed twice, once in software and once due to your actual head and ear shape. This renders the filtering ineffective and may actually be perceived as a downgrade of software quality. With headphones, the head and ear shape have now effect, because the soundwaves are directly injected into your ear.







Also tagged with one or more of these keywords: hrtf, positional audio, vr, 3d audio

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users