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

◆ updateAutoGain()

void updateAutoGain ( float level)

Definition at line 154 of file advanced.h.

154 {
155 if (!autoGain) {
156 autoGainValue = 1.0f;
157 return;
158 }
159
160 static float targetLevel = 0.7f;
161 static float avgLevel = 0.0f;
162
163 avgLevel = avgLevel * 0.95f + level * 0.05f;
164
165 if (avgLevel > 0.01f) {
166 float gainAdjust = targetLevel / avgLevel;
167 gainAdjust = fl::clamp(gainAdjust, 0.5f, 2.0f);
168 autoGainValue = autoGainValue * 0.9f + gainAdjust * 0.1f;
169 }
170}
fl::UICheckbox autoGain("Auto Gain", true)
float autoGainValue
Definition advanced.h:90
constexpr enable_if< is_fixed_point< T >::value, T >::type clamp(T x, T lo, T hi) FL_NOEXCEPT

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: