Sound Byte Libs
0.5.1-121-g3358a44
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
fixed.hpp
Go to the documentation of this file.
1
// sbl/dsp/fixed.hpp — Fixed-point constants and audio sample types
2
//
3
// Phase convention: uint32_t full range [0, 2^32) = one cycle
4
5
#ifndef SBL_DSP_TYPES_FIXED_HPP_
6
#define SBL_DSP_TYPES_FIXED_HPP_
7
8
#include <cstdint>
9
10
namespace
sbl::dsp::types
{
11
12
// Master sample rate. All DSP coefficient math reads this directly — no per-
13
// component sample_rate_ members. Set once at audio init, never changes at
14
// runtime. Tests can modify between batch runs (tear down DSP graph, set new
15
// rate, rebuild, run all tests again).
16
inline
uint32_t
SAMPLE_RATE
= 48000;
17
inline
float
SAMPLE_RATE_F
= 48000.0f;
18
19
// 24-bit audio sample range (matches SAI/I2S int32 format)
20
inline
constexpr
int32_t
SAMPLE_MAX_24
= 8388607;
// 2^23 - 1
21
inline
constexpr
int32_t
SAMPLE_MIN_24
= -8388607;
// -(2^23 - 1), symmetric
22
23
/// Clamp value to 24-bit audio range
24
inline
constexpr
int32_t
saturate_24
(int32_t x) {
25
return
(x >
SAMPLE_MAX_24
) ?
SAMPLE_MAX_24
26
: (x <
SAMPLE_MIN_24
) ?
SAMPLE_MIN_24
27
: x;
28
}
29
30
}
// namespace sbl::dsp::types
31
32
#endif
// SBL_DSP_TYPES_FIXED_HPP_
sbl::dsp::types
Sample rate, sample formats, blocks and frames.
Definition
block.hpp:20
sbl::dsp::types::saturate_24
constexpr int32_t saturate_24(int32_t x)
Clamp value to 24-bit audio range.
Definition
fixed.hpp:24
sbl::dsp::types::SAMPLE_RATE_F
float SAMPLE_RATE_F
Definition
fixed.hpp:17
sbl::dsp::types::SAMPLE_MIN_24
constexpr int32_t SAMPLE_MIN_24
Definition
fixed.hpp:21
sbl::dsp::types::SAMPLE_MAX_24
constexpr int32_t SAMPLE_MAX_24
Definition
fixed.hpp:20
sbl::dsp::types::SAMPLE_RATE
uint32_t SAMPLE_RATE
Definition
fixed.hpp:16
src
sbl
dsp
types
fixed.hpp
Generated by
1.9.8