MCPcopy Create free account
hub / github.com/FastLED/FastLED / freqToBin

Method freqToBin

src/fl/audio/fft/fft.cpp.hpp:111–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109}
110
111int Bins::freqToBin(float freq) const {
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}
123
124float Bins::binBoundary(int i) const {
125 float f_i = binToFreq(i);

Callers 8

computeFormantRatioMethod · 0.80
computeFeaturesMethod · 0.80
FL_TEST_FILEFunction · 0.80
beat.hppFile · 0.80
FL_TEST_FILEFunction · 0.80
runAccuracyTestFunction · 0.80
runContinuousSweepFunction · 0.80
fft_sweep.hppFile · 0.80

Calls 2

logfFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected