HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
speaker_mapping_win32.hpp
1// Copyright Take Vos 2021.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "speaker_mapping.hpp"
8#include "../macros.hpp"
9
10hi_export_module(hikogui.audio.speaker_mapping_win32);
11
12hi_export namespace hi { inline namespace v1 {
13
14hi_export [[nodiscard]] inline speaker_mapping speaker_mapping_from_win32(DWORD from){
15 auto r = speaker_mapping{0};
16
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;
22
23 hi_check((from & ~valid_mask) == 0, "Unknown speaker locations");
24
25 if (from & SPEAKER_FRONT_LEFT) {
26 r |= speaker_mapping::front_left;
27 }
28 if (from & SPEAKER_FRONT_RIGHT) {
29 r |= speaker_mapping::front_right;
30 }
31 if (from & SPEAKER_FRONT_CENTER) {
32 r |= speaker_mapping::front_center;
33 }
34 if (from & SPEAKER_LOW_FREQUENCY) {
35 r |= speaker_mapping::low_frequency;
36 }
37 if (from & SPEAKER_BACK_LEFT) {
38 r |= speaker_mapping::back_left;
39 }
40 if (from & SPEAKER_BACK_RIGHT) {
41 r |= speaker_mapping::back_right;
42 }
43 if (from & SPEAKER_FRONT_LEFT_OF_CENTER) {
44 r |= speaker_mapping::front_left_of_center;
45 }
46 if (from & SPEAKER_FRONT_RIGHT_OF_CENTER) {
47 r |= speaker_mapping::front_right_of_center;
48 }
49 if (from & SPEAKER_BACK_CENTER) {
50 r |= speaker_mapping::back_center;
51 }
52 if (from & SPEAKER_SIDE_LEFT) {
53 r |= speaker_mapping::side_left;
54 }
55 if (from & SPEAKER_SIDE_RIGHT) {
56 r |= speaker_mapping::side_right;
57 }
58 if (from & SPEAKER_TOP_CENTER) {
59 r |= speaker_mapping::top_center;
60 }
61 if (from & SPEAKER_TOP_FRONT_LEFT) {
62 r |= speaker_mapping::top_front_left;
63 }
64 if (from & SPEAKER_TOP_FRONT_CENTER) {
65 r |= speaker_mapping::top_front_center;
66 }
67 if (from & SPEAKER_TOP_FRONT_RIGHT) {
68 r |= speaker_mapping::top_front_right;
69 }
70 if (from & SPEAKER_TOP_BACK_LEFT) {
71 r |= speaker_mapping::top_back_left;
72 }
73 if (from & SPEAKER_TOP_BACK_CENTER) {
74 r |= speaker_mapping::top_back_center;
75 }
76 if (from & SPEAKER_TOP_BACK_RIGHT) {
77 r |= speaker_mapping::top_back_right;
78 }
79
80 return r;
81}
82
83hi_export [[nodiscard]] inline DWORD speaker_mapping_to_win32(speaker_mapping from) noexcept{
84 auto r = DWORD{0};
85
86 if (to_bool(from & speaker_mapping::front_left)) {
87 r |= SPEAKER_FRONT_LEFT;
88 }
89 if (to_bool(from & speaker_mapping::front_right)) {
90 r |= SPEAKER_FRONT_RIGHT;
91 }
92 if (to_bool(from & speaker_mapping::front_center)) {
93 r |= SPEAKER_FRONT_CENTER;
94 }
95 if (to_bool(from & speaker_mapping::low_frequency)) {
96 r |= SPEAKER_LOW_FREQUENCY;
97 }
98 if (to_bool(from & speaker_mapping::back_left)) {
99 r |= SPEAKER_BACK_LEFT;
100 }
101 if (to_bool(from & speaker_mapping::back_right)) {
102 r |= SPEAKER_BACK_RIGHT;
103 }
104 if (to_bool(from & speaker_mapping::front_left_of_center)) {
105 r |= SPEAKER_FRONT_LEFT_OF_CENTER;
106 }
107 if (to_bool(from & speaker_mapping::front_right_of_center)) {
108 r |= SPEAKER_FRONT_RIGHT_OF_CENTER;
109 }
110 if (to_bool(from & speaker_mapping::back_center)) {
111 r |= SPEAKER_BACK_CENTER;
112 }
113 if (to_bool(from & speaker_mapping::side_left)) {
114 r |= SPEAKER_SIDE_LEFT;
115 }
116 if (to_bool(from & speaker_mapping::side_right)) {
117 r |= SPEAKER_SIDE_RIGHT;
118 }
119 if (to_bool(from & speaker_mapping::top_center)) {
120 r |= SPEAKER_TOP_CENTER;
121 }
122 if (to_bool(from & speaker_mapping::top_front_left)) {
123 r |= SPEAKER_TOP_FRONT_LEFT;
124 }
125 if (to_bool(from & speaker_mapping::top_front_center)) {
126 r |= SPEAKER_TOP_FRONT_CENTER;
127 }
128 if (to_bool(from & speaker_mapping::top_front_right)) {
129 r |= SPEAKER_TOP_FRONT_RIGHT;
130 }
131 if (to_bool(from & speaker_mapping::top_back_left)) {
132 r |= SPEAKER_TOP_BACK_LEFT;
133 }
134 if (to_bool(from & speaker_mapping::top_back_center)) {
135 r |= SPEAKER_TOP_BACK_CENTER;
136 }
137 if (to_bool(from & speaker_mapping::top_back_right)) {
138 r |= SPEAKER_TOP_BACK_RIGHT;
139 }
140
141 return r;
142}
143
144
145}} // namespace hi::inline v1
The HikoGUI namespace.
Definition array_generic.hpp:20
DOXYGEN BUG.
Definition algorithm_misc.hpp:20