FastLED 3.9.15
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_NOEXCEPT;
83
85 float getFloor() const FL_NOEXCEPT { return mCurrentFloor; }
86
90 float normalize(float level) const FL_NOEXCEPT;
91
95 bool isAboveFloor(float level) const FL_NOEXCEPT;
96
98 void reset() FL_NOEXCEPT;
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_NOEXCEPT { return mStats; }
110
111private:
114 void updateFloor(float level) FL_NOEXCEPT;
115
120 float combineDomains(float timeLevel, float freqLevel) const FL_NOEXCEPT;
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
float normalize(float level) const FL_NOEXCEPT
Normalize signal by removing noise floor.
bool isAboveFloor(float level) const FL_NOEXCEPT
Check if signal is above noise floor + margin.
float mCurrentFloor
Current noise floor estimate.
void update(float timedomainLevel, float frequencydomainLevel=-1.0f) FL_NOEXCEPT
Update noise floor estimate with new observation.
void updateFloor(float level) FL_NOEXCEPT
Update floor estimate based on current observation.
NoiseFloorTrackerConfig mConfig
void configure(const NoiseFloorTrackerConfig &config) FL_NOEXCEPT
Configure the noise floor tracker.
float getFloor() const FL_NOEXCEPT
Get current noise floor estimate.
static constexpr u32 BELOW_FLOOR_THRESHOLD
Threshold for considering signal "consistently low".
void reset() FL_NOEXCEPT
Reset noise floor to initial state.
float mLastHysteresisFloor
Floor value at last hysteresis trigger Used to enforce hysteresis margin before allowing floor to ris...
float combineDomains(float timeLevel, float freqLevel) const FL_NOEXCEPT
Calculate combined metric from time and frequency domains.
~NoiseFloorTracker() FL_NOEXCEPT
const Stats & getStats() const FL_NOEXCEPT
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.
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_NOEXCEPT