11#ifndef SBL_DSP_MATH_GAIN_HPP_
12#define SBL_DSP_MATH_GAIN_HPP_
34inline float gain_to_db(
float gain) {
return gain > 0.0f ? 20.0f * std::log10(gain) : -INFINITY; }
50 const float l = std::isfinite(level) ? (level < 0.0f ? 0.0f : (level > 1.0f ? 1.0f : level)) : 0.0f;
51 if (!(range_db > 0.0f)) {
55 return (
db_to_gain(-range_db * (1.0f - l)) - floor) / (1.0f - floor);
Math for the audio stack.
constexpr float DB_PER_DOUBLING
float level_gain(float level, float range_db)
The level taper: a level in [0, 1] to a gain.
float gain_to_db(float gain)
Level in dB for an amplitude gain.
float db_to_gain(float db)
Amplitude gain for a level in dB: 10^(db / 20).