diff options
author | Chris Robinson <[email protected]> | 2018-12-15 23:28:49 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-12-15 23:28:49 -0800 |
commit | 741861eaa62bd555255f19467fa115a12b7fd577 (patch) | |
tree | 355ace44252d63c55760ad1747bff8a24b089cf2 /Alc | |
parent | a6a5634adb1bdec44fa7cb8557e5b6d59642d7aa (diff) |
Put the ACN index map in a header
Also put it and the Ambisonic scales in a more appropriate header.
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ambidefs.h | 72 | ||||
-rw-r--r-- | Alc/bformatdec.cpp | 5 | ||||
-rw-r--r-- | Alc/bformatdec.h | 47 | ||||
-rw-r--r-- | Alc/panning.cpp | 46 |
4 files changed, 88 insertions, 82 deletions
diff --git a/Alc/ambidefs.h b/Alc/ambidefs.h index 124a0c8e..bdeac18e 100644 --- a/Alc/ambidefs.h +++ b/Alc/ambidefs.h @@ -30,4 +30,76 @@ */ #define MAX_AMBI2D_COEFFS (MAX_AMBI_ORDER*2 + 1) + +/* NOTE: These are scale factors as applied to Ambisonics content. Decoder + * coefficients should be divided by these values to get proper N3D scalings. + */ +struct AmbiScale { + static constexpr float N3D2N3D[MAX_AMBI_COEFFS]{ + 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f + }; + static constexpr float SN3D2N3D[MAX_AMBI_COEFFS]{ + 1.000000000f, /* ACN 0, sqrt(1) */ + 1.732050808f, /* ACN 1, sqrt(3) */ + 1.732050808f, /* ACN 2, sqrt(3) */ + 1.732050808f, /* ACN 3, sqrt(3) */ + 2.236067978f, /* ACN 4, sqrt(5) */ + 2.236067978f, /* ACN 5, sqrt(5) */ + 2.236067978f, /* ACN 6, sqrt(5) */ + 2.236067978f, /* ACN 7, sqrt(5) */ + 2.236067978f, /* ACN 8, sqrt(5) */ + 2.645751311f, /* ACN 9, sqrt(7) */ + 2.645751311f, /* ACN 10, sqrt(7) */ + 2.645751311f, /* ACN 11, sqrt(7) */ + 2.645751311f, /* ACN 12, sqrt(7) */ + 2.645751311f, /* ACN 13, sqrt(7) */ + 2.645751311f, /* ACN 14, sqrt(7) */ + 2.645751311f, /* ACN 15, sqrt(7) */ + }; + static constexpr float FuMa2N3D[MAX_AMBI_COEFFS]{ + 1.414213562f, /* ACN 0 (W), sqrt(2) */ + 1.732050808f, /* ACN 1 (Y), sqrt(3) */ + 1.732050808f, /* ACN 2 (Z), sqrt(3) */ + 1.732050808f, /* ACN 3 (X), sqrt(3) */ + 1.936491673f, /* ACN 4 (V), sqrt(15)/2 */ + 1.936491673f, /* ACN 5 (T), sqrt(15)/2 */ + 2.236067978f, /* ACN 6 (R), sqrt(5) */ + 1.936491673f, /* ACN 7 (S), sqrt(15)/2 */ + 1.936491673f, /* ACN 8 (U), sqrt(15)/2 */ + 2.091650066f, /* ACN 9 (Q), sqrt(35/8) */ + 1.972026594f, /* ACN 10 (O), sqrt(35)/3 */ + 2.231093404f, /* ACN 11 (M), sqrt(224/45) */ + 2.645751311f, /* ACN 12 (K), sqrt(7) */ + 2.231093404f, /* ACN 13 (L), sqrt(224/45) */ + 1.972026594f, /* ACN 14 (N), sqrt(35)/3 */ + 2.091650066f, /* ACN 15 (P), sqrt(35/8) */ + }; +}; + +struct AmbiIndex { + static constexpr int FuMa2ACN[MAX_AMBI_COEFFS]{ + 0, /* W */ + 3, /* X */ + 1, /* Y */ + 2, /* Z */ + 6, /* R */ + 7, /* S */ + 5, /* T */ + 8, /* U */ + 4, /* V */ + 12, /* K */ + 13, /* L */ + 11, /* M */ + 14, /* N */ + 10, /* O */ + 15, /* P */ + 9, /* Q */ + }; + static constexpr int ACN2ACN[MAX_AMBI_COEFFS]{ + 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 d92c84db..9c6e3dff 100644 --- a/Alc/bformatdec.cpp +++ b/Alc/bformatdec.cpp @@ -17,11 +17,6 @@ #include "almalloc.h" -constexpr float AmbiScale::N3D2N3D[MAX_AMBI_COEFFS]; -constexpr float AmbiScale::SN3D2N3D[MAX_AMBI_COEFFS]; -constexpr float AmbiScale::FuMa2N3D[MAX_AMBI_COEFFS]; - - namespace { #define HF_BAND 0 diff --git a/Alc/bformatdec.h b/Alc/bformatdec.h index d855041d..4da5547e 100644 --- a/Alc/bformatdec.h +++ b/Alc/bformatdec.h @@ -26,53 +26,6 @@ struct AmbDecConf; #define XYZ_SCALE_3H3P 1.136697713f -/* NOTE: These are scale factors as applied to Ambisonics content. Decoder - * coefficients should be divided by these values to get proper N3D scalings. - */ -struct AmbiScale { - static constexpr float N3D2N3D[MAX_AMBI_COEFFS]{ - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f - }; - static constexpr float SN3D2N3D[MAX_AMBI_COEFFS]{ - 1.000000000f, /* ACN 0 (W), sqrt(1) */ - 1.732050808f, /* ACN 1 (Y), sqrt(3) */ - 1.732050808f, /* ACN 2 (Z), sqrt(3) */ - 1.732050808f, /* ACN 3 (X), sqrt(3) */ - 2.236067978f, /* ACN 4 (V), sqrt(5) */ - 2.236067978f, /* ACN 5 (T), sqrt(5) */ - 2.236067978f, /* ACN 6 (R), sqrt(5) */ - 2.236067978f, /* ACN 7 (S), sqrt(5) */ - 2.236067978f, /* ACN 8 (U), sqrt(5) */ - 2.645751311f, /* ACN 9 (Q), sqrt(7) */ - 2.645751311f, /* ACN 10 (O), sqrt(7) */ - 2.645751311f, /* ACN 11 (M), sqrt(7) */ - 2.645751311f, /* ACN 12 (K), sqrt(7) */ - 2.645751311f, /* ACN 13 (L), sqrt(7) */ - 2.645751311f, /* ACN 14 (N), sqrt(7) */ - 2.645751311f, /* ACN 15 (P), sqrt(7) */ - }; - static constexpr float FuMa2N3D[MAX_AMBI_COEFFS]{ - 1.414213562f, /* ACN 0 (W), sqrt(2) */ - 1.732050808f, /* ACN 1 (Y), sqrt(3) */ - 1.732050808f, /* ACN 2 (Z), sqrt(3) */ - 1.732050808f, /* ACN 3 (X), sqrt(3) */ - 1.936491673f, /* ACN 4 (V), sqrt(15)/2 */ - 1.936491673f, /* ACN 5 (T), sqrt(15)/2 */ - 2.236067978f, /* ACN 6 (R), sqrt(5) */ - 1.936491673f, /* ACN 7 (S), sqrt(15)/2 */ - 1.936491673f, /* ACN 8 (U), sqrt(15)/2 */ - 2.091650066f, /* ACN 9 (Q), sqrt(35/8) */ - 1.972026594f, /* ACN 10 (O), sqrt(35)/3 */ - 2.231093404f, /* ACN 11 (M), sqrt(224/45) */ - 2.645751311f, /* ACN 12 (K), sqrt(7) */ - 2.231093404f, /* ACN 13 (L), sqrt(224/45) */ - 1.972026594f, /* ACN 14 (N), sqrt(35)/3 */ - 2.091650066f, /* ACN 15 (P), sqrt(35/8) */ - }; -}; - - class BFormatDec { public: static constexpr size_t sNumBands{2}; diff --git a/Alc/panning.cpp b/Alc/panning.cpp index 37559620..3ea0ae06 100644 --- a/Alc/panning.cpp +++ b/Alc/panning.cpp @@ -42,30 +42,14 @@ #include "bs2b.h" -namespace { +constexpr float AmbiScale::N3D2N3D[MAX_AMBI_COEFFS]; +constexpr float AmbiScale::SN3D2N3D[MAX_AMBI_COEFFS]; +constexpr float AmbiScale::FuMa2N3D[MAX_AMBI_COEFFS]; +constexpr int AmbiIndex::FuMa2ACN[MAX_AMBI_COEFFS]; +constexpr int AmbiIndex::ACN2ACN[MAX_AMBI_COEFFS]; -constexpr ALsizei FuMa2ACN[MAX_AMBI_COEFFS] = { - 0, /* W */ - 3, /* X */ - 1, /* Y */ - 2, /* Z */ - 6, /* R */ - 7, /* S */ - 5, /* T */ - 8, /* U */ - 4, /* V */ - 12, /* K */ - 13, /* L */ - 11, /* M */ - 14, /* N */ - 10, /* O */ - 15, /* P */ - 9, /* Q */ -}; -constexpr ALsizei ACN2ACN[MAX_AMBI_COEFFS] = { - 0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15 -}; + +namespace { inline const char *GetLabelFromChannel(Channel channel) { @@ -354,10 +338,10 @@ auto GetAmbiScales(AmbiNorm scaletype) noexcept -> const float(&)[MAX_AMBI_COEFF return AmbiScale::N3D2N3D; } -auto GetAmbiLayout(AmbiLayout layouttype) noexcept -> const ALsizei(&)[MAX_AMBI_COEFFS] +auto GetAmbiLayout(AmbiLayout layouttype) noexcept -> const int(&)[MAX_AMBI_COEFFS] { - if(layouttype == AmbiLayout::FuMa) return FuMa2ACN; - return ACN2ACN; + if(layouttype == AmbiLayout::FuMa) return AmbiIndex::FuMa2ACN; + return AmbiIndex::ACN2ACN; } @@ -444,8 +428,8 @@ void InitPanning(ALCdevice *device) * The upsampler expects this and will convert it for output. */ device->FOAOut.Ambi = AmbiConfig{}; - acnmap_end = std::begin(ACN2ACN) + 4; - std::transform(std::begin(ACN2ACN), acnmap_end, std::begin(device->FOAOut.Ambi.Map), + acnmap_end = std::begin(AmbiIndex::ACN2ACN) + 4; + std::transform(std::begin(AmbiIndex::ACN2ACN), acnmap_end, std::begin(device->FOAOut.Ambi.Map), [](const ALsizei &acn) noexcept { return BFChannelConfig{1.0f, acn}; } ); device->FOAOut.CoeffCount = 0; @@ -779,7 +763,8 @@ void InitUhjPanning(ALCdevice *device) { static constexpr ALsizei count{3}; - std::transform(std::begin(FuMa2ACN), std::begin(FuMa2ACN)+count, std::begin(device->Dry.Ambi.Map), + auto acnmap_end = std::begin(AmbiIndex::FuMa2ACN) + count; + std::transform(std::begin(AmbiIndex::FuMa2ACN), acnmap_end, std::begin(device->Dry.Ambi.Map), [](const ALsizei &acn) noexcept -> BFChannelConfig { return BFChannelConfig{1.0f/AmbiScale::FuMa2N3D[acn], acn}; } ); @@ -1205,7 +1190,8 @@ no_hrtf: void aluInitEffectPanning(ALeffectslot *slot) { const size_t count{countof(slot->ChanMap)}; - std::transform(std::begin(ACN2ACN), std::begin(ACN2ACN)+count, std::begin(slot->ChanMap), + auto acnmap_end = std::begin(AmbiIndex::ACN2ACN) + count; + std::transform(std::begin(AmbiIndex::ACN2ACN), acnmap_end, std::begin(slot->ChanMap), [](const ALsizei &acn) noexcept { return BFChannelConfig{1.0f, acn}; } ); slot->NumChannels = static_cast<ALsizei>(count); |