Don't use the dual-band upsampler for basic ambisonic decoding
This commit is contained in:
+19
-3
@@ -26,13 +26,13 @@ using namespace std::placeholders;
|
||||
static_assert(BFormatDec::sNumBands == 2, "Unexpected BFormatDec::sNumBands");
|
||||
|
||||
constexpr ALfloat Ambi3DDecoderHFScale[MAX_AMBI_ORDER+1] = {
|
||||
2.00000000f, 1.15470054f
|
||||
1.00000000e+00f, 1.00000000e+00f
|
||||
};
|
||||
constexpr ALfloat Ambi3DDecoderHFScale2O[MAX_AMBI_ORDER+1] = {
|
||||
1.49071198f, 1.15470054f
|
||||
7.45355990e-01f, 1.00000000e+00f
|
||||
};
|
||||
constexpr ALfloat Ambi3DDecoderHFScale3O[MAX_AMBI_ORDER+1] = {
|
||||
1.17958441f, 1.01578297f
|
||||
5.89792205e-01f, 8.79693856e-01f
|
||||
};
|
||||
|
||||
inline auto GetDecoderHFScales(ALsizei order) noexcept -> const ALfloat(&)[MAX_AMBI_ORDER+1]
|
||||
@@ -258,6 +258,22 @@ void BFormatDec::upSample(ALfloat (*OutBuffer)[BUFFERSIZE], const ALsizei OutCha
|
||||
}
|
||||
|
||||
|
||||
std::array<ALfloat,MAX_AMBI_ORDER+1> AmbiUpsampler::GetHFOrderScales(const ALsizei in_order, const ALsizei out_order) noexcept
|
||||
{
|
||||
std::array<ALfloat,MAX_AMBI_ORDER+1> ret{};
|
||||
|
||||
assert(out_order >= in_order);
|
||||
ASSUME(out_order >= in_order);
|
||||
|
||||
const ALfloat (&target)[MAX_AMBI_ORDER+1] = GetDecoderHFScales(out_order);
|
||||
const ALfloat (&input)[MAX_AMBI_ORDER+1] = GetDecoderHFScales(in_order);
|
||||
|
||||
for(ALsizei i{0};i < in_order+1;++i)
|
||||
ret[i] = input[i] / target[i];
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void AmbiUpsampler::reset(const ALsizei out_order, const ALfloat xover_norm)
|
||||
{
|
||||
const ALfloat (&hfscales)[MAX_AMBI_ORDER+1] = GetDecoderHFScales(out_order);
|
||||
|
||||
@@ -73,6 +73,8 @@ public:
|
||||
void reset(const ALsizei out_order, const ALfloat xover_norm);
|
||||
void process(ALfloat (*OutBuffer)[BUFFERSIZE], const ALsizei OutChannels, const ALfloat (*InSamples)[BUFFERSIZE], const ALsizei InChannels, const ALsizei SamplesToDo);
|
||||
|
||||
static std::array<ALfloat,MAX_AMBI_ORDER+1> GetHFOrderScales(const ALsizei in_order, const ALsizei out_order) noexcept;
|
||||
|
||||
DEF_NEWDEL(AmbiUpsampler)
|
||||
};
|
||||
|
||||
|
||||
+28
-22
@@ -453,20 +453,23 @@ void InitPanning(ALCdevice *device)
|
||||
device->AmbiDecoder->reset(coeffcount, 400.0f / static_cast<ALfloat>(device->Frequency),
|
||||
count, chancoeffs, idxmap);
|
||||
|
||||
if(coeffcount <= 4)
|
||||
{
|
||||
if(coeffcount <= 3)
|
||||
device->FOAOut.AmbiMap = device->Dry.AmbiMap;
|
||||
device->FOAOut.NumChannels = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
device->FOAOut.AmbiMap.fill(BFChannelConfig{});
|
||||
std::transform(AmbiIndex::From2D.begin(), AmbiIndex::From2D.begin()+3,
|
||||
std::begin(device->FOAOut.AmbiMap),
|
||||
[](const ALsizei &acn) noexcept { return BFChannelConfig{1.0f, acn}; }
|
||||
const std::array<ALfloat,MAX_AMBI_ORDER+1> scales{AmbiUpsampler::GetHFOrderScales(1,
|
||||
(coeffcount > 7) ? 4 :
|
||||
(coeffcount > 5) ? 3 :
|
||||
(coeffcount > 3) ? 2 : 1)};
|
||||
|
||||
device->FOAOut.AmbiMap[0] = BFChannelConfig{scales[0], AmbiIndex::From2D[0]};
|
||||
auto ambimap_iter = std::transform(AmbiIndex::From2D.begin()+1,
|
||||
AmbiIndex::From2D.begin()+3, std::begin(device->FOAOut.AmbiMap)+1,
|
||||
[&scales](const ALsizei &acn) noexcept { return BFChannelConfig{scales[1], acn}; }
|
||||
);
|
||||
device->FOAOut.NumChannels = 3;
|
||||
std::fill(ambimap_iter, std::end(device->FOAOut.AmbiMap), BFChannelConfig{});
|
||||
}
|
||||
device->FOAOut.NumChannels = 0;
|
||||
|
||||
device->RealOut.NumChannels = device->channelsFromFmt();
|
||||
}
|
||||
@@ -508,31 +511,34 @@ void InitCustomPanning(ALCdevice *device, const AmbDecConf *conf, const ALsizei
|
||||
device->AmbiDecoder->reset(conf, false, count, device->Frequency, speakermap);
|
||||
|
||||
if(conf->ChanMask <= AMBI_1ORDER_MASK)
|
||||
{
|
||||
device->FOAOut.AmbiMap = device->Dry.AmbiMap;
|
||||
device->FOAOut.NumChannels = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
device->FOAOut.AmbiMap.fill(BFChannelConfig{});
|
||||
const std::array<ALfloat,MAX_AMBI_ORDER+1> scales{AmbiUpsampler::GetHFOrderScales(1,
|
||||
(conf->ChanMask > AMBI_3ORDER_MASK) ? 4 :
|
||||
(conf->ChanMask > AMBI_2ORDER_MASK) ? 3 :
|
||||
(conf->ChanMask > AMBI_1ORDER_MASK) ? 2 : 1)};
|
||||
|
||||
auto ambimap_iter = std::begin(device->FOAOut.AmbiMap);
|
||||
if((conf->ChanMask&AMBI_PERIPHONIC_MASK))
|
||||
{
|
||||
count = 4;
|
||||
std::transform(AmbiIndex::From3D.begin(), AmbiIndex::From3D.begin()+count,
|
||||
std::begin(device->FOAOut.AmbiMap),
|
||||
[](const ALsizei &index) noexcept { return BFChannelConfig{1.0f, index}; }
|
||||
device->FOAOut.AmbiMap[0] = BFChannelConfig{scales[0], AmbiIndex::From3D[0]};
|
||||
ambimap_iter = std::transform(AmbiIndex::From3D.begin()+1,
|
||||
AmbiIndex::From3D.begin()+4, ambimap_iter+1,
|
||||
[&scales](const ALsizei &acn) noexcept { return BFChannelConfig{scales[1], acn}; }
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
count = 3;
|
||||
std::transform(AmbiIndex::From2D.begin(), AmbiIndex::From2D.begin()+count,
|
||||
std::begin(device->FOAOut.AmbiMap),
|
||||
[](const ALsizei &index) noexcept { return BFChannelConfig{1.0f, index}; }
|
||||
device->FOAOut.AmbiMap[0] = BFChannelConfig{scales[0], AmbiIndex::From2D[0]};
|
||||
ambimap_iter = std::transform(AmbiIndex::From2D.begin()+1,
|
||||
AmbiIndex::From2D.begin()+3, ambimap_iter,
|
||||
[&scales](const ALsizei &acn) noexcept { return BFChannelConfig{scales[1], acn}; }
|
||||
);
|
||||
}
|
||||
device->FOAOut.NumChannels = count;
|
||||
std::fill(ambimap_iter, std::end(device->FOAOut.AmbiMap), BFChannelConfig{});
|
||||
}
|
||||
device->FOAOut.NumChannels = 0;
|
||||
|
||||
device->RealOut.NumChannels = device->channelsFromFmt();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user