Visualization: VU Meter
| 339 | |
| 340 | // Visualization: VU Meter |
| 341 | void drawVUMeter(float rms, float peak) { |
| 342 | clearDisplay(); |
| 343 | fl::CRGBPalette16 palette = getCurrentPalette(); |
| 344 | |
| 345 | // RMS level bar |
| 346 | int rmsWidth = rms * WIDTH * audioGain.value() * autoGainValue; |
| 347 | rmsWidth = fl::min(rmsWidth, WIDTH); |
| 348 | |
| 349 | for (int x = 0; x < rmsWidth; x++) { |
| 350 | for (int y = HEIGHT/3; y < 2*HEIGHT/3; y++) { |
| 351 | uint8_t colorIndex = fl::map_range<int, uint8_t>(x, 0, WIDTH, 0, 255); |
| 352 | int ledIndex = xyMap(x, y); |
| 353 | if (ledIndex >= 0 && ledIndex < NUM_LEDS) { |
| 354 | leds[ledIndex] = ColorFromPalette(palette, colorIndex); |
| 355 | } |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | // Peak indicator |
| 360 | int peakX = peak * WIDTH * audioGain.value() * autoGainValue; |
| 361 | peakX = fl::min(peakX, WIDTH - 1); |
| 362 | |
| 363 | for (int y = HEIGHT/4; y < 3*HEIGHT/4; y++) { |
| 364 | int ledIndex = xyMap(peakX, y); |
| 365 | if (ledIndex >= 0 && ledIndex < NUM_LEDS) { |
| 366 | leds[ledIndex] = fl::CRGB::White; |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | // Beat indicator |
| 371 | if (isBeat && beatFlash) { |
| 372 | for (int x = 0; x < WIDTH; x++) { |
| 373 | int ledIndex1 = xyMap(x, 0); |
| 374 | int ledIndex2 = xyMap(x, HEIGHT - 1); |
| 375 | if (ledIndex1 >= 0 && ledIndex1 < NUM_LEDS) leds[ledIndex1] = fl::CRGB::White; |
| 376 | if (ledIndex2 >= 0 && ledIndex2 < NUM_LEDS) leds[ledIndex2] = fl::CRGB::White; |
| 377 | } |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | // Visualization: Matrix Rain |
| 382 | void drawMatrixRain(float peak) { |
no test coverage detected