Process audio sample with automatic gain adjustment.
78 {
79
82 }
83
84
86 return Sample();
87 }
88
89
90 const float inputRMS =
sample.rms();
91 mStats.inputRMS = inputRMS;
92
93
96 : 0.023f;
97
98
99
100 const float silenceThreshold = 10.0f;
101 if (inputRMS < silenceThreshold) {
104 }
105
106
109 mStats.peakEnvelope = peakEnv;
110
111
113 mStats.targetGain = targetGain;
114
115
117
118
121 mStats.currentGain = clampedGain;
123
124
125 const auto& pcm =
sample.pcm();
129
130
134 sumSq += val * val;
135 }
137
138
141
142
145 return Sample(impl);
146}
float mLastGain
Last smoothed gain output.
AttackDecayFilter< float > mPeakEnvelope
Peak envelope tracker: fast attack (10ms), slow decay (preset-dependent)
void applyGain(const vector< i16 > &input, float gain, vector< i16 > &output)
Apply gain to audio samples.
vector< i16 > mOutputBuffer
Working buffer (reused to avoid allocations)
float updatePIController(float targetGain, float dt)
Update PI controller toward target gain.
float computeTargetGain()
Compute target gain from peak envelope.
float mIntegrator
PI integrator state.
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NOEXCEPT
float sqrtf(float value) FL_NOEXCEPT
constexpr common_type_t< T, U > max(T a, U b) FL_NOEXCEPT
CRGB sample(const CRGB *grid, const XYMap &xyMap, float x, float y, SampleMode mode)
Sample a pixel from a 2D CRGB grid at floating-point coordinates.
shared_ptr< T > make_shared(Args &&... args) FL_NOEXCEPT
constexpr enable_if< is_fixed_point< T >::value, T >::type abs(T x) FL_NOEXCEPT