[openal] Final testing for OpenAL Soft 1.17

Chris Robinson chris.kcat at gmail.com
Tue Nov 3 20:43:02 EST 2015

On 11/03/2015 08:21 AM, Michael Taboada wrote:
> Hi,
> I haven't looked at the latest HRTF extension, but does it include the
> ability to switch HRTF definitions while the program is running, or even
> choose which to use at all? This could be useful for apps that have some
> HRTF definitions for different types of people/heads, etc.
> Thanks,
> -Michael.

It does. The new alcResetDeviceSOFT function allows you to reset the 
device using a new attribute list, without any lasting interruption to 
any existing contexts (obviously there may be a short break in playback 
to reconfigure the output, but it starts right back up again ASAP).

Individual HRTF definitions can be selected by first enumerating them:

ALCint num_hrtfs;
alcGetIntegerv(device, ALC_NUM_HRTF_SPECIFIERS_SOFT, 1, &num_hrtfs);

Note that the device needs to be a valid, open device, not NULL, because 
individual devices may support different HRTFs. Then you can get 
human-readable strings (UTF-8 encoded) for each of the HRTFs using the 
new alcGetStringiSOFT function:

alcGetStringi(device, ALC_HRTF_SPECIFIER_SOFT, i);

where 0 <= i < num_hrtfs. Then an HRTF can be selected by passing it by ID:

ALCint attr[] = {
     ALC_HRTF_SOFT, ALC_TRUE,  /* Enable HRTF */
     ALC_HRTF_ID_SOFT, i, /* Select HRTF at index 'i' */
     0 /* end of list */

These attributes can then be passed to alcCreateContext or 
alcResetDeviceSOFT (in both cases the device's output is being 
(re)configured, the former just giving you a new context as well). 
Afterward, you can test if HRTF is in use by calling:

ALCint hrtf_enabled;
alcGetIntegerv(device, ALC_HRTF_SOFT, 1, &hrtf_enabled);

and you can get the name of the HRTF in use:

alcGetString(device, ALC_HRTF_SPECIFIER_SOFT);

There's an alhrtf example that shows it all in action.

Currently, OpenAL Soft names the HRTFs given it's filename, e.g. 
"default-44100.mhr" or "default-48000.mhr". Eventually, the lib and 
makehrtf utility will be able to use actual titles for them, something 
along the lines of "MIT KEMAR, 44.1khz" or "MIT KEMAR, 48khz".

More information about the openal mailing list