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

◆ removeDCOffset()

void fl::audio::SignalConditioner::removeDCOffset ( span< const i16 > pcm,
i32 dcOffset,
vector< i16 > & output )
private

Remove DC offset from samples.

Parameters
pcmInput PCM samples
dcOffsetDC offset to remove
outputOutput buffer for DC-removed samples

Definition at line 135 of file signal_conditioner.cpp.hpp.

135 {
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}
vector< bool > mValidMask
Working buffers (reused to avoid allocations)

References mValidMask, and fl::span< T, Extent >::size().

Referenced by processSample().

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