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.
| 24 | // This simulates real-world usage where FFT is computed first, |
| 25 | // then all detector reuse the cached result. |
| 26 | void 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 |
| 51 | class SynthAudioGenerator { |
nothing calls this directly
no test coverage detected