Run-time PCM converter.
More...
#include <sample_converter.hpp>
|
| | SampleConverter (SampleFormat format, Endianness endian=Endianness::Native, Layout layout=Layout::Interleaved) noexcept |
| SampleFormat | format () const noexcept |
| Endianness | endian () const noexcept |
| Layout | layout () const noexcept |
| std::size_t | bytes_per_sample () const noexcept |
| | Bytes occupied per sample (independent of layout / channel count).
|
| std::size_t | bytes_for (std::size_t frames, std::size_t channels) const noexcept |
| | Total byte size for frames * channels PCM samples in the configured layout.
|
| void | to_float (const void *src, float *const *dst_channels, std::size_t frames, std::size_t channels) const noexcept |
| | Convert PCM bytes → planar float channels.
|
| void | to_float_scaled (const void *src, float *const *dst_channels, std::size_t frames, std::size_t channels, float gain) const noexcept |
| | Same as to_float with a per-sample gain multiplier applied during conversion (saves a second pass over the buffer).
|
| void | from_float (const float *const *src_channels, void *dst, std::size_t frames, std::size_t channels) const noexcept |
| | Convert planar float channels → PCM bytes.
|
Run-time PCM converter.
Construct once with a (format, endian, layout) triple; call to_float / from_float per block.
◆ SampleConverter()
◆ bytes_for()
| std::size_t pulp::audio::SampleConverter::bytes_for |
( |
std::size_t | frames, |
|
|
std::size_t | channels ) const |
|
inlinenoexcept |
Total byte size for frames * channels PCM samples in the configured layout.
◆ bytes_per_sample()
| std::size_t pulp::audio::SampleConverter::bytes_per_sample |
( |
| ) |
const |
|
inlinenoexcept |
Bytes occupied per sample (independent of layout / channel count).
◆ endian()
| Endianness pulp::audio::SampleConverter::endian |
( |
| ) |
const |
|
inlinenoexcept |
◆ format()
◆ from_float()
| void pulp::audio::SampleConverter::from_float |
( |
const float *const * | src_channels, |
|
|
void * | dst, |
|
|
std::size_t | frames, |
|
|
std::size_t | channels ) const |
|
inlinenoexcept |
Convert planar float channels → PCM bytes.
Float values are clipped to [-1, +1] before quantization to integer formats; non-finite samples are written as silence (0).
◆ layout()
| Layout pulp::audio::SampleConverter::layout |
( |
| ) |
const |
|
inlinenoexcept |
◆ to_float()
| void pulp::audio::SampleConverter::to_float |
( |
const void * | src, |
|
|
float *const * | dst_channels, |
|
|
std::size_t | frames, |
|
|
std::size_t | channels ) const |
|
inlinenoexcept |
Convert PCM bytes → planar float channels.
- src must contain bytes_for(frames, channels) bytes.
- dst_channels must point to channels arrays of frames floats each. Out-of-range or unknown format is a no-op.
◆ to_float_scaled()
| void pulp::audio::SampleConverter::to_float_scaled |
( |
const void * | src, |
|
|
float *const * | dst_channels, |
|
|
std::size_t | frames, |
|
|
std::size_t | channels, |
|
|
float | gain ) const |
|
inlinenoexcept |
Same as to_float with a per-sample gain multiplier applied during conversion (saves a second pass over the buffer).
The documentation for this class was generated from the following file: