void reset()
Reset internal state.
float mLastGain
Last smoothed gain output.
float getGain() const
Get current gain multiplier.
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.
void setSampleRate(int sampleRate)
Set sample rate for dt computation.
void configure(const AutoGainConfig &config)
Configure the auto gain controller.
float computeTargetGain()
Compute target gain from peak envelope.
const Stats & getStats() const
float mIntegrator
PI integrator state.
Sample process(const Sample &sample)
Process audio sample with automatic gain adjustment.
void resolvePreset()
Resolve preset enum into concrete PI tuning parameters.
Get current statistics (for monitoring/debugging)
AGCPreset
AGC preset selection — derived from WLED Sound Reactive's proven approach.
@ AGCPreset_Vivid
Faster response: 1.3s peak decay, higher PI gains.
@ AGCPreset_Normal
Balanced: 3.3s peak decay, moderate PI gains.
@ AGCPreset_Custom
Use custom PI tuning fields below.
@ AGCPreset_Lazy
Slower, more stable: 6.7s peak decay, lower PI gains.
float kp
Proportional gain for PI controller.
float ki
Integral gain for PI controller.
float targetRMSLevel
Target RMS level after gain (0-32767) The AGC will adjust gain to maintain this average level.
float peakDecayTau
Peak envelope decay time constant (seconds).
float maxGain
Maximum gain multiplier (prevents over-amplification)
AGCPreset preset
AGC behavior preset (default: Normal)
float minGain
Minimum gain multiplier (prevents over-attenuation)
float gainFollowSlowTau
Slow gain-follow time constant (seconds) — used when error is small.
float gainFollowFastTau
Fast gain-follow time constant (seconds) — used when error is large.
bool enabled
Enable automatic gain adjustment.
Configuration for automatic gain control.
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.
Base definition for an LED controller.