Repository navigation
Description
Goal
Eliminate the per-sketch FL_FFT_USE_ESP_DSP define and the user-facing @filter it forces, by routing ESP-DSP through the scalar polyfill that already exists in fl::audio::fft. Users should never need to opt in OR out — the right backend should select automatically based on what the toolchain actually ships.
Background
PR #2625 just landed an @filter workaround on examples/AudioFftParity/AudioFftParity.ino to keep esp32c2 (and likely esp32s2/h2/c5) green. Root cause was:
- The example sets
#define FL_FFT_USE_ESP_DSP 1 src/fl/audio/fft/fft_backend.h:101#include "esp_dsp.h"whenever that define +FL_IS_ESP32are both true- esp_dsp.h isn't in every ESP32 toolchain bundle (low-end RISC-V parts don't have it)
- Result: hard compile error on boards where the header is missing
The @filter works around the symptom but the underlying design is wrong: any user-authored sketch that opts into ESP-DSP for performance will hit the same wall on a non-supported board, with no diagnostic better than "esp_dsp.h: No such file or directory."
Proposal — eliminate the define
-
Auto-detect esp_dsp availability at preprocessor time:
#if defined(FL_IS_ESP32) && FL_HAS_INCLUDE("esp_dsp.h") #define FL_FFT_ESP_DSP_AVAILABLE 1 #include "esp_dsp.h" #else #define FL_FFT_ESP_DSP_AVAILABLE 0 #endif
Drop the user-opt-in
FL_FFT_USE_ESP_DSPentirely.FL_HAS_INCLUDEalready exists infl/stl/has_include.hand is used elsewhere in the codebase for exactly this kind of feature probe (e.g. lcd_spi gatesesp_cache.hthe same way). -
Scalar fallback is automatic. The dispatch logic at the call site already has
#if FL_FFT_ESP_DSP_AVAILABLE / #elsebranches — the#elsepath uses kiss_fftr or the scalar polyfill. Switching the gate from "user opted in" to "header is present" means:- ESP32 boards with esp_dsp → use the hardware-accelerated backend automatically.
- ESP32 boards without esp_dsp (C2, S2, H2, C5) → use the scalar fallback automatically.
- Non-ESP32 (AVR/Teensy/ARM) → use the scalar fallback automatically.
-
Drop the @filter from AudioFftParity (added in PR fix(examples): restrict AudioFftParity to ESP32 boards with esp_dsp #2625). The example becomes a parity test that runs on every ESP32 board, validating the ESP-DSP backend where present and the scalar fallback where not. Same math should pass either way.
Why this is better
- No user-facing knobs. Users don't need to know about ESP-DSP existence. Performance just happens when the chip can deliver it.
- No example matrix surprises. New ESP32 chips that omit ESP-DSP (or future chips that gain it) Just Work without a CI matrix update.
- One less footgun. A user writing their own audio sketch on esp32c2 won't accidentally
#define FL_FFT_USE_ESP_DSP 1(copy-pasting from AudioFftParity) and hit a stop-the-build error.
Test plan
- Strip
FL_FFT_USE_ESP_DSPfromfft_backend.handAudioFftParity.ino. - Add
FL_HAS_INCLUDE("esp_dsp.h")probe infft_backend.h. - Remove the
@filterfromAudioFftParity.ino. -
bash compile esp32c2 --examples AudioFftParitysucceeds (uses scalar fallback). -
bash compile esp32s3 --examples AudioFftParitysucceeds (uses ESP-DSP). -
bash test fl_audio_fft --cppcontinues to pass on the host (scalar path). - AudioFftParity's runtime assertions pass on both an esp32c2 and an esp32s3 — the scalar and ESP-DSP backends produce mathematically equivalent output for the test signals.
Related
- esp32c2: AudioFftParity fails — esp_dsp.h missing on ESP32-C2 toolchain #2623 — symptom that motivated this (esp32c2 broken on AudioFftParity)
- PR fix(examples): restrict AudioFftParity to ESP32 boards with esp_dsp #2625 —
@filterworkaround that this issue proposes to revert
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(esp32): provide GpioIsrRx::create stub when FASTLED_RMT5=0 (fixes #…
feat(fft): auto-detect esp_dsp via FL_HAS_INCLUDE, drop FL_FFT_USE_ES…