7#include "audio_stream_format.hpp"
8#include "speaker_mapping_win32.hpp"
9#include "../macros.hpp"
12hi_export_module(hikogui.audio.audio_stream_format_win32);
14hi_export
namespace hi {
inline namespace v1 {
16hi_export [[
nodiscard]] hi_inline
bool win32_use_extensible(audio_stream_format x)
noexcept{
17 if (to_bool(x.speaker_mapping)) {
51 r.dwChannelMask = speaker_mapping_to_win32(
stream_format.speaker_mapping);
57 auto r = audio_stream_format{};
59 hi_check(
wave_format.Format.wBitsPerSample % 8 == 0,
"wBitsPerSample is not multiple of 8");
60 hi_check(
wave_format.Format.wBitsPerSample > 0,
"wBitsPerSample is 0");
61 hi_check(
wave_format.Format.wBitsPerSample <= 32,
"wBitsPerSample is more than 32");
62 hi_check(
wave_format.Samples.wValidBitsPerSample > 0,
"wValidBitsPerSample is 0");
64 wave_format.Samples.wValidBitsPerSample <=
wave_format.Format.wBitsPerSample,
"wValidBitsPerSample > wBitsPerSample");
65 hi_check(
wave_format.Format.nSamplesPerSec > 0,
"nSamplesPerSec is zero");
69 hi_check(
wave_format.Format.wBitsPerSample == 32,
"wBitsPerSample is not 32");
70 r.format = pcm_format{
true, std::endian::native,
true, 4, 8, 23};
75 r.format = pcm_format{
false, std::endian::native,
true, num_bytes, 0,
num_minor_bits};
77 throw parse_error(
"Unknown SubFormat");
80 hi_check(
wave_format.Format.nChannels > 0,
"nChannels is zero");
83 r.speaker_mapping = speaker_mapping_from_win32(
wave_format.dwChannelMask);
84 hi_check(popcount(r.speaker_mapping) == 0
or popcount(r.speaker_mapping) == r.num_channels,
"nChannels is zero");
91 auto r = audio_stream_format{};
92 hi_check(
wave_format.wBitsPerSample > 0,
"wBitsPerSample is zero");
93 hi_check(
wave_format.wBitsPerSample % 8 == 0,
"wBitsPerSample is not multiple of 8");
94 hi_check(
wave_format.wBitsPerSample <= 32,
"wBitsPerSample greater than 32");
95 hi_check(
wave_format.nSamplesPerSec > 0,
"nSamplesPerSec is zero");
97 hi_check(
wave_format.nChannels > 0,
"nChannels is zero");
101 throw parse_error(std::format(
"WAVEFORMATEXTENSIBLE has incorrect size {}",
wave_format.cbSize));
106 hi_check(
wave_format.wBitsPerSample == 32,
"wBitsPerSample is not 32");
107 r.format = pcm_format{
true, std::endian::native,
true, 4, 8, 23};
112 r.format = pcm_format{
false, std::endian::native,
true, num_bytes, 0,
num_minor_bits};
115 throw parse_error(std::format(
"Unsupported wFormatTag {}",
wave_format.wFormatTag));
120 hi_check(
wave_format.nChannels > 0,
"nChannels is zero");
123 r.speaker_mapping = speaker_mapping::none;
Rules for working with win32 headers.
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
The HikoGUI namespace.
Definition recursive_iterator.hpp:15
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:378