FastLED 3.9.15
Loading...
Searching...
No Matches
fl::audio::NoiseFloorTracker Class Reference

Detailed Description

NoiseFloorTracker maintains an adaptive estimate of the background noise floor for audio signals, with hysteresis to prevent "noise chasing" where the floor continuously adjusts to the signal level.

Features:

  • Exponential decay: Floor gradually decreases toward minimum
  • Slow attack: Floor increases slowly when signal is consistently low
  • Hysteresis: Prevents rapid floor oscillations
  • Cross-domain calibration: Combines time-domain (RMS) and frequency-domain metrics

How it works:

  1. Track minimum observed signal level over time
  2. Apply exponential decay to gradually lower the floor
  3. If signal stays below floor + margin for sustained period, raise floor slowly
  4. Use hysteresis to prevent the floor from chasing transient noise

Usage:

config.decayRate = 0.99f;
config.hysteresisMargin = 100.0f;
tracker.configure(config);
Sample sample = ...;
float rms = sample.rms();
tracker.update(rms);
float normalized = tracker.normalize(rms); // Signal with floor removed
bool isAboveFloor = tracker.isAboveFloor(rms);
float rms(fl::span< const int16_t > data)
Definition simple.h:104
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.
void update(float timedomainLevel, float frequencydomainLevel=-1.0f) FL_NOEXCEPT
Update noise floor estimate with new observation.
void configure(const NoiseFloorTrackerConfig &config) FL_NOEXCEPT
Configure the noise floor tracker.
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.
Configuration for noise floor tracking.
CRGB sample(const CRGB *grid, const XYMap &xyMap, float x, float y, SampleMode mode)
Sample a pixel from a 2D CRGB grid at floating-point coordinates.
Definition sample.cpp.hpp:9

Definition at line 70 of file noise_floor_tracker.h.

#include <noise_floor_tracker.h>

+ Collaboration diagram for fl::audio::NoiseFloorTracker:

Classes

struct  Stats
 Get current statistics (for monitoring/debugging) More...
 

Public Member Functions

 NoiseFloorTracker () FL_NOEXCEPT
 
 NoiseFloorTracker (const NoiseFloorTrackerConfig &config) FL_NOEXCEPT
 
 ~NoiseFloorTracker () FL_NOEXCEPT
 
void configure (const NoiseFloorTrackerConfig &config) FL_NOEXCEPT
 Configure the noise floor tracker.
 
float getFloor () const FL_NOEXCEPT
 Get current noise floor estimate.
 
const StatsgetStats () const FL_NOEXCEPT
 
bool isAboveFloor (float level) const FL_NOEXCEPT
 Check if signal is above noise floor + margin.
 
float normalize (float level) const FL_NOEXCEPT
 Normalize signal by removing noise floor.
 
void reset () FL_NOEXCEPT
 Reset noise floor to initial state.
 
void update (float timedomainLevel, float frequencydomainLevel=-1.0f) FL_NOEXCEPT
 Update noise floor estimate with new observation.
 

Private Member Functions

float combineDomains (float timeLevel, float freqLevel) const FL_NOEXCEPT
 Calculate combined metric from time and frequency domains.
 
void updateFloor (float level) FL_NOEXCEPT
 Update floor estimate based on current observation.
 

Private Attributes

u32 mBelowFloorCount = 0
 Count of consecutive samples below floor (for slow attack)
 
NoiseFloorTrackerConfig mConfig
 
float mCurrentFloor = 100.0f
 Current noise floor estimate.
 
float mLastHysteresisFloor = 0.0f
 Floor value at last hysteresis trigger Used to enforce hysteresis margin before allowing floor to rise.
 
Stats mStats
 

Static Private Attributes

static constexpr u32 BELOW_FLOOR_THRESHOLD = 10
 Threshold for considering signal "consistently low".
 

The documentation for this class was generated from the following files: