|
Sound Byte Libs 0.5.1-340-gab5b79a
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
|
Conversion at the DMA boundary. More...
Conversion at the DMA boundary.
Typedefs | |
| using | S24RjI32 = int32_t |
One sample in the codec's DMA word format, s24_rj_i32 | |
Functions | |
| void | deinterleave_to_float (const S24RjI32 *interleaved, float *left, float *right, uint16_t frames) |
| Deinterleave stereo codec words into float L/R buffers. | |
| void | interleave_from_float (const float *left, const float *right, S24RjI32 *interleaved, uint16_t frames) |
| Interleave float L/R buffers into stereo codec words. | |
Variables | |
| constexpr float | SAMPLE_SCALE_F = 8388607.0f |
| constexpr float | SAMPLE_SCALE_INV_F = 1.0f / 8388607.0f |
| using sbl::dsp::types::S24RjI32 = typedef int32_t |
One sample in the codec's DMA word format, s24_rj_i32
24-bit two's complement, right-aligned in 32 bits. The SAI leaves the upper byte zero; deinterleave_to_float() sign-extends from bit 23, so a sign-extended word reads the same.
Definition at line 37 of file convert.hpp.
|
inline |
Deinterleave stereo codec words into float L/R buffers.
| interleaved | [L0, R0, L1, R1, ...], two words per frame | |
| [out] | left | Output, one float per frame; full scale is +/-1.0 |
| [out] | right | Output, one float per frame; full scale is +/-1.0 |
| frames | Frame count |
Definition at line 51 of file convert.hpp.
References SAMPLE_SCALE_INV_F.
|
inline |
Interleave float L/R buffers into stereo codec words.
Clamps each sample to [-1.0, 1.0] before conversion.
NaN guard: IEEE 754 NaN fails all comparisons, so the clamp would pass NaN through to static_cast<int32_t>(NaN * SCALE), which is undefined behavior. A NaN sample is replaced with 0 first.
| left | Input, one float per frame, nominally [-1.0, 1.0] | |
| right | Input, one float per frame, nominally [-1.0, 1.0] | |
| [out] | interleaved | Output [L0, R0, L1, R1, ...], two words per frame |
| frames | Frame count |
Definition at line 93 of file convert.hpp.
References SAMPLE_SCALE_F, and SBL_NAN_DETECTED.
|
inlineconstexpr |
24-bit full scale: +/-8,388,607
Definition at line 39 of file convert.hpp.
Referenced by interleave_from_float().
|
inlineconstexpr |
1 / SAMPLE_SCALE_F
Definition at line 40 of file convert.hpp.
Referenced by deinterleave_to_float().