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

Method getHistoricalFFT

src/fl/audio/audio_context.cpp.hpp:120–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120const fft::Bins* Context::getHistoricalFFT(int framesBack) const {
121 if (framesBack < 0 || framesBack >= static_cast<int>(mFFTHistory.size())) {
122 return nullptr;
123 }
124 // Ring buffer lookup: walk backwards from the most-recently-written slot.
125 // Adding history.size() before the modulo avoids negative values from
126 // the subtraction, since C++ modulo of negative ints is implementation-defined.
127 const int n = static_cast<int>(mFFTHistory.size());
128 int index = (mFFTHistoryIndex - 1 - framesBack + n) % n;
129 return &mFFTHistory[index];
130}
131
132void Context::setSample(const Sample& sample) {
133 // Save current fft::FFT to history (use first cached entry if available)

Callers 2

updateMethod · 0.80
audio_context.hppFile · 0.80

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected