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

Method pruneHypotheses

src/fl/audio/detector/tempo_analyzer.cpp.hpp:218–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218void TempoAnalyzer::pruneHypotheses() {
219 // Remove hypotheses that haven't been updated recently
220 for (size i = 0; i < mHypotheses.size(); ) {
221 // Decay score over time
222 mHypotheses[i].score *= 0.95f;
223
224 if (mHypotheses[i].score < 0.1f) {
225 mHypotheses.erase(mHypotheses.begin() + i);
226 } else {
227 i++;
228 }
229 }
230
231 // Sort by score (highest first)
232 for (size i = 0; i < mHypotheses.size(); i++) {
233 for (size j = i + 1; j < mHypotheses.size(); j++) {
234 if (mHypotheses[j].score > mHypotheses[i].score) {
235 TempoHypothesis temp = mHypotheses[i];
236 mHypotheses[i] = mHypotheses[j];
237 mHypotheses[j] = temp;
238 }
239 }
240 }
241
242 // Keep only top hypotheses
243 if (mHypotheses.size() > MAX_HYPOTHESES) {
244 mHypotheses.resize(MAX_HYPOTHESES);
245 }
246}
247
248void TempoAnalyzer::updateCurrentTempo() {
249 if (mHypotheses.empty()) {

Callers

nothing calls this directly

Calls 4

sizeMethod · 0.45
eraseMethod · 0.45
beginMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected