aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-02-13 03:03:26 -0800
committerChris Robinson <[email protected]>2018-02-13 03:03:26 -0800
commit59768674f1764706a2e59c4c314f80eca3b5de9d (patch)
treebdff2f2d959bfe6e1de6f6b625748997e7f8d42d /Alc
parent2cb49e51a0d270f2a650d0969a5370ac50125c3f (diff)
Use an alternate ambisonic HRTF decode layout
Similar to the previous, but includes the top and bottom HRTF responses. The higher-order decode (for the "basic" HRTF output) also now uses 2H1P mixed- order instead of 2H1V, which seems more stable.
Diffstat (limited to 'Alc')
-rw-r--r--Alc/bformatdec.c7
-rw-r--r--Alc/bformatdec.h4
-rw-r--r--Alc/hrtf.h2
-rw-r--r--Alc/panning.c115
4 files changed, 71 insertions, 57 deletions
diff --git a/Alc/bformatdec.c b/Alc/bformatdec.c
index bfd40b14..03ea865c 100644
--- a/Alc/bformatdec.c
+++ b/Alc/bformatdec.c
@@ -518,7 +518,7 @@ void ambiup_free(struct AmbiUpsampler **ambiup)
}
}
-void ambiup_reset(struct AmbiUpsampler *ambiup, const ALCdevice *device)
+void ambiup_reset(struct AmbiUpsampler *ambiup, const ALCdevice *device, ALfloat w_scale, ALfloat xyz_scale)
{
ALfloat ratio;
ALsizei i;
@@ -560,11 +560,6 @@ void ambiup_reset(struct AmbiUpsampler *ambiup, const ALCdevice *device)
}
else
{
- /* Assumes full 3D/periphonic on the input and output mixes! */
- ALfloat w_scale = (device->Dry.NumChannels > 9) ? W_SCALE_3H3P :
- (device->Dry.NumChannels > 4) ? W_SCALE_2H2P : 1.0f;
- ALfloat xyz_scale = (device->Dry.NumChannels > 9) ? XYZ_SCALE_3H3P :
- (device->Dry.NumChannels > 4) ? XYZ_SCALE_2H2P : 1.0f;
for(i = 0;i < 4;i++)
{
ALsizei index = GetChannelForACN(device->Dry, i);
diff --git a/Alc/bformatdec.h b/Alc/bformatdec.h
index c997c0b9..0011eb28 100644
--- a/Alc/bformatdec.h
+++ b/Alc/bformatdec.h
@@ -38,11 +38,11 @@ void bformatdec_upSample(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[B
/* Stand-alone first-order upsampler. Kept here because it shares some stuff
- * with bformatdec.
+ * with bformatdec. Assumes a periphonic (4-channel) input mix!
*/
struct AmbiUpsampler *ambiup_alloc();
void ambiup_free(struct AmbiUpsampler **ambiup);
-void ambiup_reset(struct AmbiUpsampler *ambiup, const ALCdevice *device);
+void ambiup_reset(struct AmbiUpsampler *ambiup, const ALCdevice *device, ALfloat w_scale, ALfloat xyz_scale);
void ambiup_process(struct AmbiUpsampler *ambiup, ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei OutChannels, const ALfloat (*restrict InSamples)[BUFFERSIZE], ALsizei SamplesToDo);
diff --git a/Alc/hrtf.h b/Alc/hrtf.h
index b041c911..60842e8d 100644
--- a/Alc/hrtf.h
+++ b/Alc/hrtf.h
@@ -12,7 +12,7 @@
/* The maximum number of virtual speakers used to generate HRTF coefficients
* for decoding B-Format.
*/
-#define HRTF_AMBI_MAX_CHANNELS 16
+#define HRTF_AMBI_MAX_CHANNELS 18
#define HRTF_HISTORY_BITS (6)
diff --git a/Alc/panning.c b/Alc/panning.c
index b90652a3..6baff75f 100644
--- a/Alc/panning.c
+++ b/Alc/panning.c
@@ -649,6 +649,8 @@ static void InitPanning(ALCdevice *device)
}
else
{
+ ALfloat w_scale=1.0f, xyz_scale=1.0f;
+
/* FOA output is always ACN+N3D for higher-order ambisonic output.
* The upsampler expects this and will convert it for output.
*/
@@ -661,7 +663,17 @@ static void InitPanning(ALCdevice *device)
device->FOAOut.CoeffCount = 0;
device->FOAOut.NumChannels = 4;
- ambiup_reset(device->AmbiUp, device);
+ if(device->AmbiOrder >= 3)
+ {
+ w_scale = W_SCALE_3H3P;
+ xyz_scale = XYZ_SCALE_3H3P;
+ }
+ else
+ {
+ w_scale = W_SCALE_2H2P;
+ xyz_scale = XYZ_SCALE_2H2P;
+ }
+ ambiup_reset(device->AmbiUp, device, w_scale, xyz_scale);
}
if(ConfigValueFloat(devname, "decoder", "nfc-ref-delay", &nfc_delay) && nfc_delay > 0.0f)
@@ -870,62 +882,68 @@ static void InitHrtfPanning(ALCdevice *device)
{
/* NOTE: azimuth goes clockwise. */
static const ALfloat AmbiPoints[][2] = {
- { DEG2RAD( 35.0f), DEG2RAD( -45.0f) },
- { DEG2RAD( 35.0f), DEG2RAD(-135.0f) },
- { DEG2RAD( 35.0f), DEG2RAD( 135.0f) },
+ { DEG2RAD( 90.0f), DEG2RAD( 0.0f) },
{ DEG2RAD( 35.0f), DEG2RAD( 45.0f) },
+ { DEG2RAD( 35.0f), DEG2RAD( 135.0f) },
+ { DEG2RAD( 35.0f), DEG2RAD(-135.0f) },
+ { DEG2RAD( 35.0f), DEG2RAD( -45.0f) },
{ DEG2RAD( 0.0f), DEG2RAD( 0.0f) },
- { DEG2RAD( 0.0f), DEG2RAD( -45.0f) },
- { DEG2RAD( 0.0f), DEG2RAD( -90.0f) },
- { DEG2RAD( 0.0f), DEG2RAD(-135.0f) },
- { DEG2RAD( 0.0f), DEG2RAD( 180.0f) },
- { DEG2RAD( 0.0f), DEG2RAD( 135.0f) },
- { DEG2RAD( 0.0f), DEG2RAD( 90.0f) },
{ DEG2RAD( 0.0f), DEG2RAD( 45.0f) },
- { DEG2RAD(-35.0f), DEG2RAD( -45.0f) },
- { DEG2RAD(-35.0f), DEG2RAD(-135.0f) },
- { DEG2RAD(-35.0f), DEG2RAD( 135.0f) },
+ { DEG2RAD( 0.0f), DEG2RAD( 90.0f) },
+ { DEG2RAD( 0.0f), DEG2RAD( 135.0f) },
+ { DEG2RAD( 0.0f), DEG2RAD( 180.0f) },
+ { DEG2RAD( 0.0f), DEG2RAD(-135.0f) },
+ { DEG2RAD( 0.0f), DEG2RAD( -90.0f) },
+ { DEG2RAD( 0.0f), DEG2RAD( -45.0f) },
{ DEG2RAD(-35.0f), DEG2RAD( 45.0f) },
+ { DEG2RAD(-35.0f), DEG2RAD( 135.0f) },
+ { DEG2RAD(-35.0f), DEG2RAD(-135.0f) },
+ { DEG2RAD(-35.0f), DEG2RAD( -45.0f) },
+ { DEG2RAD(-90.0f), DEG2RAD( 0.0f) },
};
static const ALfloat AmbiMatrixFOA[][MAX_AMBI_COEFFS] = {
- { 6.25000000e-002f, 5.00000000e-002f, 1.25000000e-001f, 5.00000000e-002f },
- { 6.25000000e-002f, 5.00000000e-002f, 1.25000000e-001f, -5.00000000e-002f },
- { 6.25000000e-002f, -5.00000000e-002f, 1.25000000e-001f, -5.00000000e-002f },
- { 6.25000000e-002f, -5.00000000e-002f, 1.25000000e-001f, 5.00000000e-002f },
- { 6.25000000e-002f, 0.00000000e+000f, 0.00000000e+000f, 8.66025404e-002f },
- { 6.25000000e-002f, 6.12372435e-002f, 0.00000000e+000f, 6.12372435e-002f },
- { 6.25000000e-002f, 8.66025404e-002f, 0.00000000e+000f, 0.00000000e+000f },
- { 6.25000000e-002f, 6.12372435e-002f, 0.00000000e+000f, -6.12372435e-002f },
- { 6.25000000e-002f, 0.00000000e+000f, 0.00000000e+000f, -8.66025404e-002f },
- { 6.25000000e-002f, -6.12372435e-002f, 0.00000000e+000f, -6.12372435e-002f },
- { 6.25000000e-002f, -8.66025404e-002f, 0.00000000e+000f, 0.00000000e+000f },
- { 6.25000000e-002f, -6.12372435e-002f, 0.00000000e+000f, 6.12372435e-002f },
- { 6.25000000e-002f, 5.00000000e-002f, -1.25000000e-001f, 5.00000000e-002f },
- { 6.25000000e-002f, 5.00000000e-002f, -1.25000000e-001f, -5.00000000e-002f },
- { 6.25000000e-002f, -5.00000000e-002f, -1.25000000e-001f, -5.00000000e-002f },
- { 6.25000000e-002f, -5.00000000e-002f, -1.25000000e-001f, 5.00000000e-002f },
+ { 5.55555556e-02f, 0.00000000e+00f, 1.23717915e-01f, 0.00000000e+00f },
+ { 5.55555556e-02f, -5.00000000e-02f, 7.14285715e-02f, 5.00000000e-02f },
+ { 5.55555556e-02f, -5.00000000e-02f, 7.14285715e-02f, -5.00000000e-02f },
+ { 5.55555556e-02f, 5.00000000e-02f, 7.14285715e-02f, -5.00000000e-02f },
+ { 5.55555556e-02f, 5.00000000e-02f, 7.14285715e-02f, 5.00000000e-02f },
+ { 5.55555556e-02f, 0.00000000e+00f, 0.00000000e+00f, 8.66025404e-02f },
+ { 5.55555556e-02f, -6.12372435e-02f, 0.00000000e+00f, 6.12372435e-02f },
+ { 5.55555556e-02f, -8.66025404e-02f, 0.00000000e+00f, 0.00000000e+00f },
+ { 5.55555556e-02f, -6.12372435e-02f, 0.00000000e+00f, -6.12372435e-02f },
+ { 5.55555556e-02f, 0.00000000e+00f, 0.00000000e+00f, -8.66025404e-02f },
+ { 5.55555556e-02f, 6.12372435e-02f, 0.00000000e+00f, -6.12372435e-02f },
+ { 5.55555556e-02f, 8.66025404e-02f, 0.00000000e+00f, 0.00000000e+00f },
+ { 5.55555556e-02f, 6.12372435e-02f, 0.00000000e+00f, 6.12372435e-02f },
+ { 5.55555556e-02f, -5.00000000e-02f, -7.14285715e-02f, 5.00000000e-02f },
+ { 5.55555556e-02f, -5.00000000e-02f, -7.14285715e-02f, -5.00000000e-02f },
+ { 5.55555556e-02f, 5.00000000e-02f, -7.14285715e-02f, -5.00000000e-02f },
+ { 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] = {
- { 6.25000000e-002f, 5.00000000e-002f, 1.25000000e-001f, 5.00000000e-002f, 4.55645099e-002f, 9.68245837e-002f, 0.00000000e+000f, 9.68245837e-002f, 0.00000000e+000f },
- { 6.25000000e-002f, 5.00000000e-002f, 1.25000000e-001f, -5.00000000e-002f, -4.55645099e-002f, 9.68245837e-002f, 0.00000000e+000f, -9.68245837e-002f, 0.00000000e+000f },
- { 6.25000000e-002f, -5.00000000e-002f, 1.25000000e-001f, -5.00000000e-002f, 4.55645099e-002f, -9.68245837e-002f, 0.00000000e+000f, -9.68245837e-002f, 0.00000000e+000f },
- { 6.25000000e-002f, -5.00000000e-002f, 1.25000000e-001f, 5.00000000e-002f, -4.55645099e-002f, -9.68245837e-002f, 0.00000000e+000f, 9.68245837e-002f, 0.00000000e+000f },
- { 6.25000000e-002f, 0.00000000e+000f, 0.00000000e+000f, 8.66025404e-002f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 1.29099445e-001f },
- { 6.25000000e-002f, 6.12372435e-002f, 0.00000000e+000f, 6.12372435e-002f, 6.83467648e-002f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f },
- { 6.25000000e-002f, 8.66025404e-002f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, -1.29099445e-001f },
- { 6.25000000e-002f, 6.12372435e-002f, 0.00000000e+000f, -6.12372435e-002f, -6.83467648e-002f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f },
- { 6.25000000e-002f, 0.00000000e+000f, 0.00000000e+000f, -8.66025404e-002f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 1.29099445e-001f },
- { 6.25000000e-002f, -6.12372435e-002f, 0.00000000e+000f, -6.12372435e-002f, 6.83467648e-002f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f },
- { 6.25000000e-002f, -8.66025404e-002f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, -1.29099445e-001f },
- { 6.25000000e-002f, -6.12372435e-002f, 0.00000000e+000f, 6.12372435e-002f, -6.83467648e-002f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f },
- { 6.25000000e-002f, 5.00000000e-002f, -1.25000000e-001f, 5.00000000e-002f, 4.55645099e-002f, -9.68245837e-002f, 0.00000000e+000f, -9.68245837e-002f, 0.00000000e+000f },
- { 6.25000000e-002f, 5.00000000e-002f, -1.25000000e-001f, -5.00000000e-002f, -4.55645099e-002f, -9.68245837e-002f, 0.00000000e+000f, 9.68245837e-002f, 0.00000000e+000f },
- { 6.25000000e-002f, -5.00000000e-002f, -1.25000000e-001f, -5.00000000e-002f, 4.55645099e-002f, 9.68245837e-002f, 0.00000000e+000f, 9.68245837e-002f, 0.00000000e+000f },
- { 6.25000000e-002f, -5.00000000e-002f, -1.25000000e-001f, 5.00000000e-002f, -4.55645099e-002f, 9.68245837e-002f, 0.00000000e+000f, -9.68245837e-002f, 0.00000000e+000f },
+ { 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 },
};
static const ALfloat AmbiOrderHFGainFOA[MAX_AMBI_ORDER+1] = {
- 2.82842712e+00, 1.63299316e+00
+ 3.00000000e+00f, 1.73205081e+00f
}, AmbiOrderHFGainHOA[MAX_AMBI_ORDER+1] = {
- 2.15665546e+00, 1.67053814e+00, 8.62662186e-01
+ 2.40192231e+00f, 1.86052102e+00f, 9.60768923e-01f
};
const ALfloat (*restrict AmbiMatrix)[MAX_AMBI_COEFFS] = AmbiMatrixFOA;
const ALfloat *restrict AmbiOrderHFGain = AmbiOrderHFGainFOA;
@@ -964,7 +982,8 @@ static void InitHrtfPanning(ALCdevice *device)
device->FOAOut.CoeffCount = 0;
device->FOAOut.NumChannels = 4;
- ambiup_reset(device->AmbiUp, device);
+ ambiup_reset(device->AmbiUp, device, AmbiOrderHFGainFOA[0] / AmbiOrderHFGain[0],
+ AmbiOrderHFGainFOA[1] / AmbiOrderHFGain[1]);
}
else
{