[openal] HRTF queries
Chris Robinson
chris.kcat at gmail.com
Fri Jun 20 23:24:09 EDT 2014
On 06/20/2014 04:44 PM, Ethan Lee wrote:
> You might be able to design it similarly to the OpenGL shader API, but
> without the need for programs/linking on top of shaders. For instance,
> alcCreateHRTFs(ALint, ALint*), alcBindHRTF(ALint),
> alcAttachHRTFSource(ALchar*), alcParseHRTF(), etc.
The problem with this is that there's no standard HRTF data format for
an app to provide. OpenAL Soft has its own format(s) for its HRTF files,
but they're implementation-specific. Having something like this for
pre-supplied profiles that only handles string names seems like overkill.
Perhaps instead enumeration could provide a set of integer IDs, done
through alcGetIntegerv. For example...
ALCint num_profiles;
alcGetIntegerv(device, ALC_NUM_HRTF_PROFILES_SOFT, 1, &num_profiles);
// Each profile gives 3 ints: ID, channel config, and sample rate
ALCint profiles[num_profiles * 3];
alcGetIntegerv(device, ALC_HRTF_PROFILES_SOFT, num_profiles * 3,
profiles);
for(int i = 0;i < num_profiles;i++)
{
profiles[i*3 ]; // ID for this HRTF profile
profiles[i*3 + 1]; // Channel config, e.g. ALC_STEREO_SOFT
profiles[i*3 + 2]; // Sample rate
}
Then to set one, you create a context with an ID in the attribute list
(for example, if using profile 'p'):
ALCint attr[] = { ALC_HRTF_SOFT, profiles[p*3], 0 };
context = alcCreateContext(device, attr);
You can then check to see which is being used:
ALCint id;
alcGetIntegerv(device, ALC_HRTF_SOFT, 1, &id);
An ID of 0 would mean no HRTF.
Of course, then the issue becomes, how to get a string to display to the
user from an ID. alcGetString is unsuited for doing that. Perhaps a new
alcGetStringFromID function, which would work for other ID types as well
(if a future extension were to add more device-level IDs).
More information about the openal
mailing list