7#include "../utility/utility.hpp"
8#include "../codec/codec.hpp"
9#include "../font/font.hpp"
10#include "../macros.hpp"
15hi_export_module(hikogui.audio.speaker_mapping);
17hi_export
namespace hi {
inline namespace v1 {
19hi_export
enum class speaker_mapping : uint32_t {
21 front_left = 0x0'0001,
22 front_right = 0x0'0002,
23 front_center = 0x0'0004,
24 low_frequency = 0x0'0008,
26 back_right = 0x0'0020,
27 front_left_of_center = 0x0'0040,
28 front_right_of_center = 0x0'0080,
29 back_center = 0x0'0100,
31 side_right = 0x0'0400,
32 top_center = 0x0'0800,
33 top_front_left = 0x0'1000,
34 top_front_center = 0x0'2000,
35 top_front_right = 0x0'4000,
36 top_back_left = 0x0'8000,
37 top_back_center = 0x1'0000,
38 top_back_right = 0x2'0000,
41 mono_1_0 = front_center,
42 stereo_2_0 = front_left | front_right,
45 stereo_2_1 = stereo_2_0 | low_frequency,
46 stereo_3_0 = stereo_2_0 | front_center,
47 stereo_3_1 = stereo_3_0 | low_frequency,
48 quad_4_0 = stereo_2_0 | back_left | back_right,
49 quad_side_4_0 = stereo_2_0 | side_left | side_right,
50 hexagonal_6_0 = quad_4_0 | front_center | back_center,
51 hexagonal_6_1 = hexagonal_6_0 | low_frequency,
52 octagonal_8_0 = hexagonal_6_0 | side_left | side_right,
55 surround_3_0 = stereo_2_0 | back_center,
56 surround_4_0 = surround_3_0 | front_center,
57 surround_4_1 = surround_4_0 | low_frequency,
58 surround_5_0 = quad_4_0 | front_center,
59 surround_5_1 = surround_5_0 | low_frequency,
60 surround_7_0 = surround_5_0 | side_left | side_right,
61 surround_7_1 = surround_7_0 | low_frequency,
62 surround_9_0 = surround_7_0 | top_front_left | top_front_right,
63 surround_9_1 = surround_9_0 | low_frequency,
64 surround_11_0 = surround_9_0 | front_left_of_center | front_right_of_center,
65 surround_11_1 = surround_11_0 | low_frequency,
68 surround_side_5_0 = quad_side_4_0 | front_center,
69 surround_side_5_1 = surround_side_5_0 | low_frequency,
70 surround_side_6_0 = surround_side_5_0 | back_center,
71 surround_side_6_1 = surround_side_6_0 | low_frequency,
72 surround_side_7_0 = surround_side_5_0 | front_left_of_center | front_right_of_center,
73 surround_side_7_1 = surround_side_7_0 | low_frequency,
76 surround_wide_6_0 = surround_4_0 | front_left_of_center | front_right_of_center,
77 surround_wide_6_1 = surround_wide_6_0 | low_frequency,
78 surround_wide_7_0 = surround_5_0 | front_left_of_center | front_right_of_center,
79 surround_wide_7_1 = surround_wide_7_0 | low_frequency,
82 surround_atmos_5_1_4 = surround_5_1 | top_front_left | top_front_right | top_back_left | top_back_right,
83 surround_atmos_7_1_4 = surround_7_1 | top_front_left | top_front_right | top_back_left | top_back_right,
86hi_export [[nodiscard]]
constexpr bool to_bool(speaker_mapping
const& rhs)
noexcept
88 return to_bool(std::to_underlying(rhs));
91hi_export [[nodiscard]]
constexpr unsigned int popcount(speaker_mapping
const &rhs)
noexcept
93 return std::popcount(std::to_underlying(rhs));
96hi_export [[nodiscard]]
constexpr speaker_mapping operator|(speaker_mapping
const &lhs, speaker_mapping
const &rhs)
noexcept
98 return static_cast<speaker_mapping
>(std::to_underlying(lhs) | std::to_underlying(rhs));
101hi_export [[nodiscard]]
constexpr speaker_mapping operator&(speaker_mapping
const& lhs, speaker_mapping
const& rhs)
noexcept
103 return static_cast<speaker_mapping
>(std::to_underlying(lhs) & std::to_underlying(rhs));
106hi_export
constexpr speaker_mapping &operator|=(speaker_mapping &lhs, speaker_mapping
const &rhs)
noexcept
108 return lhs = lhs | rhs;
111hi_export
constexpr speaker_mapping &operator&=(speaker_mapping &lhs, speaker_mapping
const &rhs)
noexcept
113 return lhs = lhs & rhs;
118 [[nodiscard]]
datum encode(speaker_mapping
const &rhs)
const noexcept
120 return datum{narrow_cast<long long>(std::to_underlying(rhs))};
123 [[nodiscard]] speaker_mapping
decode(
long long rhs)
const
125 hi_check(rhs >= 0,
"Expect speaker mapping to be encoded as a natural number, got {}.", rhs);
126 return static_cast<speaker_mapping
>(rhs);
129 [[nodiscard]] speaker_mapping
decode(
datum const &rhs)
const
131 if (
auto *i = get_if<long long>(rhs)) {
134 throw parse_error(std::format(
"Expect speaker mapping to be encoded as a integer, got {}", rhs));
139hi_export [[nodiscard]]
inline std::string to_string(speaker_mapping rhs)
noexcept{
142 if (to_bool(rhs & speaker_mapping::front_left)) {
145 if (to_bool(rhs & speaker_mapping::front_right)) {
148 if (to_bool(rhs & speaker_mapping::front_center)) {
151 if (to_bool(rhs & speaker_mapping::low_frequency)) {
154 if (to_bool(rhs & speaker_mapping::back_left)) {
157 if (to_bool(rhs & speaker_mapping::back_right)) {
160 if (to_bool(rhs & speaker_mapping::front_left_of_center)) {
163 if (to_bool(rhs & speaker_mapping::front_right_of_center)) {
166 if (to_bool(rhs & speaker_mapping::back_center)) {
169 if (to_bool(rhs & speaker_mapping::side_left)) {
172 if (to_bool(rhs & speaker_mapping::side_right)) {
175 if (to_bool(rhs & speaker_mapping::top_center)) {
178 if (to_bool(rhs & speaker_mapping::top_front_left)) {
181 if (to_bool(rhs & speaker_mapping::top_front_center)) {
184 if (to_bool(rhs & speaker_mapping::top_front_right)) {
187 if (to_bool(rhs & speaker_mapping::top_back_left)) {
190 if (to_bool(rhs & speaker_mapping::top_back_center)) {
193 if (to_bool(rhs & speaker_mapping::top_back_right)) {
The HikoGUI namespace.
Definition array_generic.hpp:20
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
A dynamic data type.
Definition datum.hpp:198
Encode and decode a type to and from a UTF-8 string.
Definition pickle.hpp:24
T decode(datum rhs) const
Decode a UTF-8 string into a value of a given type.
Definition pickle.hpp:48
datum encode(T const &rhs) const noexcept
Encode the value of a type into a UTF-8 string.
Definition pickle.hpp:30
Exception thrown during parsing on an error.
Definition exception_intf.hpp:48