FastLED 3.10.8
Loading...
Searching...
No Matches
noise_floor_tracker.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/stl/int.h"
4#include "fl/stl/noexcept.h"
5
6namespace fl {
7namespace audio {
8
12 bool enabled = true;
13
17 float decayRate = 0.99f;
18
21 float attackRate = 0.001f;
22
25 float hysteresisMargin = 100.0f;
26
28 float minFloor = 10.0f;
29
31 float maxFloor = 5000.0f;
32
36 float crossDomainWeight = 0.3f;
37};
38
71public:
75
78
82 void update(float timedomainLevel, float frequencydomainLevel = -1.0f) FL_NO_EXCEPT;
83
85 float getFloor() const FL_NO_EXCEPT { return mCurrentFloor; }
86
90 float normalize(float level) const FL_NO_EXCEPT;
91
95 bool isAboveFloor(float level) const FL_NO_EXCEPT;
96
98 void reset() FL_NO_EXCEPT;
99
101 struct Stats {
102 float currentFloor = 0.0f; // Current noise floor estimate
103 float minObserved = 0.0f; // Minimum level observed (lifetime)
104 float maxObserved = 0.0f; // Maximum level observed (lifetime)
105 u32 samplesProcessed = 0; // Total samples processed
106 bool inHysteresis = false; // Whether hysteresis is active
107 };
108
109 const Stats& getStats() const FL_NO_EXCEPT { return mStats; }
110
111private:
114 void updateFloor(float level) FL_NO_EXCEPT;
115
120 float combineDomains(float timeLevel, float freqLevel) const FL_NO_EXCEPT;
121
124
126 float mCurrentFloor = 100.0f;
127
131
134
136 static constexpr u32 BELOW_FLOOR_THRESHOLD = 10;
137};
138
139} // namespace audio
140} // namespace fl
void configure(const NoiseFloorTrackerConfig &config) FL_NO_EXCEPT
Configure the noise floor tracker.
void reset() FL_NO_EXCEPT
Reset noise floor to initial state.
float getFloor() const FL_NO_EXCEPT
Get current noise floor estimate.
bool isAboveFloor(float level) const FL_NO_EXCEPT
Check if signal is above noise floor + margin.
float mCurrentFloor
Current noise floor estimate.
float normalize(float level) const FL_NO_EXCEPT
Normalize signal by removing noise floor.
const Stats & getStats() const FL_NO_EXCEPT
void updateFloor(float level) FL_NO_EXCEPT
Update floor estimate based on current observation.
NoiseFloorTrackerConfig mConfig
~NoiseFloorTracker() FL_NO_EXCEPT
void update(float timedomainLevel, float frequencydomainLevel=-1.0f) FL_NO_EXCEPT
Update noise floor estimate with new observation.
float combineDomains(float timeLevel, float freqLevel) const FL_NO_EXCEPT
Calculate combined metric from time and frequency domains.
static constexpr u32 BELOW_FLOOR_THRESHOLD
Threshold for considering signal "consistently low".
float mLastHysteresisFloor
Floor value at last hysteresis trigger Used to enforce hysteresis margin before allowing floor to ris...
u32 mBelowFloorCount
Count of consecutive samples below floor (for slow attack)
Get current statistics (for monitoring/debugging)
float decayRate
Decay rate for noise floor (0.0-1.0) Higher = slower decay (more stable, less responsive) Lower = fas...
float hysteresisMargin
Hysteresis margin (prevents noise chasing) Floor must drop by this amount before it can rise again.
bool enabled
Enable noise floor tracking.
float maxFloor
Maximum floor value (prevents floor from growing unbounded)
float minFloor
Minimum floor value (prevents floor from going to zero)
float attackRate
Attack rate for noise floor (0.0-1.0) How quickly the floor rises when signal is consistently low.
float crossDomainWeight
Cross-domain calibration weight (0.0-1.0) Blends time-domain RMS and frequency-domain energy for floo...
Configuration for noise floor tracking.
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
Base definition for an LED controller.
Definition crgb.hpp:179