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