From e288c3b44a1417a9c54f4f219f028430959ef198 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 31 Mar 2018 20:44:14 -0700 Subject: Fix HRTF HOA coefficients ACN8 was accidentally put on ACN7. However, rather than adding the missing channel of silence, set up the coefficient map to only use the ambisonic channels that can contribute to output. --- Alc/panning.c | 58 +++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 21 deletions(-) (limited to 'Alc') diff --git a/Alc/panning.c b/Alc/panning.c index b49eb2e7..cb4406a8 100644 --- a/Alc/panning.c +++ b/Alc/panning.c @@ -852,30 +852,31 @@ static void InitHrtfPanning(ALCdevice *device) { 5.55555556e-02f, 5.00000000e-02f, -7.14285715e-02f, 5.00000000e-02f }, { 5.55555556e-02f, 0.00000000e+00f, -1.23717915e-01f, 0.00000000e+00f }, }, AmbiMatrixHOA[][MAX_AMBI_COEFFS] = { - { 5.55555556e-02f, 0.00000000e+00f, 1.23717915e-01f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, - { 5.55555556e-02f, -5.00000000e-02f, 7.14285715e-02f, 5.00000000e-02f, -4.55645099e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, - { 5.55555556e-02f, -5.00000000e-02f, 7.14285715e-02f, -5.00000000e-02f, 4.55645099e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, - { 5.55555556e-02f, 5.00000000e-02f, 7.14285715e-02f, -5.00000000e-02f, -4.55645099e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, - { 5.55555556e-02f, 5.00000000e-02f, 7.14285715e-02f, 5.00000000e-02f, 4.55645099e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, - { 5.55555556e-02f, 0.00000000e+00f, 0.00000000e+00f, 8.66025404e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 1.29099445e-01f }, - { 5.55555556e-02f, -6.12372435e-02f, 0.00000000e+00f, 6.12372435e-02f, -6.83467648e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, - { 5.55555556e-02f, -8.66025404e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, -1.29099445e-01f }, - { 5.55555556e-02f, -6.12372435e-02f, 0.00000000e+00f, -6.12372435e-02f, 6.83467648e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, - { 5.55555556e-02f, 0.00000000e+00f, 0.00000000e+00f, -8.66025404e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 1.29099445e-01f }, - { 5.55555556e-02f, 6.12372435e-02f, 0.00000000e+00f, -6.12372435e-02f, -6.83467648e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, - { 5.55555556e-02f, 8.66025404e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, -1.29099445e-01f }, - { 5.55555556e-02f, 6.12372435e-02f, 0.00000000e+00f, 6.12372435e-02f, 6.83467648e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, - { 5.55555556e-02f, -5.00000000e-02f, -7.14285715e-02f, 5.00000000e-02f, -4.55645099e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, - { 5.55555556e-02f, -5.00000000e-02f, -7.14285715e-02f, -5.00000000e-02f, 4.55645099e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, - { 5.55555556e-02f, 5.00000000e-02f, -7.14285715e-02f, -5.00000000e-02f, -4.55645099e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, - { 5.55555556e-02f, 5.00000000e-02f, -7.14285715e-02f, 5.00000000e-02f, 4.55645099e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, - { 5.55555556e-02f, 0.00000000e+00f, -1.23717915e-01f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, + { 5.55555556e-02f, 0.00000000e+00f, 1.23717915e-01f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, + { 5.55555556e-02f, -5.00000000e-02f, 7.14285715e-02f, 5.00000000e-02f, -4.55645099e-02f, 0.00000000e+00f }, + { 5.55555556e-02f, -5.00000000e-02f, 7.14285715e-02f, -5.00000000e-02f, 4.55645099e-02f, 0.00000000e+00f }, + { 5.55555556e-02f, 5.00000000e-02f, 7.14285715e-02f, -5.00000000e-02f, -4.55645099e-02f, 0.00000000e+00f }, + { 5.55555556e-02f, 5.00000000e-02f, 7.14285715e-02f, 5.00000000e-02f, 4.55645099e-02f, 0.00000000e+00f }, + { 5.55555556e-02f, 0.00000000e+00f, 0.00000000e+00f, 8.66025404e-02f, 0.00000000e+00f, 1.29099445e-01f }, + { 5.55555556e-02f, -6.12372435e-02f, 0.00000000e+00f, 6.12372435e-02f, -6.83467648e-02f, 0.00000000e+00f }, + { 5.55555556e-02f, -8.66025404e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, -1.29099445e-01f }, + { 5.55555556e-02f, -6.12372435e-02f, 0.00000000e+00f, -6.12372435e-02f, 6.83467648e-02f, 0.00000000e+00f }, + { 5.55555556e-02f, 0.00000000e+00f, 0.00000000e+00f, -8.66025404e-02f, 0.00000000e+00f, 1.29099445e-01f }, + { 5.55555556e-02f, 6.12372435e-02f, 0.00000000e+00f, -6.12372435e-02f, -6.83467648e-02f, 0.00000000e+00f }, + { 5.55555556e-02f, 8.66025404e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, -1.29099445e-01f }, + { 5.55555556e-02f, 6.12372435e-02f, 0.00000000e+00f, 6.12372435e-02f, 6.83467648e-02f, 0.00000000e+00f }, + { 5.55555556e-02f, -5.00000000e-02f, -7.14285715e-02f, 5.00000000e-02f, -4.55645099e-02f, 0.00000000e+00f }, + { 5.55555556e-02f, -5.00000000e-02f, -7.14285715e-02f, -5.00000000e-02f, 4.55645099e-02f, 0.00000000e+00f }, + { 5.55555556e-02f, 5.00000000e-02f, -7.14285715e-02f, -5.00000000e-02f, -4.55645099e-02f, 0.00000000e+00f }, + { 5.55555556e-02f, 5.00000000e-02f, -7.14285715e-02f, 5.00000000e-02f, 4.55645099e-02f, 0.00000000e+00f }, + { 5.55555556e-02f, 0.00000000e+00f, -1.23717915e-01f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, }; static const ALfloat AmbiOrderHFGainFOA[MAX_AMBI_ORDER+1] = { 1.00000000e+00f, 5.77350269e-01f }, AmbiOrderHFGainHOA[MAX_AMBI_ORDER+1] = { 9.80580676e-01f, 7.59554525e-01f, 3.92232270e-01f }; + static const ALsizei IndexMap[6] = { 0, 1, 2, 3, 4, 8 }; const ALfloat (*restrict AmbiMatrix)[MAX_AMBI_COEFFS] = AmbiMatrixFOA; const ALfloat *restrict AmbiOrderHFGain = AmbiOrderHFGainFOA; ALsizei count = 4; @@ -889,7 +890,7 @@ static void InitHrtfPanning(ALCdevice *device) { AmbiMatrix = AmbiMatrixHOA; AmbiOrderHFGain = AmbiOrderHFGainHOA; - count = 9; + count = COUNTOF(IndexMap); } device->Hrtf = al_calloc(16, FAM_SIZE(DirectHrtfState, Chan, count)); @@ -897,7 +898,7 @@ static void InitHrtfPanning(ALCdevice *device) for(i = 0;i < count;i++) { device->Dry.Ambi.Map[i].Scale = 1.0f; - device->Dry.Ambi.Map[i].Index = i; + device->Dry.Ambi.Map[i].Index = IndexMap[i]; } device->Dry.CoeffCount = 0; device->Dry.NumChannels = count; @@ -930,7 +931,22 @@ static void InitHrtfPanning(ALCdevice *device) AmbiOrderHFGain ); - InitNearFieldCtrl(device, device->HrtfHandle->distance, device->AmbiUp ? 2 : 1, true); + if(GetConfigValueBool(alstr_get_cstr(device->DeviceName), "decoder", "nfc", 1) && + device->HrtfHandle->distance > 0.0f) + { + /* NFC is only used when AvgSpeakerDist is greater than 0, and can only + * be used when rendering to an ambisonic buffer. + */ + device->AvgSpeakerDist = device->HrtfHandle->distance; + + i = 0; + device->Dry.NumChannelsPerOrder[i++] = 1; + device->Dry.NumChannelsPerOrder[i++] = 3; + if(device->AmbiUp) + device->Dry.NumChannelsPerOrder[i++] = 2; + while(i < MAX_AMBI_ORDER+1) + device->Dry.NumChannelsPerOrder[i++] = 0; + } } static void InitUhjPanning(ALCdevice *device) -- cgit v1.2.3