FastLED 3.10.9
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 1063 of file fft_impl.cpp.hpp.

1066 {
1067 int bands = binEnd - binStart;
1068 normFactors.resize(binEnd);
1069 for (int i = 0; i < binEnd; ++i) {
1070 normFactors[i] = 1.0f;
1071 }
1072
1073 // Count FFT bins mapping to each output bin using same bounds as logRebinRange
1074 const int numRawBins = fftN / 2 + 1;
1075 const u16x16 rawBinHz(fs / static_cast<float>(fftN));
1076 const u16x16 halfBin = rawBinHz >> 1;
1077 const u16x16 loEdge(mLogBinEdges[binStart]);
1078 const u16x16 hiEdge(mLogBinEdges[binEnd]);
1079
1080 int kStart = 0;
1081 if (loEdge > halfBin) {
1082 kStart = static_cast<int>(
1083 u16x16::ceil((loEdge - halfBin) / rawBinHz).to_int());
1084 }
1085 int kEnd = static_cast<int>(
1086 u16x16::ceil((hiEdge + halfBin) / rawBinHz).to_int());
1087 if (kEnd > numRawBins) kEnd = numRawBins;
1088
1089 FASTLED_STACK_ARRAY(float, counts, binEnd);
1090 for (int k = kStart; k < kEnd; ++k) {
1091 counts[lut[k]] += 1.0f;
1092 }
1093
1094 for (int i = binStart; i < binEnd; ++i) {
1095 normFactors[i] = (counts[i] > 0.0f) ? 1.0f / counts[i] : 1.0f;
1096 }
1097 (void)bands;
1098 }
#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: