diff options
Diffstat (limited to 'alc/ambidefs.h')
-rw-r--r-- | alc/ambidefs.h | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/alc/ambidefs.h b/alc/ambidefs.h index 79c0f1cf..339b51f9 100644 --- a/alc/ambidefs.h +++ b/alc/ambidefs.h @@ -5,30 +5,32 @@ #include <stddef.h> #include <stdint.h> +using uint = unsigned int; + /* The maximum number of Ambisonics channels. For a given order (o), the size * needed will be (o+1)**2, thus zero-order has 1, first-order has 4, second- * order has 9, third-order has 16, and fourth-order has 25. */ -#define MAX_AMBI_ORDER 3 +constexpr uint8_t MaxAmbiOrder{3}; constexpr inline size_t AmbiChannelsFromOrder(size_t order) noexcept { return (order+1) * (order+1); } -#define MAX_AMBI_CHANNELS AmbiChannelsFromOrder(MAX_AMBI_ORDER) +constexpr size_t MaxAmbiChannels{AmbiChannelsFromOrder(MaxAmbiOrder)}; /* A bitmask of ambisonic channels for 0 to 4th order. This only specifies up * to 4th order, which is the highest order a 32-bit mask value can specify (a * 64-bit mask could handle up to 7th order). */ -#define AMBI_0ORDER_MASK 0x00000001 -#define AMBI_1ORDER_MASK 0x0000000f -#define AMBI_2ORDER_MASK 0x000001ff -#define AMBI_3ORDER_MASK 0x0000ffff -#define AMBI_4ORDER_MASK 0x01ffffff +constexpr uint Ambi0OrderMask{0x00000001}; +constexpr uint Ambi1OrderMask{0x0000000f}; +constexpr uint Ambi2OrderMask{0x000001ff}; +constexpr uint Ambi3OrderMask{0x0000ffff}; +constexpr uint Ambi4OrderMask{0x01ffffff}; /* A bitmask of ambisonic channels with height information. If none of these * channels are used/needed, there's no height (e.g. with most surround sound * speaker setups). This is ACN ordering, with bit 0 being ACN 0, etc. */ -#define AMBI_PERIPHONIC_MASK 0xfe7ce4 +constexpr uint AmbiPeriphonicMask{0xfe7ce4}; /* The maximum number of ambisonic channels for 2D (non-periphonic) * representation. This is 2 per each order above zero-order, plus 1 for zero- @@ -36,18 +38,18 @@ constexpr inline size_t AmbiChannelsFromOrder(size_t order) noexcept */ constexpr inline size_t Ambi2DChannelsFromOrder(size_t order) noexcept { return order*2 + 1; } -#define MAX_AMBI2D_CHANNELS Ambi2DChannelsFromOrder(MAX_AMBI_ORDER) +constexpr size_t MaxAmbi2DChannels{Ambi2DChannelsFromOrder(MaxAmbiOrder)}; /* NOTE: These are scale factors as applied to Ambisonics content. Decoder * coefficients should be divided by these values to get proper scalings. */ struct AmbiScale { - static constexpr std::array<float,MAX_AMBI_CHANNELS> FromN3D{{ + static constexpr std::array<float,MaxAmbiChannels> FromN3D{{ 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 std::array<float,MAX_AMBI_CHANNELS> FromSN3D{{ + static constexpr std::array<float,MaxAmbiChannels> FromSN3D{{ 1.000000000f, /* ACN 0, sqrt(1) */ 1.732050808f, /* ACN 1, sqrt(3) */ 1.732050808f, /* ACN 2, sqrt(3) */ @@ -65,7 +67,7 @@ struct AmbiScale { 2.645751311f, /* ACN 14, sqrt(7) */ 2.645751311f, /* ACN 15, sqrt(7) */ }}; - static constexpr std::array<float,MAX_AMBI_CHANNELS> FromFuMa{{ + static constexpr std::array<float,MaxAmbiChannels> FromFuMa{{ 1.414213562f, /* ACN 0 (W), sqrt(2) */ 1.732050808f, /* ACN 1 (Y), sqrt(3) */ 1.732050808f, /* ACN 2 (Z), sqrt(3) */ @@ -86,7 +88,7 @@ struct AmbiScale { }; struct AmbiIndex { - static constexpr std::array<uint8_t,MAX_AMBI_CHANNELS> FromFuMa{{ + static constexpr std::array<uint8_t,MaxAmbiChannels> FromFuMa{{ 0, /* W */ 3, /* X */ 1, /* Y */ @@ -104,7 +106,7 @@ struct AmbiIndex { 15, /* P */ 9, /* Q */ }}; - static constexpr std::array<uint8_t,MAX_AMBI2D_CHANNELS> FromFuMa2D{{ + static constexpr std::array<uint8_t,MaxAmbi2DChannels> FromFuMa2D{{ 0, /* W */ 3, /* X */ 1, /* Y */ @@ -114,18 +116,18 @@ struct AmbiIndex { 9, /* Q */ }}; - static constexpr std::array<uint8_t,MAX_AMBI_CHANNELS> FromACN{{ + static constexpr std::array<uint8_t,MaxAmbiChannels> FromACN{{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }}; - static constexpr std::array<uint8_t,MAX_AMBI2D_CHANNELS> From2D{{ + static constexpr std::array<uint8_t,MaxAmbi2DChannels> From2D{{ 0, 1,3, 4,8, 9,15 }}; - static constexpr std::array<uint8_t,MAX_AMBI_CHANNELS> OrderFromChannel{{ + static constexpr std::array<uint8_t,MaxAmbiChannels> OrderFromChannel{{ 0, 1,1,1, 2,2,2,2,2, 3,3,3,3,3,3,3, }}; - static constexpr std::array<uint8_t,MAX_AMBI2D_CHANNELS> OrderFrom2DChannel{{ + static constexpr std::array<uint8_t,MaxAmbi2DChannels> OrderFrom2DChannel{{ 0, 1,1, 2,2, 3,3, }}; }; |