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}
void applyGain(const vector< i16 > &input, float gain, vector< i16 > &output) FL_NO_EXCEPT
Apply gain to audio samples.
float mLastGain
Last smoothed gain output.
AttackDecayFilter< float > mPeakEnvelope
Peak envelope tracker: fast attack (10ms), slow decay (preset-dependent)
float updatePIController(float targetGain, float dt) FL_NO_EXCEPT
Update PI controller toward target gain.
vector< i16 > mOutputBuffer
Working buffer (reused to avoid allocations)
float computeTargetGain() FL_NO_EXCEPT
Compute target gain from peak envelope.
float mIntegrator
PI integrator state.
shared_ptr< T > make_shared(Args &&... args) FL_NO_EXCEPT
constexpr common_type_t< T, U > max(T a, U b) FL_NO_EXCEPT
CRGB sample(const CRGB *grid, const XYMap &xyMap, float x, float y, SampleMode mode) FL_NO_EXCEPT
Sample a pixel from a 2D CRGB grid at floating-point coordinates.
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NO_EXCEPT
float sqrtf(float value) FL_NO_EXCEPT
constexpr enable_if< is_fixed_point< T >::value, T >::type abs(T x) FL_NO_EXCEPT