MCPcopy Create free account
hub / github.com/FastLED/FastLED / updateAutoGain

Function updateAutoGain

examples/Audio/advanced/advanced.h:154–170  ·  view source on GitHub ↗

Update auto gain

Source from the content-addressed store, hash-verified

152
153// Update auto gain
154void updateAutoGain(float level) {
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}
171
172// Clear display
173void clearDisplay() {

Callers 1

loopFunction · 0.85

Calls 1

clampFunction · 0.85

Tested by

no test coverage detected