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

Method applyGain

src/fl/audio/audio.cpp.hpp:191–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189
190
191void Sample::applyGain(float gain) {
192 if (!isValid() || gain == 1.0f) return;
193 auto& samples = mImpl->pcm_mutable();
194 for (fl::size i = 0; i < samples.size(); ++i) {
195 fl::i32 val = static_cast<fl::i32>(static_cast<float>(samples[i]) * gain);
196 if (val > 32767) val = 32767;
197 if (val < -32768) val = -32768;
198 samples[i] = static_cast<fl::i16>(val);
199 }
200}
201
202Sample::Sample(fl::span<const fl::i16> span, fl::u32 timestamp) {
203 mImpl = fl::Singleton<AudioSamplePool>::instance().getOrCreate();

Callers 4

updateMethod · 0.45
readAllMethod · 0.45
gain.hppFile · 0.45
FL_TEST_FILEFunction · 0.45

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected