FastLED 3.10.8
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 i32 sample32 = static_cast<i32>(sample);
168 const i32 absSample = (sample32 < 0) ? -sample32 : sample32;
169
170 // Hysteresis logic: Different thresholds for opening vs closing
171 if (!mNoiseGateOpen) {
172 // Gate is closed - check if signal exceeds open threshold
173 if (absSample >= openThreshold) {
174 mNoiseGateOpen = true;
175 }
176 } else {
177 // Gate is open - check if signal falls below close threshold
178 if (absSample < closeThreshold) {
179 mNoiseGateOpen = false;
180 }
181 }
182
183 // Output sample if gate is open, else zero
184 output.push_back(mNoiseGateOpen ? sample : 0);
185 }
186}
bool mNoiseGateOpen
Noise gate state.
SignalConditionerConfig mConfig
CRGB sample(const CRGB *grid, const XYMap &xyMap, float x, float y, SampleMode mode) FL_NO_EXCEPT
Sample a pixel from a 2D CRGB grid at floating-point coordinates.

References fl::FL_NO_EXCEPT, mConfig, mNoiseGateOpen, and fl::sample().

Referenced by processSample().

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