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

◆ drawVUMeter()

void drawVUMeter ( float rms,
float peak )

Definition at line 329 of file advanced.h.

329 {
330 clearDisplay();
331 CRGBPalette16 palette = getCurrentPalette();
332
333 // RMS level bar
334 int rmsWidth = rms * WIDTH * audioGain.value() * autoGainValue;
335 rmsWidth = MIN(rmsWidth, WIDTH);
336
337 for (int x = 0; x < rmsWidth; x++) {
338 for (int y = HEIGHT/3; y < 2*HEIGHT/3; y++) {
339 uint8_t colorIndex = fl::map_range<int, uint8_t>(x, 0, WIDTH, 0, 255);
340 int ledIndex = xyMap(x, y);
341 if (ledIndex >= 0 && ledIndex < NUM_LEDS) {
342 leds[ledIndex] = ColorFromPalette(palette, colorIndex);
343 }
344 }
345 }
346
347 // Peak indicator
348 int peakX = peak * WIDTH * audioGain.value() * autoGainValue;
349 peakX = MIN(peakX, WIDTH - 1);
350
351 for (int y = HEIGHT/4; y < 3*HEIGHT/4; y++) {
352 int ledIndex = xyMap(peakX, y);
353 if (ledIndex >= 0 && ledIndex < NUM_LEDS) {
354 leds[ledIndex] = CRGB::White;
355 }
356 }
357
358 // Beat indicator
359 if (isBeat && beatFlash) {
360 for (int x = 0; x < WIDTH; x++) {
361 int ledIndex1 = xyMap(x, 0);
362 int ledIndex2 = xyMap(x, HEIGHT - 1);
363 if (ledIndex1 >= 0 && ledIndex1 < NUM_LEDS) leds[ledIndex1] = CRGB::White;
364 if (ledIndex2 >= 0 && ledIndex2 < NUM_LEDS) leds[ledIndex2] = CRGB::White;
365 }
366 }
367}
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:57
UINumberField palette("Palette", 0, 0, 2)
UICheckbox beatFlash("Beat Flash", true)
bool isBeat
Definition advanced.h:88
#define WIDTH
Definition advanced.h:34
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
@ 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: