FastLED 3.9.15
Loading...
Searching...
No Matches
auto_gain.h File Reference
#include "fl/math/filter/filter.h"
#include "fl/stl/int.h"
#include "fl/stl/vector.h"
#include "fl/stl/noexcept.h"
+ Include dependency graph for auto_gain.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  fl::audio::AutoGain
 AutoGain implements adaptive gain control using a PI (proportional-integral) controller with slow peak envelope tracking, inspired by WLED Sound Reactive. More...
 
struct  fl::audio::AutoGain::Stats
 Get current statistics (for monitoring/debugging) More...
 
struct  fl::audio::AutoGainConfig
 Configuration for automatic gain control. More...
 

Namespaces

namespace  fl
 Base definition for an LED controller.
 
namespace  fl::audio
 

Enumerations

enum class  fl::audio::AGCPreset { fl::audio::AGCPreset_Normal , fl::audio::AGCPreset_Vivid , fl::audio::AGCPreset_Lazy , fl::audio::AGCPreset_Custom }
 AGC preset selection — derived from WLED Sound Reactive's proven approach. More...
 

Class Documentation

◆ fl::audio::AutoGain::Stats

struct fl::audio::AutoGain::Stats
Class Members
float currentGain = 1.0f
float inputRMS = 0.0f
float integrator = 0.0f
float outputRMS = 0.0f
float peakEnvelope = 0.0f
u32 samplesProcessed = 0
float targetGain = 1.0f

◆ fl::audio::AutoGainConfig

struct fl::audio::AutoGainConfig
Class Members
bool enabled = true Enable automatic gain adjustment.
float gainFollowFastTau = 0.38f Fast gain-follow time constant (seconds) — used when error is large.
float gainFollowSlowTau = 12.3f Slow gain-follow time constant (seconds) — used when error is small.
float ki = 1.7f Integral gain for PI controller.
float kp = 0.6f Proportional gain for PI controller.
float maxGain = 32.0f Maximum gain multiplier (prevents over-amplification)
float minGain = 1.0f / 64.0f Minimum gain multiplier (prevents over-attenuation)
float peakDecayTau = 3.3f Peak envelope decay time constant (seconds).

Controls how quickly the peak tracker forgets old peaks. Longer = more stable.

AGCPreset preset = AGCPreset::AGCPreset_Normal AGC behavior preset (default: Normal)
float targetRMSLevel = 8000.0f Target RMS level after gain (0-32767) The AGC will adjust gain to maintain this average level.