7#include "speaker_mapping.hpp"
8#include "../macros.hpp"
10hi_export_module(hikogui.audio.speaker_mapping_win32);
12hi_export
namespace hi {
inline namespace v1 {
14hi_export [[nodiscard]]
inline speaker_mapping speaker_mapping_from_win32(DWORD from){
15 auto r = speaker_mapping{0};
17 constexpr DWORD valid_mask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY |
18 SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT | SPEAKER_FRONT_LEFT_OF_CENTER | SPEAKER_FRONT_RIGHT_OF_CENTER |
19 SPEAKER_BACK_CENTER | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT | SPEAKER_TOP_CENTER | SPEAKER_TOP_FRONT_LEFT |
20 SPEAKER_TOP_FRONT_CENTER | SPEAKER_TOP_FRONT_RIGHT | SPEAKER_TOP_BACK_LEFT | SPEAKER_TOP_BACK_CENTER |
21 SPEAKER_TOP_BACK_RIGHT;
23 hi_check((from & ~valid_mask) == 0,
"Unknown speaker locations");
25 if (from & SPEAKER_FRONT_LEFT) {
26 r |= speaker_mapping::front_left;
28 if (from & SPEAKER_FRONT_RIGHT) {
29 r |= speaker_mapping::front_right;
31 if (from & SPEAKER_FRONT_CENTER) {
32 r |= speaker_mapping::front_center;
34 if (from & SPEAKER_LOW_FREQUENCY) {
35 r |= speaker_mapping::low_frequency;
37 if (from & SPEAKER_BACK_LEFT) {
38 r |= speaker_mapping::back_left;
40 if (from & SPEAKER_BACK_RIGHT) {
41 r |= speaker_mapping::back_right;
43 if (from & SPEAKER_FRONT_LEFT_OF_CENTER) {
44 r |= speaker_mapping::front_left_of_center;
46 if (from & SPEAKER_FRONT_RIGHT_OF_CENTER) {
47 r |= speaker_mapping::front_right_of_center;
49 if (from & SPEAKER_BACK_CENTER) {
50 r |= speaker_mapping::back_center;
52 if (from & SPEAKER_SIDE_LEFT) {
53 r |= speaker_mapping::side_left;
55 if (from & SPEAKER_SIDE_RIGHT) {
56 r |= speaker_mapping::side_right;
58 if (from & SPEAKER_TOP_CENTER) {
59 r |= speaker_mapping::top_center;
61 if (from & SPEAKER_TOP_FRONT_LEFT) {
62 r |= speaker_mapping::top_front_left;
64 if (from & SPEAKER_TOP_FRONT_CENTER) {
65 r |= speaker_mapping::top_front_center;
67 if (from & SPEAKER_TOP_FRONT_RIGHT) {
68 r |= speaker_mapping::top_front_right;
70 if (from & SPEAKER_TOP_BACK_LEFT) {
71 r |= speaker_mapping::top_back_left;
73 if (from & SPEAKER_TOP_BACK_CENTER) {
74 r |= speaker_mapping::top_back_center;
76 if (from & SPEAKER_TOP_BACK_RIGHT) {
77 r |= speaker_mapping::top_back_right;
83hi_export [[nodiscard]]
inline DWORD speaker_mapping_to_win32(speaker_mapping from)
noexcept{
86 if (to_bool(from & speaker_mapping::front_left)) {
87 r |= SPEAKER_FRONT_LEFT;
89 if (to_bool(from & speaker_mapping::front_right)) {
90 r |= SPEAKER_FRONT_RIGHT;
92 if (to_bool(from & speaker_mapping::front_center)) {
93 r |= SPEAKER_FRONT_CENTER;
95 if (to_bool(from & speaker_mapping::low_frequency)) {
96 r |= SPEAKER_LOW_FREQUENCY;
98 if (to_bool(from & speaker_mapping::back_left)) {
99 r |= SPEAKER_BACK_LEFT;
101 if (to_bool(from & speaker_mapping::back_right)) {
102 r |= SPEAKER_BACK_RIGHT;
104 if (to_bool(from & speaker_mapping::front_left_of_center)) {
105 r |= SPEAKER_FRONT_LEFT_OF_CENTER;
107 if (to_bool(from & speaker_mapping::front_right_of_center)) {
108 r |= SPEAKER_FRONT_RIGHT_OF_CENTER;
110 if (to_bool(from & speaker_mapping::back_center)) {
111 r |= SPEAKER_BACK_CENTER;
113 if (to_bool(from & speaker_mapping::side_left)) {
114 r |= SPEAKER_SIDE_LEFT;
116 if (to_bool(from & speaker_mapping::side_right)) {
117 r |= SPEAKER_SIDE_RIGHT;
119 if (to_bool(from & speaker_mapping::top_center)) {
120 r |= SPEAKER_TOP_CENTER;
122 if (to_bool(from & speaker_mapping::top_front_left)) {
123 r |= SPEAKER_TOP_FRONT_LEFT;
125 if (to_bool(from & speaker_mapping::top_front_center)) {
126 r |= SPEAKER_TOP_FRONT_CENTER;
128 if (to_bool(from & speaker_mapping::top_front_right)) {
129 r |= SPEAKER_TOP_FRONT_RIGHT;
131 if (to_bool(from & speaker_mapping::top_back_left)) {
132 r |= SPEAKER_TOP_BACK_LEFT;
134 if (to_bool(from & speaker_mapping::top_back_center)) {
135 r |= SPEAKER_TOP_BACK_CENTER;
137 if (to_bool(from & speaker_mapping::top_back_right)) {
138 r |= SPEAKER_TOP_BACK_RIGHT;
The HikoGUI namespace.
Definition array_generic.hpp:20
DOXYGEN BUG.
Definition algorithm_misc.hpp:20