FastLED 3.9.15
Loading...
Searching...
No Matches

◆ updateAutoGain()

void updateAutoGain ( float level)

Definition at line 146 of file advanced.h.

146 {
147 if (!autoGain) {
148 autoGainValue = 1.0f;
149 return;
150 }
151
152 static float targetLevel = 0.7f;
153 static float avgLevel = 0.0f;
154
155 avgLevel = avgLevel * 0.95f + level * 0.05f;
156
157 if (avgLevel > 0.01f) {
158 float gainAdjust = targetLevel / avgLevel;
159 gainAdjust = fl::clamp(gainAdjust, 0.5f, 2.0f);
160 autoGainValue = autoGainValue * 0.9f + gainAdjust * 0.1f;
161 }
162}
float autoGainValue
Definition advanced.h:89
UICheckbox autoGain("Auto Gain", true)
FASTLED_FORCE_INLINE T clamp(T value, T min, T max)
Definition clamp.h:10

References autoGain(), autoGainValue, and fl::clamp().

Referenced by loop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: