FreqMatrixEffect
Source:
FreqMatrixEffect.h
FreqMatrixEffect¶
src/light/effects/FreqMatrixEffect.h:32Inherits:
EffectBase
Audio-reactive effect: scrolls the dominant frequency as a color column.
Author: Andrew Tuline (WLED-SR), via the predecessor, https://github.com/ewowi/MoonLight/blob/main/src/MoonLight/Nodes/Effects/E_WLED.h
A vertical shift register driven by the music's major peak frequency. Each scroll moves the column one pixel and paints a new one at the source end. Its hue comes from that peak and its brightness from the loudness, so pitch becomes color.
Prior art: WLED's Freqmatrix, by way of MoonLight.
Public Attributes¶
uint8_t speed = 255
: The scroll throttle, where higher scrolls more often.
uint8_t fx = 128
: The brightness intensity scaler.
uint8_t lowBin = 18
: The lower edge of the frequency window the hue maps across.
uint8_t highBin = 48
: The upper edge of that window.
uint8_t sensitivity = 30
: Brightness sensitivity.
bool audioSpeed = false
: Let the audio level modulate the scroll rate.
Public Methods¶
virtual inline const char * tags() const override
: Catalog tags: WLED origin, audio-reactive.
virtual inline Dim dimensions() const override
: Writes the x=0 column along y, which extrude fans across a wider layer.
virtual inline void defineControls() override
: Publish the scroll rate, the brightness response and the frequency window.
virtual inline void tick() override
: Scroll the column when the throttle allows, and paint the new pixel from the peak frequency.
More info¶
The column is the shift register¶
Each pass reads pixel y-1 into pixel y and writes the new color at y=0. No history buffer is needed, since the look lives entirely in the buffer's own scroll. As a D1 effect it writes the x=0 column along y, which extrude fans across a wider layer.
The one deviation from WLED's math¶
WLED works on a volume normalized to 0..1, where AudioFrame::level is a 0..255 integer. So its 0.25 threshold is reproduced as 64, and its 256.0 divisor as 2560. That lands a full-scale reading near 255, which is the same response curve on our scale. Every other constant is preserved: 80 Hz, and the 42 and 3 multipliers of the window.