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

Method removeDCOffset

src/fl/audio/signal_conditioner.cpp.hpp:135–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133}
134
135void SignalConditioner::removeDCOffset(span<const i16> pcm, i32 dcOffset, vector<i16>& output) {
136 const size count = pcm.size();
137 output.clear();
138 output.reserve(count);
139
140 for (size i = 0; i < count; ++i) {
141 // Zero out samples that were marked as spikes
142 if (i < mValidMask.size() && !mValidMask[i]) {
143 output.push_back(0);
144 continue;
145 }
146
147 i32 sample32 = static_cast<i32>(pcm[i]) - dcOffset;
148
149 // Clamp to int16 range to prevent overflow
150 if (sample32 > 32767) sample32 = 32767;
151 if (sample32 < -32768) sample32 = -32768;
152
153 output.push_back(static_cast<i16>(sample32));
154 }
155}
156
157void SignalConditioner::applyNoiseGate(span<const i16> pcm, vector<i16>& output) {
158 const size count = pcm.size();

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected