aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2015-02-11 09:32:05 -0800
committerChris Robinson <[email protected]>2015-02-11 09:32:05 -0800
commit71b6e9bfe0f3f188ff48a1acdb29311ee3ed8ed7 (patch)
treec38614d26c675fed3520537d06fbf8493288462e /Alc
parenta6e574ba9e1a7dade95b9d4ddf864df5c0724b21 (diff)
Add an option for "basic" HRTF rendering
This method is intended to help development by easily testing the quality of the B-Format encode and B-Format-to-HRTF decode. When used with HRTF, all sources are renderer using the virtual B-Format output, rather than just B-Format sources. Despite the CPU cost savings (only four channels need to be filtered with HRTF, while sources all render normally), the spatial acuity offered by the B-Format output is pretty poor since it's only first-order ambisonics, so "full" HRTF rendering is definitely preferred. It's /possible/ for some systems to be edge cases that prefer the CPU cost savings provided by basic over the sharper localization provided by full, and you do still get 3D positional cues, but this is unlikely to be an actual use- case in practice.
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c33
-rw-r--r--Alc/ALu.c4
2 files changed, 28 insertions, 9 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index baf7f01b..6fc1d83e 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -1976,6 +1976,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
}
device->Hrtf = NULL;
+ device->Hrtf_Mode = DisabledHrtf;
if(device->FmtChans != DevFmtStereo)
{
free(device->Bs2b);
@@ -1984,20 +1985,35 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
else
{
bool headphones = device->IsHeadphones;
+ enum HrtfMode hrtf_mode = FullHrtf;
const char *mode;
int bs2blevel;
int usehrtf;
- if(device->Type != Loopback && ConfigValueStr(NULL, "stereo-mode", &mode))
+ if(device->Type != Loopback)
{
- if(strcasecmp(mode, "headphones") == 0)
- headphones = true;
- else if(strcasecmp(mode, "speakers") == 0)
- headphones = false;
- else if(strcasecmp(mode, "auto") != 0)
- ERR("Unexpected stereo-mode: %s\n", mode);
+ if(ConfigValueStr(NULL, "stereo-mode", &mode))
+ {
+ if(strcasecmp(mode, "headphones") == 0)
+ headphones = true;
+ else if(strcasecmp(mode, "speakers") == 0)
+ headphones = false;
+ else if(strcasecmp(mode, "auto") != 0)
+ ERR("Unexpected stereo-mode: %s\n", mode);
+ }
+
+ if(ConfigValueStr(NULL, "hrtf-mode", &mode))
+ {
+ if(strcasecmp(mode, "full") == 0)
+ hrtf_mode = FullHrtf;
+ else if(strcasecmp(mode, "basic") == 0)
+ hrtf_mode = BasicHrtf;
+ else
+ ERR("Unexpected hrtf-mode: %s\n", mode);
+ }
}
+
if(device->Type == Loopback || !ConfigValueBool(NULL, "hrtf", &usehrtf))
usehrtf = ((device->Flags&DEVICE_HRTF_REQUEST) || headphones);
@@ -2005,6 +2021,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
device->Hrtf = GetHrtf(device->FmtChans, device->Frequency);
if(device->Hrtf)
{
+ device->Hrtf_Mode = hrtf_mode;
TRACE("HRTF enabled\n");
free(device->Bs2b);
device->Bs2b = NULL;
@@ -3273,6 +3290,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
device->Flags = 0;
device->Bs2b = NULL;
+ device->Hrtf_Mode = DisabledHrtf;
AL_STRING_INIT(device->DeviceName);
device->DryBuffer = NULL;
@@ -3725,6 +3743,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN
device->Flags = 0;
device->Bs2b = NULL;
+ device->Hrtf_Mode = DisabledHrtf;
AL_STRING_INIT(device->DeviceName);
device->DryBuffer = NULL;
diff --git a/Alc/ALu.c b/Alc/ALu.c
index f789b13c..64cf5349 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -563,7 +563,7 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A
voice->IsHrtf = AL_FALSE;
}
- else if(Device->Hrtf)
+ else if(Device->Hrtf_Mode == FullHrtf)
{
voice->Direct.OutBuffer += voice->Direct.OutChannels;
voice->Direct.OutChannels = 2;
@@ -999,7 +999,7 @@ ALvoid CalcSourceParams(ALvoice *voice, const ALsource *ALSource, const ALCconte
BufferListItem = BufferListItem->next;
}
- if(Device->Hrtf)
+ if(Device->Hrtf_Mode == FullHrtf)
{
/* Use a binaural HRTF algorithm for stereo headphone playback */
aluVector dir = {{ 0.0f, 0.0f, -1.0f, 0.0f }};