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

Method mapFrequencyBin

src/fl/audio/audio_reactive.cpp.hpp:737–750  ·  view source on GitHub ↗

Helper methods

Source from the content-addressed store, hash-verified

735
736// Helper methods
737float Reactive::mapFrequencyBin(int fromBin, int toBin) {
738 if (fromBin < 0 || toBin >= static_cast<int>(mFFTBins.bands()) || fromBin > toBin) {
739 return 0.0f;
740 }
741
742 float sum = 0.0f;
743 for (int i = fromBin; i <= toBin; ++i) {
744 if (i < static_cast<int>(mFFTBins.raw().size())) {
745 sum += mFFTBins.raw()[i];
746 }
747 }
748
749 return sum / static_cast<float>(toBin - fromBin + 1);
750}
751
752float Reactive::computeRMS(const fl::vector<fl::i16>& samples) {
753 if (samples.empty()) return 0.0f;

Callers

nothing calls this directly

Calls 3

bandsMethod · 0.80
sizeMethod · 0.45
rawMethod · 0.45

Tested by

no test coverage detected