146 {
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);
161 }
162}
UICheckbox autoGain("Auto Gain", true)
FASTLED_FORCE_INLINE T clamp(T value, T min, T max)