6#ifndef SBL_DSP_DYNAMICS_SOFT_LIMITER_HPP_
7#define SBL_DSP_DYNAMICS_SOFT_LIMITER_HPP_
47 constexpr float knee()
const {
return knee_; }
49 constexpr float ceiling()
const {
return ceiling_; }
73 const float room = ceiling_ - knee_;
74 const float over = (std::fabs(x) - knee_) / room;
86 void process(
const float* in,
float* out, uint16_t frames)
const {
87 for (uint16_t i = 0; i < frames; ++i) {
88 out[i] =
limit(in[i]);
A soft-knee limiter: the input under a knee, a tanh bend under a ceiling above it.
constexpr float knee() const
The knee.
bool acts_on(float x) const
Whether limit() changes x: its magnitude is above the knee, or it is not a number.
constexpr SoftLimiter(float knee, float ceiling)
A limiter with a knee and a ceiling, 0 < knee < ceiling.
float limit(float x) const
One sample through the limiter.
void process(const float *in, float *out, uint16_t frames) const
A block through the limiter; out may be in.
constexpr float ceiling() const
The ceiling.
Fast analytical approximations of sin, tan, 2^x and tanh.
A float's magnitude as its bit pattern, for compares without the FPU.
float fast_tanhf(float x)
Fast tanh approximation using a [3,2] Pade approximant.
uint32_t magnitude_bits(float x)
x's bits with the sign cleared.