FastLED 3.9.15
Loading...
Searching...
No Matches

◆ drawRadialSpectrum()

void drawRadialSpectrum ( FFTBins * fft,
float  )

Definition at line 222 of file advanced.h.

222 {
223 clearDisplay();
224 CRGBPalette16 palette = getCurrentPalette();
225
226 int centerX = WIDTH / 2;
227 int centerY = HEIGHT / 2;
228
229 for (size_t angle = 0; angle < 360; angle += 6) { // Reduced resolution
230 size_t band = (angle / 6) % NUM_BANDS;
231 if (band >= fft->bins_db.size()) continue;
232
233 float magnitude = fft->bins_db[band] / 100.0f;
234 magnitude = MAX(0.0f, magnitude - noiseFloor.value());
235 magnitude *= audioGain.value() * autoGainValue;
236 magnitude = fl::clamp(magnitude, 0.0f, 1.0f);
237
238 int radius = magnitude * (MIN(WIDTH, HEIGHT) / 2);
239
240 for (int r = 0; r < radius; r++) {
241 int x = centerX + (r * cosf(angle * PI / 180.0f));
242 int y = centerY + (r * sinf(angle * PI / 180.0f));
243
244 if (x >= 0 && x < WIDTH && y >= 0 && y < HEIGHT) {
245 uint8_t colorIndex = fl::map_range<int, uint8_t>(r, 0, radius, 255, 0);
246 int ledIndex = xyMap(x, y);
247 if (ledIndex >= 0 && ledIndex < NUM_LEDS) {
248 leds[ledIndex] = ColorFromPalette(palette, colorIndex + hue);
249 }
250 }
251 }
252 }
253}
CRGB leds[NUM_LEDS]
#define NUM_LEDS
uint8_t hue
int y
Definition simple.h:93
int x
Definition simple.h:92
fl::XYMap xyMap
Definition ColorBoost.h:57
UINumberField palette("Palette", 0, 0, 2)
AudioAnalyzeFFT1024 fft
#define WIDTH
Definition advanced.h:34
static const int NUM_BANDS
Definition advanced.h:81
UISlider noiseFloor("Noise Floor", 0.1f, 0.0f, 1.0f, 0.01f)
float autoGainValue
Definition advanced.h:89
UISlider audioGain("Audio Gain", 1.0f, 0.1f, 5.0f, 0.1f)
CRGBPalette16 getCurrentPalette()
Definition advanced.h:101
#define HEIGHT
Definition advanced.h:35
void clearDisplay()
Definition advanced.h:165
CRGB ColorFromPalette(const CRGBPalette16 &pal, fl::u8 index, fl::u8 brightness, TBlendType blendType)
#define MIN(a, b)
Definition math_macros.h:49
#define PI
Definition math_macros.h:97
#define MAX(a, b)
Definition math_macros.h:45
FASTLED_FORCE_INLINE T clamp(T value, T min, T max)
Definition clamp.h:10

References audioGain(), autoGainValue, fl::clamp(), clearDisplay(), ColorFromPalette(), fft, getCurrentPalette(), HEIGHT, hue, leds, MAX, MIN, noiseFloor(), NUM_BANDS, NUM_LEDS, palette(), PI, WIDTH, x, xyMap, and y.

Referenced by loop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: