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

◆ drawRadialSpectrum()

void drawRadialSpectrum ( FFTBins * fft,
float  )

Definition at line 224 of file advanced.h.

224 {
225 clearDisplay();
226 CRGBPalette16 palette = getCurrentPalette();
227
228 int centerX = WIDTH / 2;
229 int centerY = HEIGHT / 2;
230
231 for (size_t angle = 0; angle < 360; angle += 6) { // Reduced resolution
232 size_t band = (angle / 6) % NUM_BANDS;
233 if (band >= fft->bins_db.size()) continue;
234
235 float magnitude = fft->bins_db[band] / 100.0f;
236 magnitude = MAX(0.0f, magnitude - noiseFloor.value());
237 magnitude *= audioGain.value() * autoGainValue;
238 magnitude = fl::clamp(magnitude, 0.0f, 1.0f);
239
240 int radius = magnitude * (MIN(WIDTH, HEIGHT) / 2);
241
242 for (int r = 0; r < radius; r++) {
243 int x = centerX + (r * cosf(angle * PI / 180.0f));
244 int y = centerY + (r * sinf(angle * PI / 180.0f));
245
246 if (x >= 0 && x < WIDTH && y >= 0 && y < HEIGHT) {
247 uint8_t colorIndex = fl::map_range<int, uint8_t>(r, 0, radius, 255, 0);
248 int ledIndex = xyMap(x, y);
249 if (ledIndex >= 0 && ledIndex < NUM_LEDS) {
250 leds[ledIndex] = ColorFromPalette(palette, colorIndex + hue);
251 }
252 }
253 }
254 }
255}
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:61
UINumberField palette("Palette", 0, 0, 2)
AudioAnalyzeFFT1024 fft
#define WIDTH
Definition advanced.h:36
static const int NUM_BANDS
Definition advanced.h:83
UISlider noiseFloor("Noise Floor", 0.1f, 0.0f, 1.0f, 0.01f)
float autoGainValue
Definition advanced.h:91
UISlider audioGain("Audio Gain", 1.0f, 0.1f, 5.0f, 0.1f)
CRGBPalette16 getCurrentPalette()
Definition advanced.h:103
#define HEIGHT
Definition advanced.h:37
void clearDisplay()
Definition advanced.h:167
CRGB ColorFromPalette(const CRGBPalette16 &pal, fl::u8 index, fl::u8 brightness, TBlendType blendType)
#define MIN(a, b)
Definition math_macros.h:41
#define PI
Definition math_macros.h:89
#define MAX(a, b)
Definition math_macros.h:37
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: