From 53fadf54977a3312db66e7e086c9b01d9162ae29 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 15 Mar 2016 05:08:05 -0700 Subject: Add a dual-band ambisonic decoder This uses a virtual B-Format buffer for mixing, and then uses a dual-band decoder for improved positional quality. This currently only works with first- order output since first-order input (from the AL_EXT_BFROMAT extension) would not sound correct when fed through a second- or third-order decoder. This also does not currently implement near-field compensation since near-field rendering effects are not implemented. --- Alc/ALc.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'Alc/ALc.c') diff --git a/Alc/ALc.c b/Alc/ALc.c index 8ede026a..f51757e8 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -37,6 +37,8 @@ #include "alError.h" #include "bs2b.h" #include "uhjfilter.h" +#include "bformatdec.h" +#include "ambdec.h" #include "alu.h" #include "compat.h" @@ -2116,12 +2118,12 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) } } - aluInitPanning(device); + aluInitPanning(device, NULL); - /* With HRTF, allocate two extra channels for the post-filter output. */ + /* Allocate extra channels for any post-filter output. */ size = device->Dry.NumChannels * sizeof(device->Dry.Buffer[0]); - if(device->Hrtf || device->Uhj_Encoder) - size += 2 * sizeof(device->Dry.Buffer[0]); + if(device->Hrtf || device->Uhj_Encoder || device->AmbiDecoder) + size += ChannelsFromDevFmt(device->FmtChans) * sizeof(device->Dry.Buffer[0]); device->Dry.Buffer = al_calloc(16, size); if(!device->Dry.Buffer) { @@ -2129,12 +2131,12 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) return ALC_INVALID_DEVICE; } - if(device->Hrtf || device->Uhj_Encoder) + if(device->Hrtf || device->Uhj_Encoder || device->AmbiDecoder) { device->VirtOut.Buffer = device->Dry.Buffer; device->VirtOut.NumChannels = device->Dry.NumChannels; device->RealOut.Buffer = device->Dry.Buffer + device->Dry.NumChannels; - device->RealOut.NumChannels = 2; + device->RealOut.NumChannels = ChannelsFromDevFmt(device->FmtChans); } else { @@ -2277,6 +2279,9 @@ static ALCvoid FreeDevice(ALCdevice *device) al_free(device->Uhj_Encoder); device->Uhj_Encoder = NULL; + bformatdec_free(device->AmbiDecoder); + device->AmbiDecoder = NULL; + AL_STRING_DEINIT(device->DeviceName); al_free(device->Dry.Buffer); -- cgit v1.2.3