Skip to content
Hangman edited this page Sep 6, 2022 · 5 revisions

In terms of being able to tell where exactly a sound is coming from, HRTF is the real shit.

If you are a developer confronted with 3D sound for the first time, you probably think that a sound that is supposed to come from the front left will simply play a bit louder on the left ear than on the right. As a result, however, this does not lead to the human brain actually locating the sound at that point.

The physics is a bit more complicated. Since sound has a speed, the sound waves arrive earlier on the left ear than on the right. Likewise, different frequencies have different curvature behavior around the head and move through the air with different loss. This results in different attenuation of frequencies depending on the position and distance of the sound source.

HRTF tries to calculate all this correctly and leads to a huge increase in the user's ability to locate the sound source correctly.
Seriously, it's a huge difference, not just a nice gimmick. Try it out (and make sure to wear headphones): HRTF Test

Querying Available HRTF Profiles

In order to enable HRTF in TuningFork you must first query if any HRTF profile is available on the AudioDevice.

AudioDevice device = audio.getDevice();
Array<String> hrtfs = device.getAvailableHrtfs();

For my headset the profile names look like this:

Built-In 44100hz
Built-In 48000hz

Enabling HRTF

Once you got your list of available HRTFs, you can enable it. hrtfProfile must be a valid String from the hrtfs list.

boolean hrtfEnabled = device.enableHrtf(hrtfProfile);

It is not guaranteed that the desired profile will be used. OpenAL may select a different profile if it is more suitable for the device configuration.

Disabling HRTF Again

device.disableHrtf();