diff options
author | Chris Robinson <[email protected]> | 2018-12-20 04:19:35 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-12-20 04:19:35 -0800 |
commit | 49ac268334bf8875ff1b5baa1e79edc8b7fe15bd (patch) | |
tree | 8417b3b937ee38d19a7dd2708729fa35290ffe6e | |
parent | 8d3f7651c9d188f047a2b2c2ee4e2012b56d9b50 (diff) |
Add index maps from 2D and 3D
-rw-r--r-- | Alc/ambidefs.h | 8 | ||||
-rw-r--r-- | Alc/bformatdec.cpp | 14 | ||||
-rw-r--r-- | Alc/panning.cpp | 33 |
3 files changed, 30 insertions, 25 deletions
diff --git a/Alc/ambidefs.h b/Alc/ambidefs.h index 82eb7ee3..eeb09f75 100644 --- a/Alc/ambidefs.h +++ b/Alc/ambidefs.h @@ -102,6 +102,14 @@ struct AmbiIndex { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }}; + + static constexpr std::array<int,MAX_AMBI2D_COEFFS> From2D{{ + 0, 1,3, 4,8, 9,15 + }}; + static constexpr std::array<int,MAX_AMBI_COEFFS> From3D{{ + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15 + }}; }; #endif /* AMBIDEFS_H */ diff --git a/Alc/bformatdec.cpp b/Alc/bformatdec.cpp index 6a149611..d0d1325a 100644 --- a/Alc/bformatdec.cpp +++ b/Alc/bformatdec.cpp @@ -63,8 +63,6 @@ auto GetAmbiScales(AmbDecScale scaletype) noexcept -> const std::array<float,MAX void BFormatDec::reset(const AmbDecConf *conf, ALsizei chancount, ALuint srate, const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]) { - static constexpr ALsizei map2DTo3D[MAX_AMBI2D_COEFFS]{ 0, 1, 3, 4, 8, 9, 15 }; - mSamples.clear(); mSamplesHF = nullptr; mSamplesLF = nullptr; @@ -110,16 +108,16 @@ void BFormatDec::reset(const AmbDecConf *conf, ALsizei chancount, ALuint srate, { ALfloat coeffs[MAX_AMBI_COEFFS]; CalcDirectionCoeffs(Ambi3DPoints[k], 0.0f, coeffs); - auto ambimap_end = std::begin(map2DTo3D) + chancount; - std::transform(std::begin(map2DTo3D), ambimap_end, std::begin(encgains[k]), + auto ambimap_end = AmbiIndex::From2D.begin() + chancount; + std::transform(AmbiIndex::From2D.begin(), ambimap_end, std::begin(encgains[k]), [&coeffs](const ALsizei &index) noexcept -> ALfloat - { ASSUME(index > 0); return coeffs[index]; } + { ASSUME(index >= 0); return coeffs[index]; } ); } assert(chancount >= 3); for(ALsizei c{0};c < 3;c++) { - const ALsizei i{map2DTo3D[c]}; + const ALsizei i{AmbiIndex::From2D[c]}; ALdouble gain{0.0}; for(size_t k{0u};k < COUNTOF(Ambi3DDecoder);k++) gain += (ALdouble)Ambi3DDecoder[k][i] * encgains[k][c]; @@ -142,7 +140,7 @@ void BFormatDec::reset(const AmbDecConf *conf, ALsizei chancount, ALuint srate, ALfloat (&mtx)[MAX_AMBI_COEFFS] = mMatrix.Single[chanmap[i]]; for(ALsizei j{0},k{0};j < coeff_count;j++) { - const ALsizei l{periphonic ? j : map2DTo3D[j]}; + const ALsizei l{periphonic ? j : AmbiIndex::From2D[j]}; if(!(conf->ChanMask&(1<<l))) continue; mtx[j] = conf->HFMatrix[i][k] / coeff_scale[l] * ((l>=9) ? conf->HFOrderGain[3] : @@ -163,7 +161,7 @@ void BFormatDec::reset(const AmbDecConf *conf, ALsizei chancount, ALuint srate, ALfloat (&mtx)[sNumBands][MAX_AMBI_COEFFS] = mMatrix.Dual[chanmap[i]]; for(ALsizei j{0},k{0};j < coeff_count;j++) { - const ALsizei l{periphonic ? j : map2DTo3D[j]}; + const ALsizei l{periphonic ? j : AmbiIndex::From2D[j]}; if(!(conf->ChanMask&(1<<l))) continue; mtx[HF_BAND][j] = conf->HFMatrix[i][k] / coeff_scale[l] * ((l>=9) ? conf->HFOrderGain[3] : diff --git a/Alc/panning.cpp b/Alc/panning.cpp index 50d1eec2..d03977b8 100644 --- a/Alc/panning.cpp +++ b/Alc/panning.cpp @@ -47,6 +47,8 @@ constexpr std::array<float,MAX_AMBI_COEFFS> AmbiScale::FromSN3D; constexpr std::array<float,MAX_AMBI_COEFFS> AmbiScale::FromFuMa; constexpr std::array<int,MAX_AMBI_COEFFS> AmbiIndex::FromFuMa; constexpr std::array<int,MAX_AMBI_COEFFS> AmbiIndex::FromACN; +constexpr std::array<int,MAX_AMBI2D_COEFFS> AmbiIndex::From2D; +constexpr std::array<int,MAX_AMBI_COEFFS> AmbiIndex::From3D; namespace { @@ -423,11 +425,8 @@ void InitPanning(ALCdevice *device) } else { - /* FOA output is always ACN+N3D for higher-order ambisonic output. - * The upsampler expects this and will convert it for output. - */ device->FOAOut.Ambi = AmbiConfig{}; - std::transform(AmbiIndex::FromACN.begin(), AmbiIndex::FromACN.begin()+4, + std::transform(AmbiIndex::From3D.begin(), AmbiIndex::From3D.begin()+4, std::begin(device->FOAOut.Ambi.Map), [](const ALsizei &acn) noexcept { return BFChannelConfig{1.0f, acn}; } ); @@ -462,7 +461,7 @@ void InitPanning(ALCdevice *device) else { device->FOAOut.Ambi = AmbiConfig{}; - std::transform(AmbiIndex::FromACN.begin(), AmbiIndex::FromACN.begin()+4, + std::transform(AmbiIndex::From3D.begin(), AmbiIndex::From3D.begin()+4, std::begin(device->FOAOut.Ambi.Map), [](const ALsizei &acn) noexcept { return BFChannelConfig{1.0f, acn}; } ); @@ -513,11 +512,11 @@ void InitCustomPanning(ALCdevice *device, const AmbDecConf *conf, const ALsizei } else { - static constexpr int map[4] = { 0, 1, 2, 3 }; static constexpr ALsizei count{4}; device->FOAOut.Ambi = AmbiConfig{}; - std::transform(std::begin(map), std::begin(map)+count, std::begin(device->FOAOut.Ambi.Map), + std::transform(AmbiIndex::From3D.begin(), AmbiIndex::From3D.begin()+count, + std::begin(device->FOAOut.Ambi.Map), [](const ALsizei &index) noexcept { return BFChannelConfig{1.0f, index}; } ); device->FOAOut.CoeffCount = 0; @@ -540,19 +539,19 @@ void InitHQPanning(ALCdevice *device, const AmbDecConf *conf, const ALsizei (&sp ALsizei count; if((conf->ChanMask&AMBI_PERIPHONIC_MASK)) { - static constexpr int map[MAX_AMBI_COEFFS] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; count = (conf->ChanMask > AMBI_2ORDER_MASK) ? 16 : (conf->ChanMask > AMBI_1ORDER_MASK) ? 9 : 4; - std::transform(std::begin(map), std::begin(map)+count, std::begin(device->Dry.Ambi.Map), + std::transform(AmbiIndex::From3D.begin(), AmbiIndex::From3D.begin()+count, + std::begin(device->Dry.Ambi.Map), [](const ALsizei &index) noexcept { return BFChannelConfig{1.0f, index}; } ); } else { - static constexpr int map[MAX_AMBI2D_COEFFS] = { 0, 1, 3, 4, 8, 9, 15 }; count = (conf->ChanMask > AMBI_2ORDER_MASK) ? 7 : (conf->ChanMask > AMBI_1ORDER_MASK) ? 5 : 3; - std::transform(std::begin(map), std::begin(map)+count, std::begin(device->Dry.Ambi.Map), + std::transform(AmbiIndex::From2D.begin(), AmbiIndex::From2D.begin()+count, + std::begin(device->Dry.Ambi.Map), [](const ALsizei &index) noexcept { return BFChannelConfig{1.0f, index}; } ); } @@ -579,17 +578,17 @@ void InitHQPanning(ALCdevice *device, const AmbDecConf *conf, const ALsizei (&sp device->FOAOut.Ambi = AmbiConfig{}; if((conf->ChanMask&AMBI_PERIPHONIC_MASK)) { - static constexpr int map[4] = { 0, 1, 2, 3 }; count = 4; - std::transform(std::begin(map), std::begin(map)+count, std::begin(device->FOAOut.Ambi.Map), + std::transform(AmbiIndex::From3D.begin(), AmbiIndex::From3D.begin()+count, + std::begin(device->FOAOut.Ambi.Map), [](const ALsizei &index) noexcept { return BFChannelConfig{1.0f, index}; } ); } else { - static constexpr int map[3] = { 0, 1, 3 }; count = 3; - std::transform(std::begin(map), std::begin(map)+count, std::begin(device->FOAOut.Ambi.Map), + std::transform(AmbiIndex::From2D.begin(), AmbiIndex::From2D.begin()+count, + std::begin(device->FOAOut.Ambi.Map), [](const ALsizei &index) noexcept { return BFChannelConfig{1.0f, index}; } ); } @@ -1145,8 +1144,8 @@ no_hrtf: void aluInitEffectPanning(ALeffectslot *slot) { const size_t count{countof(slot->ChanMap)}; - auto acnmap_end = AmbiIndex::FromACN.begin() + count; - std::transform(AmbiIndex::FromACN.begin(), acnmap_end, std::begin(slot->ChanMap), + auto acnmap_end = AmbiIndex::From3D.begin() + count; + std::transform(AmbiIndex::From3D.begin(), acnmap_end, std::begin(slot->ChanMap), [](const ALsizei &acn) noexcept { return BFChannelConfig{1.0f, acn}; } ); slot->NumChannels = static_cast<ALsizei>(count); |