108 for (
int i = 0; i <
kNumBins; ++i) {
118 if (fmax <= fmin) fmax = fmin * 2.0f;
120 for (
int i = 0; i <
kNumBins; ++i) {
121 out[i] = fmin *
fl::expf(m *
static_cast<float>(i) /
static_cast<float>(
kNumBins - 1));
135 if (pcm.
size() == 0)
return;
144 const auto& raw = fftBins.
raw();
153 const bool applyGain = (
mGain != 1.0f);
155 for (
int i = 0; i < numBins; ++i) {
160 if (applyMicCorrection) {
173 if (applyScalingMode) {
174 val = applyScaling(val,
mConfig.scalingMode);
185 for (
int i = 0; i < numBins; ++i) {
191 for (
int i = 0; i < numBins; ++i) {
199 if (runningMax < 0.001f) runningMax = 0.001f;
203 for (
int i = numBins; i <
kNumBins; ++i) {
209 for (
int i = kBassStart; i <= kBassEnd; ++i) bassSum +=
mBins[i];
210 mBass = bassSum /
static_cast<float>(kBassEnd - kBassStart + 1);
214 for (
int i = kMidStart; i <= kMidEnd; ++i) midSum +=
mBins[i];
215 mMid = midSum /
static_cast<float>(kMidEnd - kMidStart + 1);
219 for (
int i = kTrebleStart; i <= kTrebleEnd; ++i) trebleSum +=
mBins[i];
220 mTreble = trebleSum /
static_cast<float>(kTrebleEnd - kTrebleStart + 1);
223 float rms = context->getRMS();
225 if (volumeMax < 0.001f) volumeMax = 0.001f;
236 mZcf = context->getZCF();
242 float peakVal = 0.0f;
243 float scaledSum = 0.0f;
244 for (
int i = 0; i < numBins; ++i) {
245 scaledSum += scaledBins[i];
246 if (scaledBins[i] > peakVal) {
247 peakVal = scaledBins[i];
253 float scaledAvg = (numBins > 0) ? (scaledSum /
static_cast<float>(numBins)) : 0.0f;
255 ?
fl::min(1.0f, peakVal / (scaledAvg *
static_cast<float>(numBins)))
260 constexpr float kFullScale = 32767.0f;
289 for (
int i = 0; i <
kNumBins; ++i) {
316 if (index < 0 || index >=
kNumBins)
return 0.0f;
float rms(fl::span< const int16_t > data)
float mEqBuffer[kNumBins]
void computeBinCenters(float *out) const FL_NO_EXCEPT
MicProfile mCurrentMicProfile
void update(shared_ptr< Context > context) FL_NO_EXCEPT override
vector< AttackDecayFilter< float > > mBinMaxFilters
AttackDecayFilter< float > mVolumeMax
float mPinkNoiseGains[kNumBins]
bool mUseAttackDecaySmoothing
void fireCallbacks() FL_NO_EXCEPT override
static constexpr float kFFTDownscale
vector< AttackDecayFilter< float > > mBinOutputFilters
void configure(const EqualizerConfig &config) FL_NO_EXCEPT
Reconfigure equalizer tuning parameters at runtime.
float mMicGains[kNumBins]
vector< ExponentialSmoother< float > > mBinSmoothers
shared_ptr< const fft::Bins > mRetainedFFT
SpectralEqualizer mSpectralEq
static constexpr int kNumBins
void recomputePinkNoiseGains() FL_NO_EXCEPT
~EqualizerDetector() FL_NO_EXCEPT override
void reset() FL_NO_EXCEPT override
function_list< void(const Equalizer &)> onEqualizer
float getBin(int index) const FL_NO_EXCEPT
EqualizerDetector() FL_NO_EXCEPT
void setMicProfile(MicProfile profile) FL_NO_EXCEPT
Set microphone correction profile (propagated from Processor).
float binToFreq(int i) const FL_NO_EXCEPT
fl::span< const float > raw() const FL_NO_EXCEPT
constexpr fl::size size() const FL_NO_EXCEPT
High-resolution microphone frequency response data and utilities.
constexpr int kTrebleStart
float applyScaling(float value, FFTScalingMode mode) FL_NO_EXCEPT
Apply fft::FFT scaling mode to a single bin value.
FFTScalingMode
FFT bin scaling mode applied before per-bin normalization.
@ Logarithmic
Log10(1 + magnitude) — compresses high peaks.
@ Linear
Identity (same as None, explicit name for WLED compat)
@ None
Raw magnitudes (no scaling)
@ SquareRoot
Square root of magnitude (WLED-MM default, good perceptual balance)
Configuration for the equalizer detector.
void downsampleMicResponse(const MicResponseCurve &curve, const float *binCenters, int numBins, float *out) FL_NO_EXCEPT
Downsample a high-resolution mic response curve to N output bins.
MicResponseCurve getMicResponseCurve(MicProfile profile) FL_NO_EXCEPT
Get the high-resolution response curve for a given mic profile.
void computePinkNoiseGains(const float *binCenters, int numBins, float *out) FL_NO_EXCEPT
Compute pink noise compensation gains for all bins.
MicProfile
Microphone frequency response correction profile.
@ None
No correction (flat response assumed)
float computeAudioDt(fl::size pcmSize, int sampleRate) FL_NO_EXCEPT
Compute the time delta (in seconds) for an audio buffer.
EqualizationCurve curve
Equalization curve type.
int count
Number of data points.
size numBands
Number of frequency bands (must match FrequencyBinMapper output)
Configuration for spectral equalizer.
float logf(float value) FL_NO_EXCEPT
u8 u8 fract8 blur_amount FL_NO_EXCEPT
constexpr int type_rank< T >::value
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NO_EXCEPT
float sqrtf(float value) FL_NO_EXCEPT
float expf(float value) FL_NO_EXCEPT
Base definition for an LED controller.
span< const float, kNumBins > bins
16 bins, each 0.0-1.0
float volumeNormFactor
Volume normalization factor (1/volumeMax). Higher = quieter input was scaled more.
float dominantFreqHz
Frequency of strongest bin (Hz)
float volume
0.0-1.0 (self-normalized RMS)
static constexpr int kNumBins
bool isSilence
True when input signal is effectively silent.
float dominantMagnitude
Magnitude of strongest bin (0.0-1.0, normalized)
float volumeDb
Volume in approximate dB (roughly -100 to 0)
float zcf
0.0-1.0 (zero-crossing factor)
Snapshot of equalizer state, passed to onEqualizer callbacks.