268 {
271
272 int samplesPerPixel = pcm.
size() /
WIDTH;
274
275 for (
size_t x = 0;
x <
WIDTH;
x++) {
276 size_t sampleIndex =
x * samplesPerPixel;
277 if (sampleIndex >= pcm.
size())
break;
278
279
280 float sample = float(pcm[sampleIndex]) / 32768.0f;
281
282
284 float logAmplitude = 0.0f;
285
286 if (absSample > 0.001f) {
287
290 }
291
292
293 logAmplitude =
fl::powf(logAmplitude, 0.7f);
294
295
296 int amplitude = int(logAmplitude * (
HEIGHT / 2));
298
299
300 if (sample < 0) amplitude = -amplitude;
301
302
305
306
309 }
310
311
312 if (amplitude == 0) {
313
314 int ledIndex =
xyMap(
x, centerY);
315 if (ledIndex >= 0 && ledIndex <
NUM_LEDS) {
317 }
318 } else {
319
320 int startY = (amplitude > 0) ? centerY : centerY + amplitude;
321 int endY = (amplitude > 0) ? centerY + amplitude : centerY;
322
323 for (
int y = startY;
y <= endY;
y++) {
326 if (ledIndex >= 0 && ledIndex <
NUM_LEDS) {
327
329 if (
y == startY ||
y == endY) {
331 }
332 leds[ledIndex] = pixelColor;
333 }
334 }
335 }
336 }
337 }
338}
constexpr enable_if< is_fixed_point< T >::value, T >::type abs(T x) FL_NOEXCEPT
UINumberField palette("Palette", 0, 0, 2)
fl::CRGBPalette16 getCurrentPalette()
fl::UISlider audioGain("Audio Gain", 1.0f, 0.1f, 5.0f, 0.1f)
constexpr fl::size size() const FL_NOEXCEPT
CRGB ColorFromPalette(const CRGBPalette16 &pal, fl::u8 index, fl::u8 brightness, TBlendType blendType)
float powf(float base, float exponent) FL_NOEXCEPT
FASTLED_FORCE_INLINE U map_range(T value, T in_min, T in_max, U out_min, U out_max) FL_NOEXCEPT
float log10f(float value) FL_NOEXCEPT
CRGB sample(const CRGB *grid, const XYMap &xyMap, float x, float y, SampleMode mode)
Sample a pixel from a 2D CRGB grid at floating-point coordinates.
float fabsf(float value) FL_NOEXCEPT
constexpr enable_if< is_fixed_point< T >::value, T >::type clamp(T x, T lo, T hi) FL_NOEXCEPT
CRGB & fadeToBlackBy(u8 fadefactor) FL_NOEXCEPT
fadeToBlackBy is a synonym for nscale8(), as a fade instead of a scale
Representation of an 8-bit RGB pixel (Red, Green, Blue)