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

◆ applyNoiseGate()

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

Apply noise gate with hysteresis.

Parameters
pcmInput PCM samples (DC-removed)
outputOutput buffer (gated samples, zero if gate closed)

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

157 {
158 const size count = pcm.size();
159 output.clear();
160 output.reserve(count);
161
162 const i16 openThreshold = mConfig.noiseGateOpenThreshold;
163 const i16 closeThreshold = mConfig.noiseGateCloseThreshold;
164
165 for (size i = 0; i < count; ++i) {
166 const i16 sample = pcm[i];
167 const i16 absSample = (sample < 0) ? -sample : sample;
168
169 // Hysteresis logic: Different thresholds for opening vs closing
170 if (!mNoiseGateOpen) {
171 // Gate is closed - check if signal exceeds open threshold
172 if (absSample >= openThreshold) {
173 mNoiseGateOpen = true;
174 }
175 } else {
176 // Gate is open - check if signal falls below close threshold
177 if (absSample < closeThreshold) {
178 mNoiseGateOpen = false;
179 }
180 }
181
182 // Output sample if gate is open, else zero
183 output.push_back(mNoiseGateOpen ? sample : 0);
184 }
185}
bool mNoiseGateOpen
Noise gate state.
SignalConditionerConfig mConfig
CRGB sample(const CRGB *grid, const XYMap &xyMap, float x, float y, SampleMode mode)
Sample a pixel from a 2D CRGB grid at floating-point coordinates.
Definition sample.cpp.hpp:9

References mConfig, mNoiseGateOpen, fl::sample(), 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: