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

Method applyGain

src/fl/audio/auto_gain.cpp.hpp:199–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199void AutoGain::applyGain(const vector<i16>& input, float gain, vector<i16>& output) {
200 output.clear();
201 output.reserve(input.size());
202
203 for (size i = 0; i < input.size(); ++i) {
204 // Multiply sample by gain
205 float amplified = static_cast<float>(input[i]) * gain;
206
207 // Clamp to int16 range to prevent overflow/clipping
208 if (amplified > 32767.0f) amplified = 32767.0f;
209 if (amplified < -32768.0f) amplified = -32768.0f;
210
211 output.push_back(static_cast<i16>(amplified));
212 }
213}
214
215} // namespace audio
216} // namespace fl

Callers

nothing calls this directly

Calls 4

clearMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected