FastLED 3.10.8
Loading...
Searching...
No Matches
signal_conditioner.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/stl/int.h"
4#include "fl/stl/vector.h"
5#include "fl/stl/span.h"
6#include "fl/stl/noexcept.h"
7
8namespace fl {
9namespace audio {
10
14 bool enableDCRemoval = true;
15
17 bool enableSpikeFilter = true;
18
20 bool enableNoiseGate = true;
21
24 i16 spikeThreshold = 10000;
25
28
31
32 // DC removal uses per-buffer instantaneous calculation (no alpha needed)
33};
34
55public:
59
62
67
69 void reset() FL_NO_EXCEPT;
70
72 struct Stats {
73 i32 dcOffset = 0; // Current DC offset estimate
74 bool noiseGateOpen = false; // Current noise gate state
75 u32 spikesRejected = 0; // Count of spikes rejected (lifetime)
76 u32 samplesProcessed = 0; // Total samples processed (lifetime)
77 };
78
79 const Stats& getStats() const FL_NO_EXCEPT { return mStats; }
80
81private:
87
93
98 void removeDCOffset(span<const i16> pcm, i32 dcOffset, vector<i16>& output) FL_NO_EXCEPT;
99
104
107
109 bool mNoiseGateOpen = false;
110
115};
116
117} // namespace audio
118} // namespace fl
bool mNoiseGateOpen
Noise gate state.
void removeDCOffset(span< const i16 > pcm, i32 dcOffset, vector< i16 > &output) FL_NO_EXCEPT
Remove DC offset from samples.
void applyNoiseGate(span< const i16 > pcm, vector< i16 > &output) FL_NO_EXCEPT
Apply noise gate with hysteresis.
vector< bool > mValidMask
Working buffers (reused to avoid allocations)
const Stats & getStats() const FL_NO_EXCEPT
void reset() FL_NO_EXCEPT
Reset internal state (DC estimate, noise gate state)
void configure(const SignalConditionerConfig &config) FL_NO_EXCEPT
Configure the signal conditioner.
i32 calculateDCOffset(span< const i16 > pcm, const vector< bool > &validMask) FL_NO_EXCEPT
Calculate DC offset from valid samples only.
Sample processSample(const Sample &sample) FL_NO_EXCEPT
Process a raw audio sample through the conditioning pipeline.
SignalConditionerConfig mConfig
~SignalConditioner() FL_NO_EXCEPT
size filterSpikes(span< const i16 > pcm, vector< bool > &validMask) FL_NO_EXCEPT
Detect and reject spike samples.
Get current statistics (for debugging/monitoring)
bool enableDCRemoval
Enable DC offset removal (running average high-pass filter)
bool enableNoiseGate
Enable noise gate with hysteresis.
i16 noiseGateCloseThreshold
Noise gate close threshold (signal must fall below to close gate)
bool enableSpikeFilter
Enable spike filtering for I2S glitches.
i16 noiseGateOpenThreshold
Noise gate open threshold (signal must exceed to open gate)
i16 spikeThreshold
Spike detection threshold (absolute value) Samples beyond ±spikeThreshold are rejected as glitches.
Configuration for signal conditioning pipeline.
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
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.
Base definition for an LED controller.
Definition crgb.hpp:179