FastLED 3.10.8
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 1066 of file fft_impl.cpp.hpp.

1069 {
1070 int bands = binEnd - binStart;
1071 normFactors.resize(binEnd);
1072 for (int i = 0; i < binEnd; ++i) {
1073 normFactors[i] = 1.0f;
1074 }
1075
1076 // Count FFT bins mapping to each output bin using same bounds as logRebinRange
1077 const int numRawBins = fftN / 2 + 1;
1078 const u16x16 rawBinHz(fs / static_cast<float>(fftN));
1079 const u16x16 halfBin = rawBinHz >> 1;
1080 const u16x16 loEdge(mLogBinEdges[binStart]);
1081 const u16x16 hiEdge(mLogBinEdges[binEnd]);
1082
1083 int kStart = 0;
1084 if (loEdge > halfBin) {
1085 kStart = static_cast<int>(
1086 u16x16::ceil((loEdge - halfBin) / rawBinHz).to_int());
1087 }
1088 int kEnd = static_cast<int>(
1089 u16x16::ceil((hiEdge + halfBin) / rawBinHz).to_int());
1090 if (kEnd > numRawBins) kEnd = numRawBins;
1091
1092 FASTLED_STACK_ARRAY(float, counts, binEnd);
1093 for (int k = kStart; k < kEnd; ++k) {
1094 counts[lut[k]] += 1.0f;
1095 }
1096
1097 for (int i = binStart; i < binEnd; ++i) {
1098 normFactors[i] = (counts[i] > 0.0f) ? 1.0f / counts[i] : 1.0f;
1099 }
1100 (void)bands;
1101 }
#define FASTLED_STACK_ARRAY(TYPE, NAME, SIZE)
Stack-allocated array with automatic zero-initialization.
Definition alloca.h:32
fl::vector< float > mLogBinEdges
constexpr u32 to_int() const FL_NO_EXCEPT
Definition u16x16.h:61
static constexpr FASTLED_FORCE_INLINE u16x16 ceil(u16x16 x) FL_NO_EXCEPT
Definition u16x16.h:142
void resize(fl::size n) FL_NO_EXCEPT
Definition vector.h:593

References fl::u16x16::ceil(), FASTLED_STACK_ARRAY, fl::FL_NO_EXCEPT, mLogBinEdges, 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: