Run-time PCM sample-format converter. More...
#include <algorithm>#include <bit>#include <cmath>#include <cstddef>#include <cstdint>#include <cstring>#include <limits>Go to the source code of this file.
Classes | |
| class | pulp::audio::SampleConverter |
| Run-time PCM converter. More... | |
Namespaces | |
| namespace | pulp |
| namespace | pulp::audio |
| namespace | pulp::audio::detail |
Enumerations | |
| enum class | pulp::audio::SampleFormat : uint8_t { pulp::audio::Int8 , pulp::audio::Int16 , pulp::audio::Int24 , pulp::audio::Int32 , pulp::audio::Float32 , pulp::audio::Float64 } |
| Packed-PCM sample format the bytes are encoded in. More... | |
| enum class | pulp::audio::Endianness : uint8_t { pulp::audio::Little , pulp::audio::Big , pulp::audio::Native } |
| Byte order. More... | |
| enum class | pulp::audio::Layout : uint8_t { pulp::audio::Interleaved , pulp::audio::Planar } |
| Memory layout of the byte stream relative to channels. More... | |
Functions | |
| constexpr std::size_t | pulp::audio::bytes_per_sample (SampleFormat format) noexcept |
| Bytes per sample for format. Returns 0 for unknown values. | |
| constexpr bool | pulp::audio::is_float (SampleFormat format) noexcept |
| True if format is a floating-point format. | |
| constexpr bool | pulp::audio::detail::host_is_little_endian () noexcept |
| Endianness | pulp::audio::detail::resolve_endianness (Endianness e) noexcept |
| template<typename T> | |
| T | pulp::audio::detail::byteswap_int (T value) noexcept |
| template<typename T> | |
| T | pulp::audio::detail::load_int (const uint8_t *src, Endianness src_endian) noexcept |
| template<typename T> | |
| void | pulp::audio::detail::store_int (uint8_t *dst, T value, Endianness dst_endian) noexcept |
| int32_t | pulp::audio::detail::load_int24 (const uint8_t *src, Endianness src_endian) noexcept |
| void | pulp::audio::detail::store_int24 (uint8_t *dst, int32_t value, Endianness dst_endian) noexcept |
| float | pulp::audio::detail::finite_or_zero (float v) noexcept |
Variables | |
| constexpr float | pulp::audio::detail::kInt8Scale = 1.0f / 128.0f |
| constexpr float | pulp::audio::detail::kInt16Scale = 1.0f / 32768.0f |
| constexpr float | pulp::audio::detail::kInt24Scale = 1.0f / 8388608.0f |
| constexpr double | pulp::audio::detail::kInt32Scale = 1.0 / 2147483648.0 |
Run-time PCM sample-format converter.
SampleConverter converts between packed PCM byte streams and planar float channels along three independent axes:
Integer formats round-trip without bit-loss; float ↔ int conversion is within 1 LSB of the reference. The implementation is header-only because core/audio is a real add_library target and the conversion paths are small enough that link-time matters less than inlining.
Design intent: this is the Pulp-native shape for the audio-data converter surface — independent, no name or class mirroring of any reference framework. Callers needing PCM I/O at format boundaries should reach here before rolling per-format helpers.