HRTFs - MoritzBrueckner/aura GitHub Wiki
To achieve a more realistic 3D sound compared to convential stereo panning, Aura supports HRTFs (head-related transfer functions). HRTFs consist of impulse responses (HRIRs; head-related impulse responses) that are measured (or simulated) for many directions around a head. By using a technique called convolution, it is possible to transfer the characteristic of the impulse response of a certain direction to an arbitrary input sound, thus letting it sound as coming from that direction. Note that HRTFs are computationally intensive, so they may not be suited for each target platform. Even on faster targets it is usually sufficient to use them only for the more important sounds in a scene.
HRTFs come in various file formats, Aura currently only supports the .mhr format (versions 1–3) from OpenAL Soft. Currently, only mono .mhr files can be used, they encode left-ear HRIRs that are mirrored and rotated to the right ear at runtime.
Note that Aura does not include any default .mhr files, so you must provide your own. There are many public datasets for HRTFs under various licenses. A good overview on some datasets (with audio examples) can be found here: https://airtable.com/shrY7Nz3BEujQVGmC/tbloLjoZKWJDnLtTc. For conversion to .mhr, OpenAL Soft's makemhr.exe can be used (included in the OpenAL Soft binary distribution). A collection of useful conversion tools can be found in https://github.com/ThreeDeeJay/HRIR-Batch-Converters.
Loading and Using an HRTF
var loadConfig: AuraLoadConfig = {
hrtf: [
kha.Assets.blobs.MyHRTF_mhrName // For a file called MyHRTF.mhr
]
};
Aura.loadAssets(loadConfig, () -> {
// Accessing the loaded HRTF
final myHRTF: Null<aura.types.HRTF> = Aura.getHRTF(kha.Assets.blobs.MyHRTF_mhrName);
// Assume that we already loaded a sound called `mySound` (not shown in this example)
final handle = Aura.createHandle(Play, mySound, true);
new HRTFPanner(handle, myHRTF);
handle.play();
});