Visualization: Radial Spectrum
| 230 | |
| 231 | // Visualization: Radial Spectrum |
| 232 | void drawRadialSpectrum(fl::audio::fft::Bins* fft, float /* peak */) { |
| 233 | clearDisplay(); |
| 234 | fl::CRGBPalette16 palette = getCurrentPalette(); |
| 235 | |
| 236 | int centerX = WIDTH / 2; |
| 237 | int centerY = HEIGHT / 2; |
| 238 | |
| 239 | auto bands = fft->db(); |
| 240 | |
| 241 | for (size_t angle = 0; angle < 360; angle += 6) { // Reduced resolution |
| 242 | size_t band = (angle / 6) % NUM_BANDS; |
| 243 | if (band >= bands.size()) continue; |
| 244 | |
| 245 | float magnitude = bands[band] / 100.0f; |
| 246 | magnitude = fl::max(0.0f, magnitude - noiseFloor.value()); |
| 247 | magnitude *= audioGain.value() * autoGainValue; |
| 248 | magnitude = fl::clamp(magnitude, 0.0f, 1.0f); |
| 249 | |
| 250 | int radius = magnitude * (fl::min(WIDTH, HEIGHT) / 2); |
| 251 | |
| 252 | for (int r = 0; r < radius; r++) { |
| 253 | int x = centerX + (r * fl::cosf(angle * FL_PI / 180.0f)); |
| 254 | int y = centerY + (r * fl::sinf(angle * FL_PI / 180.0f)); |
| 255 | |
| 256 | if (x >= 0 && x < WIDTH && y >= 0 && y < HEIGHT) { |
| 257 | uint8_t colorIndex = fl::map_range<int, uint8_t>(r, 0, radius, 255, 0); |
| 258 | int ledIndex = xyMap(x, y); |
| 259 | if (ledIndex >= 0 && ledIndex < NUM_LEDS) { |
| 260 | leds[ledIndex] = ColorFromPalette(palette, colorIndex + hue); |
| 261 | } |
| 262 | } |
| 263 | } |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | // Visualization: Logarithmic Waveform (prevents saturation) |
| 268 | void drawWaveform(const fl::span<const int16_t>& pcm, float /* peak */) { |
no test coverage detected