9#ifndef SBL_DSP_TYPES_CONVERT_HPP_
10#define SBL_DSP_TYPES_CONVERT_HPP_
18#ifdef SBL_PROFILING_ENABLED
19#define SBL_NAN_DETECTED() (++sbl::dsp::types::nan_detect_count())
21#define SBL_NAN_DETECTED() ((void)0)
44inline void to_float(
const Sample* in,
float* out, uint16_t frames) {
45 for (uint16_t i = 0; i < frames; ++i) {
50inline void to_sample(
const float* in, Sample* out, uint16_t frames) {
51 for (uint16_t i = 0; i < frames; ++i) {
62 float* left,
float* right,
64 for (uint16_t i = 0; i < frames; ++i) {
70 int32_t l = (interleaved[i * 2] << 8) >> 8;
71 int32_t r = (interleaved[i * 2 + 1] << 8) >> 8;
81#ifdef SBL_PROFILING_ENABLED
82inline uint32_t& nan_detect_count() {
83 static uint32_t count = 0;
99 for (uint16_t i = 0; i < frames; ++i) {
105 if (l > 1.0f) l = 1.0f;
106 if (l < -1.0f) l = -1.0f;
107 if (r > 1.0f) r = 1.0f;
108 if (r < -1.0f) r = -1.0f;
110 interleaved[i * 2 + 1] =
static_cast<int32_t
>(r *
SAMPLE_SCALE_F);
#define SBL_NAN_DETECTED()
Audio common types and configuration.
Sample rate, sample formats, blocks and frames.
Sample to_sample(float f)
constexpr float SAMPLE_SCALE_INV_F
void interleave_from_float(const float *left, const float *right, int32_t *interleaved, uint16_t frames)
void deinterleave_to_float(const int32_t *interleaved, float *left, float *right, uint16_t frames)
constexpr float SAMPLE_SCALE_F