7 /* The maximum number of Ambisonics channels. For a given order (o), the size
8 * needed will be (o+1)**2, thus zero-order has 1, first-order has 4, second-
9 * order has 9, third-order has 16, and fourth-order has 25.
11 #define MAX_AMBI_ORDER 3
12 constexpr inline size_t AmbiChannelsFromOrder(size_t order
) noexcept
13 { return (order
+1) * (order
+1); }
14 #define MAX_AMBI_CHANNELS AmbiChannelsFromOrder(MAX_AMBI_ORDER)
16 /* A bitmask of ambisonic channels for 0 to 4th order. This only specifies up
17 * to 4th order, which is the highest order a 32-bit mask value can specify (a
18 * 64-bit mask could handle up to 7th order).
20 #define AMBI_0ORDER_MASK 0x00000001
21 #define AMBI_1ORDER_MASK 0x0000000f
22 #define AMBI_2ORDER_MASK 0x000001ff
23 #define AMBI_3ORDER_MASK 0x0000ffff
24 #define AMBI_4ORDER_MASK 0x01ffffff
26 /* A bitmask of ambisonic channels with height information. If none of these
27 * channels are used/needed, there's no height (e.g. with most surround sound
28 * speaker setups). This is ACN ordering, with bit 0 being ACN 0, etc.
30 #define AMBI_PERIPHONIC_MASK (0xfe7ce4)
32 /* The maximum number of ambisonic channels for 2D (non-periphonic)
33 * representation. This is 2 per each order above zero-order, plus 1 for zero-
34 * order. Or simply, o*2 + 1.
36 constexpr inline size_t Ambi2DChannelsFromOrder(size_t order
) noexcept
37 { return order
*2 + 1; }
38 #define MAX_AMBI2D_CHANNELS Ambi2DChannelsFromOrder(MAX_AMBI_ORDER)
41 /* NOTE: These are scale factors as applied to Ambisonics content. Decoder
42 * coefficients should be divided by these values to get proper scalings.
45 static constexpr std::array
<float,MAX_AMBI_CHANNELS
> FromN3D
{{
46 1.0f
, 1.0f
, 1.0f
, 1.0f
, 1.0f
, 1.0f
, 1.0f
, 1.0f
,
47 1.0f
, 1.0f
, 1.0f
, 1.0f
, 1.0f
, 1.0f
, 1.0f
, 1.0f
49 static constexpr std::array
<float,MAX_AMBI_CHANNELS
> FromSN3D
{{
50 1.000000000f
, /* ACN 0, sqrt(1) */
51 1.732050808f
, /* ACN 1, sqrt(3) */
52 1.732050808f
, /* ACN 2, sqrt(3) */
53 1.732050808f
, /* ACN 3, sqrt(3) */
54 2.236067978f
, /* ACN 4, sqrt(5) */
55 2.236067978f
, /* ACN 5, sqrt(5) */
56 2.236067978f
, /* ACN 6, sqrt(5) */
57 2.236067978f
, /* ACN 7, sqrt(5) */
58 2.236067978f
, /* ACN 8, sqrt(5) */
59 2.645751311f
, /* ACN 9, sqrt(7) */
60 2.645751311f
, /* ACN 10, sqrt(7) */
61 2.645751311f
, /* ACN 11, sqrt(7) */
62 2.645751311f
, /* ACN 12, sqrt(7) */
63 2.645751311f
, /* ACN 13, sqrt(7) */
64 2.645751311f
, /* ACN 14, sqrt(7) */
65 2.645751311f
, /* ACN 15, sqrt(7) */
67 static constexpr std::array
<float,MAX_AMBI_CHANNELS
> FromFuMa
{{
68 1.414213562f
, /* ACN 0 (W), sqrt(2) */
69 1.732050808f
, /* ACN 1 (Y), sqrt(3) */
70 1.732050808f
, /* ACN 2 (Z), sqrt(3) */
71 1.732050808f
, /* ACN 3 (X), sqrt(3) */
72 1.936491673f
, /* ACN 4 (V), sqrt(15)/2 */
73 1.936491673f
, /* ACN 5 (T), sqrt(15)/2 */
74 2.236067978f
, /* ACN 6 (R), sqrt(5) */
75 1.936491673f
, /* ACN 7 (S), sqrt(15)/2 */
76 1.936491673f
, /* ACN 8 (U), sqrt(15)/2 */
77 2.091650066f
, /* ACN 9 (Q), sqrt(35/8) */
78 1.972026594f
, /* ACN 10 (O), sqrt(35)/3 */
79 2.231093404f
, /* ACN 11 (M), sqrt(224/45) */
80 2.645751311f
, /* ACN 12 (K), sqrt(7) */
81 2.231093404f
, /* ACN 13 (L), sqrt(224/45) */
82 1.972026594f
, /* ACN 14 (N), sqrt(35)/3 */
83 2.091650066f
, /* ACN 15 (P), sqrt(35/8) */
88 static constexpr std::array
<uint8_t,MAX_AMBI_CHANNELS
> FromFuMa
{{
106 static constexpr std::array
<uint8_t,MAX_AMBI_CHANNELS
> FromACN
{{
107 0, 1, 2, 3, 4, 5, 6, 7,
108 8, 9, 10, 11, 12, 13, 14, 15
111 static constexpr std::array
<uint8_t,MAX_AMBI2D_CHANNELS
> From2D
{{
114 static constexpr std::array
<uint8_t,MAX_AMBI_CHANNELS
> From3D
{{
115 0, 1, 2, 3, 4, 5, 6, 7,
116 8, 9, 10, 11, 12, 13, 14, 15
120 #endif /* AMBIDEFS_H */