7#include "../utility/utility.hpp"
8#include "../macros.hpp"
14hi_export_module(hikogui.audio.pcm_format);
16hi_export
namespace hi {
inline namespace v1 {
29 if (
auto const tmp = lhs._floating_point <=> rhs._floating_point;
tmp != std::strong_ordering::equal) {
32 if (
auto const tmp = lhs._num_major_bits <=> rhs._num_major_bits;
tmp != std::strong_ordering::equal) {
35 if (
auto const tmp = lhs._num_minor_bits <=> rhs._num_minor_bits;
tmp != std::strong_ordering::equal) {
38 if (
auto const tmp = lhs._num_bytes <=> rhs._num_bytes;
tmp != std::strong_ordering::equal) {
41 if (
auto const tmp = lhs._lsb <=> rhs._lsb;
tmp != std::strong_ordering::equal) {
44 return lhs._lsb <=> rhs._lsb;
49 return lhs._floating_point == rhs._floating_point;
71 _floating_point(floating_point),
72 _little_endian(endian == std::endian::little),
85 return pcm_format{
true, std::endian::native,
true, 4, 8, 23};
90 return pcm_format{
true, std::endian::little,
true, 4, 8, 23};
95 return pcm_format{
true, std::endian::big,
true, 4, 8, 23};
100 return pcm_format{
false, std::endian::native,
true, 3, 0, 23};
105 return pcm_format{
false, std::endian::little,
true, 3, 0, 23};
110 return pcm_format{
false, std::endian::big,
true, 3, 0, 23};
115 return pcm_format{
false, std::endian::native,
true, 2, 0, 15};
120 return pcm_format{
false, std::endian::little,
true, 2, 0, 15};
125 return pcm_format{
false, std::endian::big,
true, 2, 0, 15};
130 return _num_minor_bits == 0;
140 hi_axiom(
not empty());
141 return _floating_point;
146 hi_axiom(
not empty());
147 return not floating_point();
152 hi_axiom(
not empty());
153 return _little_endian ? std::endian::little : std::endian::big;
162 hi_axiom(
not empty());
170 hi_axiom(
not empty());
178 hi_axiom(
not empty());
192 hi_axiom(
not empty());
207 hi_axiom(floating_point());
208 return _num_major_bits;
220 hi_axiom(floating_point());
221 return _num_minor_bits;
237 hi_axiom(fixed_point());
238 return _num_major_bits;
254 hi_axiom(fixed_point());
255 return _num_minor_bits;
260 if (rhs.floating_point()) {
261 if (rhs.endian() == std::endian::native) {
262 return std::format(
"float-{}", rhs.
num_bits());
264 return std::format(
"float-{}_{}", rhs.
num_bits(), rhs.endian() == std::endian::little ?
"le" :
"be");
268 if (rhs.endian() == std::endian::native) {
269 return std::format(
"int-{}", rhs.
num_bits());
271 return std::format(
"int-{}_{}", rhs.
num_bits(), rhs.endian() == std::endian::little ?
"le" :
"be");
275 if (rhs.endian() == std::endian::native) {
282 rhs.endian() == std::endian::little ?
"le" :
"be");
288 uint16_t _floating_point : 1 = 0;
289 uint16_t _little_endian : 1 = 0;
290 uint16_t _lsb : 1 = 0;
291 uint16_t _num_bytes : 3 = 0;
292 uint16_t _num_major_bits : 4 = 0;
293 uint16_t _num_minor_bits : 6 = 0;
300struct std::formatter<
hi::pcm_format, char> : std::formatter<std::string_view, char> {
303 return std::formatter<std::string_view, char>::format(
to_string(t), fc);
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
Definition pcm_format.hpp:18
uint8_t num_exponent_bits() const noexcept
The number of bits in the exponent.
Definition pcm_format.hpp:205
constexpr bool msb() const noexcept
The sample is stored in the most-significant-bits of the storage.
Definition pcm_format.hpp:176
uint8_t num_bits() const noexcept
The number of least significant bits of the storage that is used by the sample.
Definition pcm_format.hpp:190
uint8_t num_fraction_bits() const noexcept
The number of fractional bits.
Definition pcm_format.hpp:252
constexpr bool lsb() const noexcept
The sample is stored in the least-significant-bits of the storage.
Definition pcm_format.hpp:168
uint8_t num_mantissa_bits() const noexcept
The number of bits in the mantissa.
Definition pcm_format.hpp:218
uint8_t num_bytes() const noexcept
The number of bytes a sample is stored in.
Definition pcm_format.hpp:160
constexpr pcm_format(bool floating_point, std::endian endian, bool lsb, uint8_t num_bytes, uint8_t num_major_bits, uint8_t num_minor_bits) noexcept
Construct a PCM format.
Definition pcm_format.hpp:64
uint8_t num_integral_bits() const noexcept
The number of integral bits.
Definition pcm_format.hpp:235