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

◆ computeLogRebinNormFactors()

void fl::audio::fft::Context::computeLogRebinNormFactors ( fl::vector< float > & normFactors,
const fl::vector< u8 > & lut,
int fftN,
float fs,
int binStart,
int binEnd )
inlineprivate

Definition at line 971 of file fft_impl.cpp.hpp.

974 {
975 int bands = binEnd - binStart;
976 normFactors.resize(binEnd);
977 for (int i = 0; i < binEnd; ++i) {
978 normFactors[i] = 1.0f;
979 }
980
981 // Count FFT bins mapping to each output bin using same bounds as logRebinRange
982 const int numRawBins = fftN / 2 + 1;
983 const u16x16 rawBinHz(fs / static_cast<float>(fftN));
984 const u16x16 halfBin = rawBinHz >> 1;
985 const u16x16 loEdge(mLogBinEdges[binStart]);
986 const u16x16 hiEdge(mLogBinEdges[binEnd]);
987
988 int kStart = 0;
989 if (loEdge > halfBin) {
990 kStart = static_cast<int>(
991 u16x16::ceil((loEdge - halfBin) / rawBinHz).to_int());
992 }
993 int kEnd = static_cast<int>(
994 u16x16::ceil((hiEdge + halfBin) / rawBinHz).to_int());
995 if (kEnd > numRawBins) kEnd = numRawBins;
996
997 FASTLED_STACK_ARRAY(float, counts, binEnd);
998 for (int k = kStart; k < kEnd; ++k) {
999 counts[lut[k]] += 1.0f;
1000 }
1001
1002 for (int i = binStart; i < binEnd; ++i) {
1003 normFactors[i] = (counts[i] > 0.0f) ? 1.0f / counts[i] : 1.0f;
1004 }
1005 (void)bands;
1006 }
#define FASTLED_STACK_ARRAY(TYPE, NAME, SIZE)
Stack-allocated array with automatic zero-initialization.
Definition alloca.h:32
fl::vector< float > mLogBinEdges
static constexpr FASTLED_FORCE_INLINE u16x16 ceil(u16x16 x) FL_NOEXCEPT
Definition u16x16.h:133
constexpr u32 to_int() const FL_NOEXCEPT
Definition u16x16.h:60
void resize(fl::size n) FL_NOEXCEPT
Definition vector.h:593

References fl::u16x16::ceil(), FASTLED_STACK_ARRAY, mLogBinEdges, fl::vector< T >::resize(), and fl::u16x16::to_int().

Referenced by initHybrid(), and initLogRebin().

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