From c9c965ef8542f59cb810faef40bfd2f5e447daee Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 1 May 2011 13:19:23 -0700 Subject: [PATCH] Add a device flag for enabling HRTF --- Alc/ALc.c | 12 ++++++++---- OpenAL32/Include/alMain.h | 3 +++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Alc/ALc.c b/Alc/ALc.c index 0bf73b1..de722d7 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -1186,7 +1186,11 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) ProcessContext(context); } - if(device->Bs2bLevel > 0 && device->Bs2bLevel <= 6) + device->UseHRTF = AL_FALSE; + if(ChannelsFromDevFmt(device->FmtChans) == 2 && device->Frequency == 44100) + device->UseHRTF = GetConfigValueBool(NULL, "hrtf", AL_FALSE); + + if(!device->UseHRTF && device->Bs2bLevel > 0 && device->Bs2bLevel <= 6) { if(!device->Bs2b) { @@ -1202,14 +1206,13 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) device->Bs2b = NULL; } - if(ChannelsFromDevFmt(device->FmtChans) <= 2) + device->HeadDampen = 0.0f; + if(!device->UseHRTF && ChannelsFromDevFmt(device->FmtChans) <= 2) { device->HeadDampen = GetConfigValueFloat(NULL, "head_dampen", DEFAULT_HEAD_DAMPEN); device->HeadDampen = __min(device->HeadDampen, 1.0f); device->HeadDampen = __max(device->HeadDampen, 0.0f); } - else - device->HeadDampen = 0.0f; return ALC_TRUE; } @@ -2279,6 +2282,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) device->IsLoopbackDevice = AL_FALSE; device->LastError = ALC_NO_ERROR; + device->UseHRTF = AL_FALSE; device->Bs2b = NULL; device->szDeviceName = NULL; diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index c6a1c4b..24027c9 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -478,6 +478,9 @@ struct ALCdevice_struct // Duplicate stereo sources on the side/rear channels ALboolean DuplicateStereo; + // Use HRTF filters for mixing sounds + ALboolean UseHRTF; + // Dry path buffer mix ALfloat DryBuffer[BUFFERSIZE][MAXCHANNELS];