7#include "../assert.hpp"
9#include "../pickle.hpp"
10#include "../text/hikogui_icon.hpp"
15namespace hi::inline
v1 {
17enum class speaker_mapping : uint32_t {
19 front_left = 0x0'0001,
20 front_right = 0x0'0002,
21 front_center = 0x0'0004,
22 low_frequency = 0x0'0008,
24 back_right = 0x0'0020,
25 front_left_of_center = 0x0'0040,
26 front_right_of_center = 0x0'0080,
27 back_center = 0x0'0100,
29 side_right = 0x0'0400,
30 top_center = 0x0'0800,
31 top_front_left = 0x0'1000,
32 top_front_center = 0x0'2000,
33 top_front_right = 0x0'4000,
34 top_back_left = 0x0'8000,
35 top_back_center = 0x1'0000,
36 top_back_right = 0x2'0000,
39 mono_1_0 = front_center,
40 stereo_2_0 = front_left | front_right,
43 stereo_2_1 = stereo_2_0 | low_frequency,
44 stereo_3_0 = stereo_2_0 | front_center,
45 stereo_3_1 = stereo_3_0 | low_frequency,
46 quad_4_0 = stereo_2_0 | back_left | back_right,
47 quad_side_4_0 = stereo_2_0 | side_left | side_right,
48 hexagonal_6_0 = quad_4_0 | front_center | back_center,
49 hexagonal_6_1 = hexagonal_6_0 | low_frequency,
50 octagonal_8_0 = hexagonal_6_0 | side_left | side_right,
53 surround_3_0 = stereo_2_0 | back_center,
54 surround_4_0 = surround_3_0 | front_center,
55 surround_4_1 = surround_4_0 | low_frequency,
56 surround_5_0 = quad_4_0 | front_center,
57 surround_5_1 = surround_5_0 | low_frequency,
58 surround_7_0 = surround_5_0 | side_left | side_right,
59 surround_7_1 = surround_7_0 | low_frequency,
60 surround_9_0 = surround_7_0 | top_front_left | top_front_right,
61 surround_9_1 = surround_9_0 | low_frequency,
62 surround_11_0 = surround_9_0 | front_left_of_center | front_right_of_center,
63 surround_11_1 = surround_11_0 | low_frequency,
66 surround_side_5_0 = quad_side_4_0 | front_center,
67 surround_side_5_1 = surround_side_5_0 | low_frequency,
68 surround_side_6_0 = surround_side_5_0 | back_center,
69 surround_side_6_1 = surround_side_6_0 | low_frequency,
70 surround_side_7_0 = surround_side_5_0 | front_left_of_center | front_right_of_center,
71 surround_side_7_1 = surround_side_7_0 | low_frequency,
74 surround_wide_6_0 = surround_4_0 | front_left_of_center | front_right_of_center,
75 surround_wide_6_1 = surround_wide_6_0 | low_frequency,
76 surround_wide_7_0 = surround_5_0 | front_left_of_center | front_right_of_center,
77 surround_wide_7_1 = surround_wide_7_0 | low_frequency,
80 surround_atmos_5_1_4 = surround_5_1 | top_front_left | top_front_right | top_back_left | top_back_right,
81 surround_atmos_7_1_4 = surround_7_1 | top_front_left | top_front_right | top_back_left | top_back_right,
84[[nodiscard]]
constexpr bool any(speaker_mapping
const &rhs)
noexcept
86 return to_bool(to_underlying(rhs));
89[[nodiscard]]
constexpr unsigned int popcount(speaker_mapping
const &rhs)
noexcept
91 return std::popcount(to_underlying(rhs));
94[[nodiscard]]
constexpr speaker_mapping
operator|(speaker_mapping
const &lhs, speaker_mapping
const &rhs)
noexcept
96 return static_cast<speaker_mapping
>(to_underlying(lhs) | to_underlying(rhs));
99[[nodiscard]]
constexpr speaker_mapping operator&(speaker_mapping
const& lhs, speaker_mapping
const& rhs)
noexcept
101 return static_cast<speaker_mapping
>(to_underlying(lhs) & to_underlying(rhs));
104constexpr speaker_mapping &operator|=(speaker_mapping &lhs, speaker_mapping
const &rhs)
noexcept
106 return lhs = lhs | rhs;
109constexpr speaker_mapping &operator&=(speaker_mapping &lhs, speaker_mapping
const &rhs)
noexcept
111 return lhs = lhs & rhs;
116 [[nodiscard]]
datum encode(speaker_mapping
const &rhs)
const noexcept
118 return datum{narrow_cast<long long>(to_underlying(rhs))};
121 [[nodiscard]] speaker_mapping decode(
long long rhs)
const
123 hi_parse_check(rhs >= 0,
"Expect speaker mapping to be encoded as a natural number, got {}.", rhs);
124 return static_cast<speaker_mapping
>(rhs);
127 [[nodiscard]] speaker_mapping decode(
datum const &rhs)
const
129 if (
auto *i = get_if<long long>(rhs)) {
132 throw parse_error(std::format(
"Expect speaker mapping to be encoded as a integer, got {}", rhs));
137[[nodiscard]]
std::string to_string(speaker_mapping rhs)
noexcept;
DOXYGEN BUG.
Definition algorithm.hpp:15
constexpr alignment operator|(horizontal_alignment lhs, vertical_alignment rhs) noexcept
Combine vertical and horizontal alignment.
Definition alignment.hpp:200
A dynamic data type.
Definition datum.hpp:224
Encode and decode a type to and from a UTF-8 string.
Definition pickle.hpp:23