176 {
179
181
182 for (
size_t band = 0; band <
NUM_BANDS && band <
fft->bins_db.size(); band++) {
183 float magnitude =
fft->bins_db[band];
184
185
186 magnitude = magnitude / 100.0f;
188
189
192
193
195 magnitude =
fl::clamp(magnitude, 0.0f, 1.0f);
196
197 int barHeight = magnitude *
HEIGHT;
198 int xStart = band * barWidth;
199
200 for (
int x = 0;
x < barWidth - 1;
x++) {
201 for (
int y = 0;
y < barHeight;
y++) {
202 uint8_t colorIndex = fl::map_range<float, uint8_t>(
203 float(
y) /
HEIGHT, 0, 1, 0, 255
204 );
206
207 int ledIndex =
xyMap(xStart +
x,
y);
208 if (ledIndex >= 0 && ledIndex <
NUM_LEDS) {
209 leds[ledIndex] = color;
210 }
211
214 if (mirrorIndex >= 0 && mirrorIndex <
NUM_LEDS) {
215 leds[mirrorIndex] = color;
216 }
217 }
218 }
219 }
220 }
221}
UINumberField palette("Palette", 0, 0, 2)
static const int NUM_BANDS
float fftSmooth[NUM_BANDS]
UISlider noiseFloor("Noise Floor", 0.1f, 0.0f, 1.0f, 0.01f)
UICheckbox mirrorMode("Mirror Mode", false)
UISlider audioGain("Audio Gain", 1.0f, 0.1f, 5.0f, 0.1f)
CRGBPalette16 getCurrentPalette()
CRGB ColorFromPalette(const CRGBPalette16 &pal, fl::u8 index, fl::u8 brightness, TBlendType blendType)
FASTLED_FORCE_INLINE T clamp(T value, T min, T max)
Representation of an RGB pixel (Red, Green, Blue)