[WIP] Add new audio-reactive palettes for smoothed FFT data#5467
Draft
[WIP] Add new audio-reactive palettes for smoothed FFT data#5467
Conversation
…ral Balance) Agent-Logs-Url: https://github.com/wled/WLED/sessions/a11e5210-96ae-4713-abdd-ba42b0e33bc5 Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com>
Copilot stopped work on behalf of
netmindz due to an error
April 1, 2026 08:31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MAX_PALETTESfrom 3 to 5paletteBandAvg[NUM_GEQ_CHANNELS]static array alongside existing FFT arrayspaletteBandAvginfillAudioPalettes()before the palette loopcase 3("Track Character") — spectral centroid from smoothed bands drives hue (warm=bass, cool=treble)case 4("Spectral Balance") — bass/mid/high energy ratios drive hue with smooth transitionspaletteBandAvginonUpdateBegin()alongside other FFT buffer resetsnpm testto validatepio run -e esp32devhardware buildOriginal prompt
Problem
The AudioReactive usermod currently contains three colour palettes (defined in
getCRGBForBand()at line 2211 ofusermods/audioreactive/audio_reactive.cpp) that are updated every frame using rawfftResult[]values. While this makes them very responsive, it also makes them "twitchy" — they react to instantaneous FFT values rather than reflecting the overall character or balance of the music.Goal
Add new audio-reactive palette(s) that use smoothed/averaged FFT data to reflect the overall tonal balance of the music. The key user experience should be:
Implementation Details
All changes should be in
usermods/audioreactive/audio_reactive.cpp.1. Add a smoothed band average buffer for palette use
Add a static
float paletteBandAvg[NUM_GEQ_CHANNELS]array (alongside the existingfftCalc,fftAvg,fftResultarrays near line 227). This buffer should be updated with an exponential moving average (EMA) infillAudioPalettes()before the palette colours are computed:2. Add a "Spectral Centroid / Track Character" palette
Add a new
case 3:to theswitch (pal)ingetCRGBForBand(). This palette computes the spectral centroid (centre-of-mass of the frequency spectrum) from the smoothed band averages and maps it to hue:3. Add a "Spectral Balance" palette
Add a new
case 4:to theswitch (pal)ingetCRGBForBand(). This palette computes energy ratios across bass/mid/high regions and uses the weighted balance to derive hue:4. Update
MAX_PALETTESChange line 74 from:
to:
5. Reset smoothing buffer on audio reset
In
onUpdateBegin()(around line 1683), add a reset ofpaletteBandAvgalongside the existingmemset(fftCalc, ...)calls:Key constraints
usermods/audioreactive/audio_reactive.cppfloat[16]array = 64 bytespaletteBandAvgarray must be declaredstaticat file scope alongside the existing FFT...This pull request was created from Copilot chat.