HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Data Fields
hi::v1::audio_sample_format Struct Reference

#include <hikogui/audio/audio_sample_format.hpp>

Public Member Functions

constexpr audio_sample_format (audio_sample_format const &) noexcept=default
 
constexpr audio_sample_format (audio_sample_format &&) noexcept=default
 
constexpr audio_sample_formatoperator= (audio_sample_format const &) noexcept=default
 
constexpr audio_sample_formatoperator= (audio_sample_format &&) noexcept=default
 
constexpr audio_sample_format (uint8_t num_bytes, uint8_t num_guard_bits, uint8_t num_bits, bool is_float, std::endian endian) noexcept
 Constructor of an audio sample format.
 
constexpr operator bool () const noexcept
 
float pack_multiplier () const noexcept
 How much to multiply float samples to create integer samples.
 
float unpack_multiplier () const noexcept
 How much to multiply integer samples to create float samples.
 
std::size_t num_samples_per_chunk (std::size_t stride) const noexcept
 The number of packed samples that are handled in a single 128 bit load or store.
 
std::size_t chunk_stride (std::size_t stride) const noexcept
 The number of bytes to advance to the next chunk to be loaded or stored.
 
std::size_t num_chunks_per_quad (std::size_t stride) const noexcept
 The number of chunks to load or store to handle 4 samples.
 
std::size_t num_fast_quads (std::size_t stride, std::size_t num_samples) const noexcept
 Calculate the number of 4 sample-quads can be handled as chunked loads and stores.
 
i8x16 load_shuffle_indices (std::size_t stride) const noexcept
 Return a shuffle indices for loading samples into 32 bit integers.
 
i8x16 store_shuffle_indices (std::size_t stride) const noexcept
 Return a shuffle indices for storing 32 bit samples into packed samples.
 
i8x16 concat_shuffle_indices (std::size_t stride) const noexcept
 Return a shuffle indices to shift previous loaded samples for concatenation.
 
constexpr bool holds_invariant () const noexcept
 Is the audio sample format valid.
 

Static Public Member Functions

static constexpr audio_sample_format float32_le () noexcept
 
static constexpr audio_sample_format float32_be () noexcept
 
static constexpr audio_sample_format float32 () noexcept
 
static constexpr audio_sample_format int16_le () noexcept
 
static constexpr audio_sample_format int16_be () noexcept
 
static constexpr audio_sample_format int16 () noexcept
 
static constexpr audio_sample_format int20_le () noexcept
 
static constexpr audio_sample_format int20_be () noexcept
 
static constexpr audio_sample_format int20 () noexcept
 
static constexpr audio_sample_format int24_le () noexcept
 
static constexpr audio_sample_format int24_be () noexcept
 
static constexpr audio_sample_format int24 () noexcept
 
static constexpr audio_sample_format int32_le () noexcept
 
static constexpr audio_sample_format int32_be () noexcept
 
static constexpr audio_sample_format int32 () noexcept
 
static constexpr audio_sample_format fix8_23_le () noexcept
 
static constexpr audio_sample_format fix8_23_be () noexcept
 
static constexpr audio_sample_format fix8_23 () noexcept
 

Data Fields

uint8_t num_bytes
 The number of bytes of the container.
 
uint8_t num_guard_bits
 The number of bits used for the integer part of a fixed point number.
 
uint8_t num_bits
 The number of significant bits of the sample format.
 
bool is_float
 The numeric type is floating point.
 
std::endian endian
 The endian order of the bytes in the container.
 

Detailed Description

Audio sample format.

Audio samples described by this type can be in three different formats.

Sample values are aligned to the most significant bits of the container described by num_bytes. The bottom bits are set to zero.

Constructor & Destructor Documentation

◆ audio_sample_format()

constexpr hi::v1::audio_sample_format::audio_sample_format ( uint8_t num_bytes,
uint8_t num_guard_bits,
uint8_t num_bits,
bool is_float,
std::endian endian )
inlineconstexprnoexcept

Constructor of an audio sample format.

Parameters
num_bytesThe number of bytes used for each sample in the stream of data.
num_guard_bitsThe number of bits used beyond -1.0 and 1.0.
num_bitsThe number of bits used to represent a normalized sample between 0.0 and 1.0 (without the sign bit).
is_floatTrue if the sample is float, otherwise integer or fixed point.
endianThe ordering of bytes in each sample

Member Function Documentation

◆ chunk_stride()

std::size_t hi::v1::audio_sample_format::chunk_stride ( std::size_t stride) const
inlinenoexcept

The number of bytes to advance to the next chunk to be loaded or stored.

◆ concat_shuffle_indices()

i8x16 hi::v1::audio_sample_format::concat_shuffle_indices ( std::size_t stride) const
inlinenoexcept

Return a shuffle indices to shift previous loaded samples for concatenation.

◆ holds_invariant()

constexpr bool hi::v1::audio_sample_format::holds_invariant ( ) const
inlineconstexprnoexcept

Is the audio sample format valid.

◆ load_shuffle_indices()

i8x16 hi::v1::audio_sample_format::load_shuffle_indices ( std::size_t stride) const
inlinenoexcept

Return a shuffle indices for loading samples into 32 bit integers.

◆ num_chunks_per_quad()

std::size_t hi::v1::audio_sample_format::num_chunks_per_quad ( std::size_t stride) const
inlinenoexcept

The number of chunks to load or store to handle 4 samples.

◆ num_fast_quads()

std::size_t hi::v1::audio_sample_format::num_fast_quads ( std::size_t stride,
std::size_t num_samples ) const
inlinenoexcept

Calculate the number of 4 sample-quads can be handled as chunked loads and stores.

◆ num_samples_per_chunk()

std::size_t hi::v1::audio_sample_format::num_samples_per_chunk ( std::size_t stride) const
inlinenoexcept

The number of packed samples that are handled in a single 128 bit load or store.

Always one of: 1, 2 or 4.

◆ pack_multiplier()

float hi::v1::audio_sample_format::pack_multiplier ( ) const
inlinenoexcept

How much to multiply float samples to create integer samples.

◆ store_shuffle_indices()

i8x16 hi::v1::audio_sample_format::store_shuffle_indices ( std::size_t stride) const
inlinenoexcept

Return a shuffle indices for storing 32 bit samples into packed samples.

◆ unpack_multiplier()

float hi::v1::audio_sample_format::unpack_multiplier ( ) const
inlinenoexcept

How much to multiply integer samples to create float samples.

Field Documentation

◆ endian

std::endian hi::v1::audio_sample_format::endian

The endian order of the bytes in the container.

◆ is_float

bool hi::v1::audio_sample_format::is_float

The numeric type is floating point.

Otherwise it is a signed integer or fixed point number.

◆ num_bits

uint8_t hi::v1::audio_sample_format::num_bits

The number of significant bits of the sample format.

This value is excluding the sign. (1 << num_bits) - 1 is the maximum sample value.

Examples:

  • 16 bit signed PCM -> num_bits=15
  • 24 bit signed PCM -> num_bits=23
  • float PCM -> num_bits=23
  • Q8.23 PCM -> num_bits=23

◆ num_bytes

uint8_t hi::v1::audio_sample_format::num_bytes

The number of bytes of the container.

Must be either 1, 2, 3 or 4

◆ num_guard_bits

uint8_t hi::v1::audio_sample_format::num_guard_bits

The number of bits used for the integer part of a fixed point number.

This value is zero for signed integer and float samples.


The documentation for this struct was generated from the following file: