aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALc.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-03-15 05:08:05 -0700
committerChris Robinson <[email protected]>2016-03-15 05:08:05 -0700
commit53fadf54977a3312db66e7e086c9b01d9162ae29 (patch)
tree1a6696bd14200484ae4dfa955f32830deb3b2a46 /Alc/ALc.c
parent64cb21cb9ff08d222d00eedc38fbc0970543bac3 (diff)
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.
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r--Alc/ALc.c17
1 files changed, 11 insertions, 6 deletions
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);