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

◆ updateFloor()

void fl::audio::NoiseFloorTracker::updateFloor ( float level)
private

Update floor estimate based on current observation.

Parameters
levelObserved signal level

Definition at line 76 of file noise_floor_tracker.cpp.hpp.

76 {
77 // Exponential moving average tracking of noise floor
78 // with asymmetric rates for rise (attack) and fall (decay)
79 //
80 // Hysteresis is achieved through the slow attack rate, not through
81 // explicit blocking of updates
82
83 if (level < mCurrentFloor) {
84 // Signal is below floor - floor should decay (decrease) rapidly toward signal
85 // Use decay rate (typically high, like 0.99) for downward movement
86 const float decayAlpha = mConfig.decayRate;
87 mCurrentFloor = decayAlpha * mCurrentFloor + (1.0f - decayAlpha) * level;
88
90 mStats.inHysteresis = false;
91
92 // Track floor drops for statistics
93 if (mLastHysteresisFloor > 0.0f && (mLastHysteresisFloor - mCurrentFloor) >= mConfig.hysteresisMargin) {
95 }
96 } else {
97 // Signal is above floor - floor should rise slowly toward signal
98 // Use attack rate (typically low, like 0.01-0.05) for upward movement
99 // This slow rise prevents chasing transient peaks
100 const float attackAlpha = 1.0f - mConfig.attackRate;
101 mCurrentFloor = attackAlpha * mCurrentFloor + mConfig.attackRate * level;
102
104 mStats.inHysteresis = false;
105
106 // Update hysteresis reference when floor rises significantly
107 if (mCurrentFloor - mLastHysteresisFloor >= mConfig.hysteresisMargin) {
109 mStats.inHysteresis = true; // Indicate significant rise
110 }
111 }
112
113 // Clamp to configured range
115}
float mCurrentFloor
Current noise floor estimate.
NoiseFloorTrackerConfig mConfig
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)
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NOEXCEPT
Definition math.h:71
constexpr common_type_t< T, U > max(T a, U b) FL_NOEXCEPT
Definition math.h:75

References fl::max(), mBelowFloorCount, mConfig, mCurrentFloor, fl::min(), mLastHysteresisFloor, and mStats.

Referenced by update().

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