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
67 replies to this topic

#1 Hiradur

Hiradur

    Member

  • Member
  • PipPip
  • 65 posts

Posted 20 January 2016 - 12:21 PM

*
POPULAR

I was surprised to find nothing about HRTF on this site so I decided to make a thread about what it is, how it improves your TDM experience and how you can get it.

 

For Germans:

Quasi den gleichen Thread gibt es auf Deutsch hier: http://www.hardwarel...es-1013497.html

 

What is HRTF?

To put it simply: Our brain can determine the position of sounds so accurately because depending on where the sound comes from it goes through different zones of our head where the sound is unnoticeably changed but it's enough for the brain to put it into 3d space.

HRTF is a technique to improve positional audio in games by filtering the audio signal the same way it would be changed when passing through our heads. This way the positioning is spot-on and feels very real.

 

I have some demo videos on Youtube if you are in doubt it works:

Please note that HRTF suffers greatly under audio compression and is much better in real life!

 

What do I need for HRTF?

In this topic I will only talk about OpenAL Soft HRTF because this is the only way at the moment to get HRTF from TDM.

You need:

- Headphones! (in theory HRTF would work with speakers as well but there are no datasets for speakers)

- OpenAL Soft version >= 1.14 (the way how HRTF can be used changed between versions, I will only talk about the latest version, 1.17.1 here)

 

That's it! No specific sound card required or anything.

It is however very easy to mess up the setup so that HRTF doesn't work. Follow the guide closely to make sure it works.

 

 

How do I set it up?

Windows 32 Bit:
- Download current build of OpenAL Soft

- move soft_oal.dll from bin\Win32 as "OpenAL32.dll" to C:\Windows\system32

Windows 64 Bit:

- warning: Due to the architecture of Windows the 32/64 bit numbers are confusing. My tutorial is correct, don't be confused!
- Download current build of OpenAL Soft

- move soft_oal.dll from bin\Win32 as "OpenAL32.dll" to C:\Windows\SysWOW64 (for 32 bit games)
- move soft_oal.dll from bin\Win64 as "OpenAL32.dll" to C:\Windows\system32 (for 64 bit games)
 

 

Final steps for both Windows versions:

- move standard HRTF datasets (default*.mhr) from hrtf to %appdata%\openal\hrtf

- remove OpenAL32.dll/wrap_oal.dll from the game folder if existing
- Copy all text from alsoftrc.sample, create alsoft.ini in %appdata%, paste the text from alsoftrc.sample into alsoft.ini and change "#hrtf = auto" to "hrtf = true" (remove "#"!)

- make sure your audio sample rate is 44,1kHz or 48kHz

- turn on OpenAL in Darkmod.cfg (seta s_useOpenAL "1")

- set TDM to stereo sound

- To make sure it works run put this in a .bat file and run it from the TDM folder:

 

set ALSOFT_LOGLEVEL=3
set ALSOFT_LOGFILE=openallog.txt
TheDarkMod.exe

 

Check openallog.txt if HRTF is enabled.

 

Linux:
- Make sure your OpenAL Soft version is >= 1.14

- Depending on the distribution and OpenAL Soft install you may need to install the HRTF datasets manually:
  - Download current build of OpenAL Soft and move default*.mhr from hrtf to ~/.local/share/openal/hrtf
- Download alsoftrc.sample and save to ~/.alsoftrc[/QUOTE]
- In ~/.alsoftrc change "#hrtf = auto" to "hrtf = true" (remove "#"!)

- set TDM to stereo sound

 

 

Advanced users:

There is a way to improve the positioning even more: Because the default HRTF datasets are made for an "average" head they may not be optimal for you. You can create your own by following this guide:

https://www.reddit.c...necraft/cagd3lb

 

 

PS: This also works with Thief 1&2 running on NewDark but you have to enforce a frequency of 44,100 kHz in alsoft.ini for it to work because Thief's sounds are in 22,050 khz.

PPS: In order to spread the awareness of HRTF I license this forum post under CC-BY so you can repost it anywhere when giving credit to me.


Edited by Hiradur, 27 January 2016 - 06:43 AM.

  • SiyahParsomen, SeriousToni, jaxa and 9 others like this

#2 Hiradur

Hiradur

    Member

  • Member
  • PipPip
  • 65 posts

Posted 20 January 2016 - 12:41 PM

@The developers: With recent versions of OpenAL Soft software can now request HRTF processing itself. Before it could only be enforced in the OpenAL Soft config file. Any chance this could make it to TDM?

Since OpenAL Soft is LGPLv2 licensed you could bundle it with TDM.


  • Anderson likes this

#3 New Horizon

New Horizon

    Mod hero

  • Active Developer
  • PipPipPipPipPip
  • 13831 posts

Posted 20 January 2016 - 01:07 PM

Any videos of this working in TDM by any chance?  I'm at work and am unable to test this until late this evening. 



#4 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 8984 posts

Posted 20 January 2016 - 01:09 PM

This is an interesting wrinkle.

 

We have an internal EFX branch but it doesn't do full HRTF as I recall. It would be a shame to throw away all that work but (OTOH) if this can just be bundled without

having to dig into the innards of EAX code then it would be a nice stop gap until the 64-bit branch arrives.


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...)

#5 Hiradur

Hiradur

    Member

  • Member
  • PipPip
  • 65 posts

Posted 20 January 2016 - 01:25 PM

Any videos of this working in TDM by any chance?  I'm at work and am unable to test this until late this evening. 

 

Not yet, I'll see if I can make one but I can't promise it will make it in time.

 

This is an interesting wrinkle.

 

We have an internal EFX branch but it doesn't do full HRTF as I recall. It would be a shame to throw away all that work but (OTOH) if this can just be bundled without

having to dig into the innards of EAX code then it would be a nice stop gap until the 64-bit branch arrives.

 

EFX and HRTF are two different things though. EFX (or its predecessor EAX) processes sounds with reverb presets to make them reflect the environment they are in (e.g. sounds in a huge hall have long echo). This doesn't improve positional audio (probably makes it worse due to the reverb but that's realistic at least). HRTF only improves positional audio. Both in combination make for a very realistic experience.


Edited by Hiradur, 20 January 2016 - 02:40 PM.

  • SiyahParsomen and Anderson like this

#6 New Horizon

New Horizon

    Mod hero

  • Active Developer
  • PipPipPipPipPip
  • 13831 posts

Posted 20 January 2016 - 01:50 PM

Ahh, so they compliment each other.  Nice.  We can still use both then. 

 

It would be very nice to have better positional audio in TDM



#7 Springheel

Springheel

    Creative Director (retired)

  • Admin
  • 37376 posts

Posted 20 January 2016 - 03:33 PM

It would be very nice to have better positional audio in TDM

 

 

Not as useful if it only works on headphones though.


TDM Missions:   A Score to Settle   *   A Reputation to Uphold   *   A New Job   *    A Matter of Hours
 
Video Series:   Springheel's Modules   *   Speedbuild Challenge   *   New Mappers Workshop  *   Building Traps

#8 jaxa

jaxa

    Advanced Member

  • Member
  • PipPipPip
  • 1325 posts

Posted 20 January 2016 - 03:52 PM

Not as useful if it only works on headphones though.

 

I was ready to greentext you. Who doesn't play TDM with headphones?

 

This seems like a good poll question. What sound system do you predominantly use with TDM? Headphones, earphones, laptop speakers, discrete/external speakers, 5.1 surround sound system, etc.


  • Deadlove likes this

#9 Hiradur

Hiradur

    Member

  • Member
  • PipPip
  • 65 posts

Posted 20 January 2016 - 04:04 PM

 
Not as useful if it only works on headphones though.

 
Well, OpenAL Soft has great positional audio even without HRTF on speakers (definitely better than TDM's default). There is also another way to improve positional audio for speakers. Doom 3/TDM uses DirectSound3D by default which was replaced by very poor software audio in Windows Vista. Creative wrote the Alchemy wrapper to bring DirectSound 3D back. It only works with Creative sound cards though. It improves positional audio for older games by a large margin for any Windows newer than XP. However, OpenAL Soft is better than DS3D in every way and should be preferred since it's natively supported by TDM.
 
@New Horizon: I recorded a video. Uploading now. Should take an hour though. Will be here:
https://youtu.be/MVqFbu4gsqs

Edited by Hiradur, 06 December 2016 - 04:22 AM.

  • Anderson and Deadlove like this

#10 Springheel

Springheel

    Creative Director (retired)

  • Admin
  • 37376 posts

Posted 20 January 2016 - 04:24 PM

Who doesn't play TDM with headphones?

 

 

People with 5.1 surround sound, I imagine.

 

Though I've never been satisfied with the way TDM does 5.1 sound.


TDM Missions:   A Score to Settle   *   A Reputation to Uphold   *   A New Job   *    A Matter of Hours
 
Video Series:   Springheel's Modules   *   Speedbuild Challenge   *   New Mappers Workshop  *   Building Traps

#11 Hiradur

Hiradur

    Member

  • Member
  • PipPip
  • 65 posts

Posted 20 January 2016 - 05:02 PM

Though I've never been satisfied with the way TDM does 5.1 sound.

 

Give it a try with OpenAL Soft (you can set 5.1 in its config), surround sound with the DS3D software implementation in Vista and above is very bad.

 

EDIT: Demo video now up


Edited by Hiradur, 20 January 2016 - 05:11 PM.

  • nbohr1more and Anderson like this

#12 lowenz

lowenz

    Advanced Member

  • Member
  • PipPipPip
  • 1876 posts

Posted 20 January 2016 - 06:00 PM

I believe we can move the runtime/dlls to TDM folder too, without any name change (and so keeping ALL the OpenAL implementations, SoftOpenAL one and Creative one)

 

seta s_useOpenAL "1"
-> seta s_libOpenAL "soft_oal.dll"

Edited by lowenz, 20 January 2016 - 06:01 PM.

  • nbohr1more likes this

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.


#13 Hiradur

Hiradur

    Member

  • Member
  • PipPip
  • 65 posts

Posted 21 January 2016 - 03:35 AM

 

I believe we can move the runtime/dlls to TDM folder too, without any name change (and so keeping ALL the OpenAL implementations, SoftOpenAL one and Creative one)

 

seta s_useOpenAL "1"
-> seta s_libOpenAL "soft_oal.dll"

 

 

Yes, this should work. Unless you are using a Creative card though OpenAL Soft may be superior to Creative's OpenAL implementation.


  • Anderson likes this

#14 Bikerdude

Bikerdude

    Mod hero

  • Member
  • PipPipPipPipPip
  • 20175 posts

Posted 21 January 2016 - 04:57 AM

I run 5.1 and have in the past played about with eax when tdm still required doom3.

So will give this a run through on the headphones and 5.1, with before and after vids.

#15 Hiradur

Hiradur

    Member

  • Member
  • PipPip
  • 65 posts

Posted 21 January 2016 - 05:35 AM

I run 5.1 and have in the past played about with eax when tdm still required doom3.

So will give this a run through on the headphones and 5.1, with before and after vids.

 

Please note that EAX and 5.1 surround sound (positional audio in general) are two different things as I mentioned in a post above.

 

I think this video demonstrates what EAX and its successor EFX do quite well:

 

It's adding reverb to his voice depending on the environment he is in. You can clearly tell it has nothing to do with surround sound.


  • Anderson likes this

#16 New Horizon

New Horizon

    Mod hero

  • Active Developer
  • PipPipPipPipPip
  • 13831 posts

Posted 21 January 2016 - 06:40 AM

I run 5.1 and have in the past played about with eax when tdm still required doom3.

So will give this a run through on the headphones and 5.1, with before and after vids.


Yes, as noted, this is for better positional audio and not environmental effects. EFX would still need to be implemented in the future.

#17 lowenz

lowenz

    Advanced Member

  • Member
  • PipPipPip
  • 1876 posts

Posted 21 January 2016 - 06:56 AM

As far as I know Soft OpenAL HRTF requires a *stereo* setup (not 5.1) for the speakers, so remember to select stereo in TDM options.


Edited by lowenz, 21 January 2016 - 06:58 AM.

  • Anderson likes this

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.


#18 Springheel

Springheel

    Creative Director (retired)

  • Admin
  • 37376 posts

Posted 21 January 2016 - 08:32 AM

So will give this a run through on the headphones and 5.1, with before and after vids.

 

 

I'll be interested in your results.


  • Bikerdude likes this
TDM Missions:   A Score to Settle   *   A Reputation to Uphold   *   A New Job   *    A Matter of Hours
 
Video Series:   Springheel's Modules   *   Speedbuild Challenge   *   New Mappers Workshop  *   Building Traps

#19 Hiradur

Hiradur

    Member

  • Member
  • PipPip
  • 65 posts

Posted 21 January 2016 - 12:41 PM

As far as I know Soft OpenAL HRTF requires a *stereo* setup (not 5.1) for the speakers, so remember to select stereo in TDM options.

 

That's correct, I forgot to mention this in the guide. Thanks.


  • Anderson likes this

#20 Deadlove

Deadlove

    Advanced Member

  • Member
  • PipPipPip
  • 978 posts

Posted 21 January 2016 - 04:22 PM

Isn't there an easier way to do this? 

 

I'm a little lost.


Plastik Musik - Andrew Nathan Kite, Owner

plastikmusik33@gmail.com

http://www.facebook.com/plastikmusik /

http://www.youtube.com/plastikmusik

http://www.plastikmusik.bandcamp.com

 

 


#21 Hiradur

Hiradur

    Member

  • Member
  • PipPip
  • 65 posts

Posted 21 January 2016 - 04:50 PM

Isn't there an easier way to do this? 
 
I'm a little lost.


Unfortunately there isn't. What's your problem?
  • Anderson likes this

#22 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 8984 posts

Posted 21 January 2016 - 05:08 PM

Hmm I guess someone should open a feature request for a portable implementation. Having to leave the config files in appdata

seems a bit messy. It would be ideal if you could just plop the dll and config files next to your app (and for TDM set the OpenAL driver

console commands).


  • Deadlove likes this
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...)

#23 Deadlove

Deadlove

    Advanced Member

  • Member
  • PipPipPip
  • 978 posts

Posted 21 January 2016 - 08:16 PM

My problem at this point is:

 

Final steps for both Windows versions:

- move standard HRTF datasets (default*.mhr) from hrtf to %appdata%\openal\hrtf

- remove OpenAL32.dll/wrap_oal.dll from the game folder if existing
Download alsoftrc.sample, save as alsoft.ini to %appdata% and change "#hrtf = false" to "hrtf=true" (remove "#"!)

- make sure your audio sample rate is 44,1kHz or 48kHz

- turn on OpenAL in Darkmod.cfg (seta s_useOpenAL "1")

- set TDM to stereo sound

 

---------------------------------------------------

 

I got that far, but can't seem to locate or know what to do. The download mentioned is just a text of code. I don't get it. I'm sorry for not being as up to par. Just trying to really enjoy TDM with some positional audio.

 

Thank you.


Plastik Musik - Andrew Nathan Kite, Owner

plastikmusik33@gmail.com

http://www.facebook.com/plastikmusik /

http://www.youtube.com/plastikmusik

http://www.plastikmusik.bandcamp.com

 

 


#24 Hiradur

Hiradur

    Member

  • Member
  • PipPip
  • 65 posts

Posted 22 January 2016 - 04:33 AM

My problem at this point is:

 

Final steps for both Windows versions:

- move standard HRTF datasets (default*.mhr) from hrtf to %appdata%\openal\hrtf

- remove OpenAL32.dll/wrap_oal.dll from the game folder if existing
Download alsoftrc.sample, save as alsoft.ini to %appdata% and change "#hrtf = false" to "hrtf=true" (remove "#"!)

- make sure your audio sample rate is 44,1kHz or 48kHz

- turn on OpenAL in Darkmod.cfg (seta s_useOpenAL "1")

- set TDM to stereo sound

 

---------------------------------------------------

 

I got that far, but can't seem to locate or know what to do. The download mentioned is just a text of code. I don't get it. I'm sorry for not being as up to par. Just trying to really enjoy TDM with some positional audio.

 

Thank you.

 

Now I'm not sure which step exactly you are lost on but the HRTF datasets are in the hrtf directory in openal-soft-1.17.1-bin.zip

 

For alsoftrc.sample you have to create an alsoft.ini file in %appdata% and then copy the text from https://raw.githubus...alsoftrc.sample to this ini file. Inside the ini file you change "#hrtf = false" to "hrtf=true" (remove "#"!).

 

 

Hmm I guess someone should open a feature request for a portable implementation. Having to leave the config files in appdata

seems a bit messy. It would be ideal if you could just plop the dll and config files next to your app (and for TDM set the OpenAL driver

console commands).

 

 

I guess the easiest way to achieve that would be to bundle soft_oal.dll with TDM and add an option to the settings menu for HRTF.

I'm taking this opportunity to propose to make OpenAL Soft the default for audio because there is really no reason not to. DirectSound3D, which is used by TDM by default, only offers good positional audio on Windows XP and older as I said above. Nobody should be using these old Windows versions anymore and even if they do they can just disable OpenAL (OAL Soft ist better than DS3D in every aspect though).

I want to make clear that OpenAL Soft offers great positional audio not only for headphone users but also for speakers, including surround sound systems. I'm one of the Rigs of Rods developers and we've been using OpenAL Soft for years and the audio experience is just great.

 

 

btw: The alsoft.ini file offers some more options other than HRTF. You can set the angles in which speakers point to you for better positioning and you can enforce using a 5.1 setup for example which I would do if you are using one because with Windows you can never be totally sure if it's detecting it correctly. You can also set a resampling algorithm. Sinc4/8 e.g. works wonders for old games using 22,050 sample rate for sounds, such as Thief 1&2 and is basically essential for Quake 2 so that the earthquake sound doesn't get distorted.

The .ini file is well documented and it's worth to look at IMO.


  • Anderson likes this

#25 lowenz

lowenz

    Advanced Member

  • Member
  • PipPipPip
  • 1876 posts

Posted 22 January 2016 - 06:26 AM

Only one note :D

 

If I use the config tool included in the package it creates the alsoft.ini in appdata\roaming folder.

 

So I assume that is the correct dir, not appdata root.


Edited by lowenz, 22 January 2016 - 06:27 AM.

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.






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