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

◆ applyGain()

void fl::audio::AutoGain::applyGain ( const vector< i16 > & input,
float gain,
vector< i16 > & output )
private

Apply gain to audio samples.

Parameters
inputInput PCM samples
gainGain multiplier
outputOutput buffer

Definition at line 199 of file auto_gain.cpp.hpp.

199 {
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}

References fl::vector_basic::size().

Referenced by process().

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