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

Function generateSyntheticCQFFT

tests/fl/audio/test_helpers.h:178–193  ·  view source on GitHub ↗

Generate synthetic CQ-spaced FFT bin data with a peak at specified frequency. Uses CQ log-spaced frequency layout matching the actual CQ kernel. @param numBins Number of CQ bins @param peakFrequency Frequency where the peak should occur (Hz) @param fmin CQ minimum frequency @param fmax CQ maximum frequency @return Vector of float magnitudes (one per bin)

Source from the content-addressed store, hash-verified

176/// @param fmax CQ maximum frequency
177/// @return Vector of float magnitudes (one per bin)
178inline vector<float> generateSyntheticCQFFT(size numBins, float peakFrequency,
179 float fmin = fft::Args::DefaultMinFrequency(),
180 float fmax = fft::Args::DefaultMaxFrequency()) {
181 vector<float> bins;
182 bins.reserve(numBins);
183 int bands = static_cast<int>(numBins);
184 float logRatio = fl::logf(fmax / fmin);
185 for (size i = 0; i < numBins; ++i) {
186 float binFreq = fmin * fl::expf(logRatio * static_cast<float>(i) / static_cast<float>(bands - 1));
187 // Gaussian-like peak in log-frequency space
188 float logDistance = fl::logf(binFreq / peakFrequency) / logRatio * static_cast<float>(bands);
189 float magnitude = fl::exp(-logDistance * logDistance / 2.0f);
190 bins.push_back(magnitude);
191 }
192 return bins;
193}
194
195/// Generate uniform magnitude bins (all same value)
196/// @param count Number of bins

Callers

nothing calls this directly

Calls 5

logfFunction · 0.85
expfFunction · 0.85
expFunction · 0.85
reserveMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected