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]
float getBin(int index) const
MicProfile mCurrentMicProfile
vector< AttackDecayFilter< float > > mBinMaxFilters
void setMicProfile(MicProfile profile)
Set microphone correction profile (propagated from Processor).
EqualizerDetector() FL_NOEXCEPT
AttackDecayFilter< float > mVolumeMax
float mPinkNoiseGains[kNumBins]
~EqualizerDetector() FL_NOEXCEPT override
bool mUseAttackDecaySmoothing
static constexpr float kFFTDownscale
vector< AttackDecayFilter< float > > mBinOutputFilters
void configure(const EqualizerConfig &config)
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()
void computeBinCenters(float *out) const
void update(shared_ptr< Context > context) override
function_list< void(const Equalizer &)> onEqualizer
void fireCallbacks() override
fl::span< const float > raw() const FL_NOEXCEPT
float binToFreq(int i) const FL_NOEXCEPT
constexpr fl::size size() const FL_NOEXCEPT
High-resolution microphone frequency response data and utilities.
float applyScaling(float value, FFTScalingMode mode)
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.
MicResponseCurve getMicResponseCurve(MicProfile profile)
Get the high-resolution response curve for a given mic profile.
void downsampleMicResponse(const MicResponseCurve &curve, const float *binCenters, int numBins, float *out)
Downsample a high-resolution mic response curve to N output bins.
MicProfile
Microphone frequency response correction profile.
@ None
No correction (flat response assumed)
float computeAudioDt(fl::size pcmSize, int sampleRate) FL_NOEXCEPT
Compute the time delta (in seconds) for an audio buffer.
void computePinkNoiseGains(const float *binCenters, int numBins, float *out)
Compute pink noise compensation gains for all bins.
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.
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NOEXCEPT
float sqrtf(float value) FL_NOEXCEPT
constexpr int type_rank< T >::value
float expf(float value) FL_NOEXCEPT
float logf(float value) FL_NOEXCEPT
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.