aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/bformatdec.cpp68
-rw-r--r--Alc/bformatdec.h2
-rw-r--r--Alc/panning.cpp16
3 files changed, 23 insertions, 63 deletions
diff --git a/Alc/bformatdec.cpp b/Alc/bformatdec.cpp
index 9c6e3dff..ee3d977e 100644
--- a/Alc/bformatdec.cpp
+++ b/Alc/bformatdec.cpp
@@ -51,18 +51,6 @@ constexpr ALfloat Ambi3DDecoderHFScale[MAX_AMBI_COEFFS] = {
};
-#define INVALID_UPSAMPLE_INDEX INT_MAX
-ALsizei GetACNIndex(const BFChannelConfig *chans, ALsizei numchans, ALsizei acn)
-{
- for(ALsizei i{0};i < numchans;i++)
- {
- if(chans[i].Index == acn)
- return i;
- }
- return INVALID_UPSAMPLE_INDEX;
-}
-#define GetChannelForACN(b, a) GetACNIndex((b).Ambi.Map, (b).NumChannels, (a))
-
auto GetAmbiScales(AmbDecScale scaletype) noexcept -> const float(&)[MAX_AMBI_COEFFS]
{
if(scaletype == AmbDecScale::FuMa) return AmbiScale::FuMa2N3D;
@@ -254,52 +242,36 @@ void BFormatDec::upSample(ALfloat (*RESTRICT OutBuffer)[BUFFERSIZE], const ALflo
}
-void AmbiUpsampler::reset(const ALCdevice *device, const ALfloat w_scale, const ALfloat xyz_scale)
+void AmbiUpsampler::reset(const ALCdevice *device)
{
using namespace std::placeholders;
mXOver[0].init(400.0f / (float)device->Frequency);
std::fill(std::begin(mXOver)+1, std::end(mXOver), mXOver[0]);
- mGains.fill({});
- if(device->Dry.CoeffCount > 0)
+ ALfloat encgains[8][MAX_OUTPUT_CHANNELS];
+ for(size_t k{0u};k < COUNTOF(Ambi3DPoints);k++)
{
- ALfloat encgains[8][MAX_OUTPUT_CHANNELS];
- for(size_t k{0u};k < COUNTOF(Ambi3DPoints);k++)
- {
- ALfloat coeffs[MAX_AMBI_COEFFS];
- CalcDirectionCoeffs(Ambi3DPoints[k], 0.0f, coeffs);
- ComputePanGains(&device->Dry, coeffs, 1.0f, encgains[k]);
- }
-
- /* Combine the matrices that do the in->virt and virt->out conversions
- * so we get a single in->out conversion. NOTE: the Encoder matrix
- * (encgains) and output are transposed, so the input channels line up
- * with the rows and the output channels line up with the columns.
- */
- for(ALsizei i{0};i < 4;i++)
- {
- for(ALsizei j{0};j < device->Dry.NumChannels;j++)
- {
- ALdouble gain{0.0};
- for(size_t k{0u};k < COUNTOF(Ambi3DDecoder);k++)
- gain += (ALdouble)Ambi3DDecoder[k][i] * encgains[k][j];
- mGains[i][j][HF_BAND] = (ALfloat)(gain * Ambi3DDecoderHFScale[i]);
- mGains[i][j][LF_BAND] = (ALfloat)gain;
- }
- }
+ ALfloat coeffs[MAX_AMBI_COEFFS];
+ CalcDirectionCoeffs(Ambi3DPoints[k], 0.0f, coeffs);
+ ComputePanGains(&device->Dry, coeffs, 1.0f, encgains[k]);
}
- else
+
+ /* Combine the matrices that do the in->virt and virt->out conversions so
+ * we get a single in->out conversion. NOTE: the Encoder matrix (encgains)
+ * and output are transposed, so the input channels line up with the rows
+ * and the output channels line up with the columns.
+ */
+ mGains.fill({});
+ for(ALsizei i{0};i < 4;i++)
{
- for(ALsizei i{0};i < 4;i++)
+ for(ALsizei j{0};j < device->Dry.NumChannels;j++)
{
- const ALsizei index{GetChannelForACN(device->Dry, i)};
- if(index != INVALID_UPSAMPLE_INDEX)
- {
- const ALfloat scale{device->Dry.Ambi.Map[index].Scale};
- mGains[i][index][HF_BAND] = scale * ((i==0) ? w_scale : xyz_scale);
- mGains[i][index][LF_BAND] = scale;
- }
+ ALdouble gain{0.0};
+ for(size_t k{0u};k < COUNTOF(Ambi3DDecoder);k++)
+ gain += (ALdouble)Ambi3DDecoder[k][i] * encgains[k][j];
+ mGains[i][j][HF_BAND] = (ALfloat)(gain * Ambi3DDecoderHFScale[i]);
+ mGains[i][j][LF_BAND] = (ALfloat)gain;
}
}
}
diff --git a/Alc/bformatdec.h b/Alc/bformatdec.h
index 385fe0fa..c52472b5 100644
--- a/Alc/bformatdec.h
+++ b/Alc/bformatdec.h
@@ -84,7 +84,7 @@ private:
std::array<std::array<std::array<ALfloat,sNumBands>,MAX_OUTPUT_CHANNELS>,4> mGains;
public:
- void reset(const ALCdevice *device, const ALfloat w_scale, const ALfloat xyz_scale);
+ void reset(const ALCdevice *device);
void process(ALfloat (*RESTRICT OutBuffer)[BUFFERSIZE], const ALsizei OutChannels, const ALfloat (*RESTRICT InSamples)[BUFFERSIZE], const ALsizei SamplesToDo);
DEF_NEWDEL(AmbiUpsampler)
diff --git a/Alc/panning.cpp b/Alc/panning.cpp
index 3ea0ae06..28df87d0 100644
--- a/Alc/panning.cpp
+++ b/Alc/panning.cpp
@@ -435,18 +435,7 @@ void InitPanning(ALCdevice *device)
device->FOAOut.CoeffCount = 0;
device->FOAOut.NumChannels = 4;
- ALfloat w_scale{1.0f}, xyz_scale{1.0f};
- if(device->mAmbiOrder >= 3)
- {
- w_scale = W_SCALE_3H3P;
- xyz_scale = XYZ_SCALE_3H3P;
- }
- else
- {
- w_scale = W_SCALE_2H2P;
- xyz_scale = XYZ_SCALE_2H2P;
- }
- device->AmbiUp->reset(device, w_scale, xyz_scale);
+ device->AmbiUp->reset(device);
}
ALfloat nfc_delay{0.0f};
@@ -738,8 +727,7 @@ void InitHrtfPanning(ALCdevice *device)
device->FOAOut.CoeffCount = 0;
device->FOAOut.NumChannels = 4;
- device->AmbiUp->reset(device, AmbiOrderHFGainFOA[0] / AmbiOrderHFGain[0],
- AmbiOrderHFGainFOA[1] / AmbiOrderHFGain[1]);
+ device->AmbiUp->reset(device);
}
else
{