174 {
177
179
180 for (
size_t band = 0; band <
NUM_BANDS && band <
fft->bins_db.size(); band++) {
181 float magnitude =
fft->bins_db[band];
182
183
184 magnitude = magnitude / 100.0f;
186
187
190
191
193 magnitude =
fl::clamp(magnitude, 0.0f, 1.0f);
194
195 int barHeight = magnitude *
HEIGHT;
196 int xStart = band * barWidth;
197
198 for (
int x = 0;
x < barWidth - 1;
x++) {
199 for (
int y = 0;
y < barHeight;
y++) {
200 uint8_t colorIndex = fl::map_range<float, uint8_t>(
201 float(
y) /
HEIGHT, 0, 1, 0, 255
202 );
204
205 int ledIndex =
xyMap(xStart +
x,
y);
206 if (ledIndex >= 0 && ledIndex <
NUM_LEDS) {
207 leds[ledIndex] = color;
208 }
209
212 if (mirrorIndex >= 0 && mirrorIndex <
NUM_LEDS) {
213 leds[mirrorIndex] = color;
214 }
215 }
216 }
217 }
218 }
219}
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)