7#include "../utility/module.hpp"
8#include "../pickle.hpp"
9#include "../font/module.hpp"
14namespace hi::inline
v1 {
16enum class speaker_mapping : uint32_t {
18 front_left = 0x0'0001,
19 front_right = 0x0'0002,
20 front_center = 0x0'0004,
21 low_frequency = 0x0'0008,
23 back_right = 0x0'0020,
24 front_left_of_center = 0x0'0040,
25 front_right_of_center = 0x0'0080,
26 back_center = 0x0'0100,
28 side_right = 0x0'0400,
29 top_center = 0x0'0800,
30 top_front_left = 0x0'1000,
31 top_front_center = 0x0'2000,
32 top_front_right = 0x0'4000,
33 top_back_left = 0x0'8000,
34 top_back_center = 0x1'0000,
35 top_back_right = 0x2'0000,
38 mono_1_0 = front_center,
39 stereo_2_0 = front_left | front_right,
42 stereo_2_1 = stereo_2_0 | low_frequency,
43 stereo_3_0 = stereo_2_0 | front_center,
44 stereo_3_1 = stereo_3_0 | low_frequency,
45 quad_4_0 = stereo_2_0 | back_left | back_right,
46 quad_side_4_0 = stereo_2_0 | side_left | side_right,
47 hexagonal_6_0 = quad_4_0 | front_center | back_center,
48 hexagonal_6_1 = hexagonal_6_0 | low_frequency,
49 octagonal_8_0 = hexagonal_6_0 | side_left | side_right,
52 surround_3_0 = stereo_2_0 | back_center,
53 surround_4_0 = surround_3_0 | front_center,
54 surround_4_1 = surround_4_0 | low_frequency,
55 surround_5_0 = quad_4_0 | front_center,
56 surround_5_1 = surround_5_0 | low_frequency,
57 surround_7_0 = surround_5_0 | side_left | side_right,
58 surround_7_1 = surround_7_0 | low_frequency,
59 surround_9_0 = surround_7_0 | top_front_left | top_front_right,
60 surround_9_1 = surround_9_0 | low_frequency,
61 surround_11_0 = surround_9_0 | front_left_of_center | front_right_of_center,
62 surround_11_1 = surround_11_0 | low_frequency,
65 surround_side_5_0 = quad_side_4_0 | front_center,
66 surround_side_5_1 = surround_side_5_0 | low_frequency,
67 surround_side_6_0 = surround_side_5_0 | back_center,
68 surround_side_6_1 = surround_side_6_0 | low_frequency,
69 surround_side_7_0 = surround_side_5_0 | front_left_of_center | front_right_of_center,
70 surround_side_7_1 = surround_side_7_0 | low_frequency,
73 surround_wide_6_0 = surround_4_0 | front_left_of_center | front_right_of_center,
74 surround_wide_6_1 = surround_wide_6_0 | low_frequency,
75 surround_wide_7_0 = surround_5_0 | front_left_of_center | front_right_of_center,
76 surround_wide_7_1 = surround_wide_7_0 | low_frequency,
79 surround_atmos_5_1_4 = surround_5_1 | top_front_left | top_front_right | top_back_left | top_back_right,
80 surround_atmos_7_1_4 = surround_7_1 | top_front_left | top_front_right | top_back_left | top_back_right,
83[[nodiscard]]
constexpr bool to_bool(speaker_mapping
const& rhs)
noexcept
85 return to_bool(to_underlying(rhs));
88[[nodiscard]]
constexpr unsigned int popcount(speaker_mapping
const &rhs)
noexcept
90 return std::popcount(to_underlying(rhs));
93[[nodiscard]]
constexpr speaker_mapping operator|(speaker_mapping
const &lhs, speaker_mapping
const &rhs)
noexcept
95 return static_cast<speaker_mapping
>(to_underlying(lhs) | to_underlying(rhs));
98[[nodiscard]]
constexpr speaker_mapping operator&(speaker_mapping
const& lhs, speaker_mapping
const& rhs)
noexcept
100 return static_cast<speaker_mapping
>(to_underlying(lhs) & to_underlying(rhs));
103constexpr speaker_mapping &operator|=(speaker_mapping &lhs, speaker_mapping
const &rhs)
noexcept
105 return lhs = lhs | rhs;
108constexpr speaker_mapping &operator&=(speaker_mapping &lhs, speaker_mapping
const &rhs)
noexcept
110 return lhs = lhs & rhs;
115 [[nodiscard]]
datum encode(speaker_mapping
const &rhs)
const noexcept
117 return datum{narrow_cast<long long>(to_underlying(rhs))};
120 [[nodiscard]] speaker_mapping decode(
long long rhs)
const
122 hi_check(rhs >= 0,
"Expect speaker mapping to be encoded as a natural number, got {}.", rhs);
123 return static_cast<speaker_mapping
>(rhs);
126 [[nodiscard]] speaker_mapping decode(
datum const &rhs)
const
128 if (
auto *i = get_if<long long>(&rhs)) {
131 throw parse_error(std::format(
"Expect speaker mapping to be encoded as a integer, got {}", rhs));
#define hi_check(expression, message,...)
Check if the expression is valid, or throw a parse_error.
Definition assert.hpp:110
constexpr std::string to_string(std::u32string_view rhs) noexcept
Conversion from UTF-32 to UTF-8.
Definition to_string.hpp:215
DOXYGEN BUG.
Definition algorithm.hpp:13
A dynamic data type.
Definition datum.hpp:219
Encode and decode a type to and from a UTF-8 string.
Definition pickle.hpp:21