HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
audio_sample_format.hpp
1// Copyright Take Vos 2020.
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 "../required.hpp"
8#include "../assert.hpp"
9#include "../cast.hpp"
10#include "../rapid/numeric_array.hpp"
11#include <bit>
12
13namespace tt {
14
34
39
51
56
59 std::endian endian;
60
63 int stride;
64
67 [[nodiscard]] float pack_multiplier() const noexcept;
68
71 [[nodiscard]] float unpack_multiplier() const noexcept;
72
76 [[nodiscard]] int num_samples_per_chunk() const noexcept;
77
80 [[nodiscard]] int chunk_stride() const noexcept;
81
84 [[nodiscard]] int num_chunks_per_quad() const noexcept;
85
88 [[nodiscard]] size_t num_fast_quads(size_t num_samples) const noexcept;
89
90
93 [[nodiscard]] i8x16 load_shuffle_indices() const noexcept;
94
97 [[nodiscard]] i8x16 store_shuffle_indices() const noexcept;
98
101 [[nodiscard]] i8x16 concat_shuffle_indices() const noexcept;
102
105 [[nodiscard]] bool is_valid() const noexcept;
106};
107
108} // namespace tt
Audio sample format.
Definition audio_sample_format.hpp:29
std::endian endian
The endian order of the bytes in the container.
Definition audio_sample_format.hpp:59
int num_chunks_per_quad() const noexcept
The number of chunks to load or store to handle 4 samples.
bool is_float
The numeric type is floating point.
Definition audio_sample_format.hpp:55
i8x16 store_shuffle_indices() const noexcept
Return a shuffle indices for storing 32 bit samples into packed samples.
int num_bits
The number of significant bits of the sample format.
Definition audio_sample_format.hpp:50
int stride
The number of bytes to step to the next sample of the same channel.
Definition audio_sample_format.hpp:63
float unpack_multiplier() const noexcept
How much to multiply integer samples to create float samples.
i8x16 load_shuffle_indices() const noexcept
Return a shuffle indices for loading samples into 32 bit integers.
float pack_multiplier() const noexcept
How much to multiply float samples to create integer samples.
i8x16 concat_shuffle_indices() const noexcept
Return a shuffle indices to shift previous loaded samples for concatenation.
int num_bytes
The number of bytes of the container.
Definition audio_sample_format.hpp:33
size_t num_fast_quads(size_t num_samples) const noexcept
Calculate the number of 4 sample-quads can be handled as chunked loads and stores.
bool is_valid() const noexcept
Is the audio sample format valid.
int chunk_stride() const noexcept
The number of bytes to advance to the next chunk to be loaded or stored.
int num_guard_bits
The number of bits used for the integer part of a fixed point number.
Definition audio_sample_format.hpp:38
int num_samples_per_chunk() const noexcept
The number of packed samples that are handled in a single 128 bit load or store.