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

Function prewarmFFTCache

tests/profile/audio_detector_performance.cpp:26–48  ·  view source on GitHub ↗

Pre-warm function: Prime the FFT cache before profiling This simulates real-world usage where FFT is computed first, then all detector reuse the cached result.

Source from the content-addressed store, hash-verified

24// This simulates real-world usage where FFT is computed first,
25// then all detector reuse the cached result.
26void prewarmFFTCache(int sampleRate = 16000) {
27 // Create a temporary processor with all FFT-dependent detector
28 // to populate the FFT cache for this sample rate/config
29 fl::audio::Processor warmup;
30 warmup.setSampleRate(sampleRate);
31
32 // Register all callbacks to activate detector
33 warmup.onEnergy([](float) {});
34 warmup.onFrequencyBands([](float, float, float) {}); // ← Triggers FFT caching
35 warmup.onBeat([]() {});
36 warmup.onTempo([](float) {});
37 warmup.onPitch([](float) {});
38 warmup.onVocal([](fl::u8) {});
39 warmup.onTransient([]() {});
40 warmup.onVibeLevels([](const fl::audio::detector::VibeLevels&) {});
41
42 // Generate and process a few samples to warm the cache
43 SynthAudioGenerator gen(sampleRate);
44 for (int i = 0; i < 20; i++) {
45 warmup.update(gen.generateSample());
46 }
47 // warmup goes out of scope, cache persists in Processor instances
48}
49
50// Synthetic audio sample generator for consistent testing
51class SynthAudioGenerator {

Callers

nothing calls this directly

Calls 11

onEnergyMethod · 0.80
onFrequencyBandsMethod · 0.80
onBeatMethod · 0.80
onTempoMethod · 0.80
onPitchMethod · 0.80
onVocalMethod · 0.80
onTransientMethod · 0.80
onVibeLevelsMethod · 0.80
setSampleRateMethod · 0.45
updateMethod · 0.45
generateSampleMethod · 0.45

Tested by

no test coverage detected