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

◆ drawVUMeter()

void drawVUMeter ( float rms,
float peak )

Definition at line 331 of file advanced.h.

331 {
332 clearDisplay();
333 CRGBPalette16 palette = getCurrentPalette();
334
335 // RMS level bar
336 int rmsWidth = rms * WIDTH * audioGain.value() * autoGainValue;
337 rmsWidth = MIN(rmsWidth, WIDTH);
338
339 for (int x = 0; x < rmsWidth; x++) {
340 for (int y = HEIGHT/3; y < 2*HEIGHT/3; y++) {
341 uint8_t colorIndex = fl::map_range<int, uint8_t>(x, 0, WIDTH, 0, 255);
342 int ledIndex = xyMap(x, y);
343 if (ledIndex >= 0 && ledIndex < NUM_LEDS) {
344 leds[ledIndex] = ColorFromPalette(palette, colorIndex);
345 }
346 }
347 }
348
349 // Peak indicator
350 int peakX = peak * WIDTH * audioGain.value() * autoGainValue;
351 peakX = MIN(peakX, WIDTH - 1);
352
353 for (int y = HEIGHT/4; y < 3*HEIGHT/4; y++) {
354 int ledIndex = xyMap(peakX, y);
355 if (ledIndex >= 0 && ledIndex < NUM_LEDS) {
356 leds[ledIndex] = CRGB::White;
357 }
358 }
359
360 // Beat indicator
361 if (isBeat && beatFlash) {
362 for (int x = 0; x < WIDTH; x++) {
363 int ledIndex1 = xyMap(x, 0);
364 int ledIndex2 = xyMap(x, HEIGHT - 1);
365 if (ledIndex1 >= 0 && ledIndex1 < NUM_LEDS) leds[ledIndex1] = CRGB::White;
366 if (ledIndex2 >= 0 && ledIndex2 < NUM_LEDS) leds[ledIndex2] = CRGB::White;
367 }
368 }
369}
CRGB leds[NUM_LEDS]
#define NUM_LEDS
int y
Definition simple.h:93
float rms(Slice< const int16_t > data)
Definition simple.h:98
int x
Definition simple.h:92
fl::XYMap xyMap
Definition ColorBoost.h:61
UINumberField palette("Palette", 0, 0, 2)
UICheckbox beatFlash("Beat Flash", true)
bool isBeat
Definition advanced.h:90
#define WIDTH
Definition advanced.h:36
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
@ White
<div style='background:#FFFFFF;width:4em;height:4em;'></div>
Definition crgb.h:703

References audioGain(), autoGainValue, beatFlash(), clearDisplay(), ColorFromPalette(), getCurrentPalette(), HEIGHT, isBeat, leds, MIN, NUM_LEDS, palette(), rms(), CRGB::White, WIDTH, x, xyMap, and y.

Referenced by loop().

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