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

◆ freqToBin()

int fl::audio::fft::Bins::freqToBin ( float freq) const

Definition at line 111 of file fft.cpp.hpp.

111 {
112 int nbands = static_cast<int>(mBinsRaw.size());
113 if (nbands <= 1) return 0;
114 if (freq <= mFmin) return 0;
115 if (freq >= mFmax) return nbands - 1;
116 float m = fl::logf(mFmax / mFmin);
117 float bin = fl::logf(freq / mFmin) / m * static_cast<float>(nbands - 1);
118 int result = static_cast<int>(bin + 0.5f);
119 if (result < 0) return 0;
120 if (result >= nbands) return nbands - 1;
121 return result;
122}
fl::vector< float > mBinsRaw
Definition fft.h:110
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
float logf(float value) FL_NOEXCEPT
Definition math.h:418

References fl::logf(), mBinsRaw, mFmax, and mFmin.

Referenced by fl::audio::detector::Vocal::computeFormantRatio(), and operator=().

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