FastLED 3.9.15
Loading...
Searching...
No Matches

◆ loop()

void loop ( )

Definition at line 46 of file AudioUrl.ino.

46 {
47 // Drain all available audio samples, keeping track of peak volume.
48 int32_t peak = 0;
49 while (fl::audio::Sample sample = audio.next()) {
50 for (size_t i = 0; i < sample.pcm().size(); ++i) {
51 int32_t v = abs(sample.pcm()[i]);
52 if (v > peak) {
53 peak = v;
54 }
55 }
56 }
57
58 // Map peak amplitude to brightness (0-255).
59 uint8_t brightness = map(peak, 0, 32768, 0, 255);
61
62 FastLED.show();
63}
fl::UIAudio audio("Audio Input")
#define NUM_LEDS
fl::CRGB leds[NUM_LEDS]
fl::UISlider brightness("Brightness", BRIGHTNESS, 0, 255)
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
constexpr enable_if< is_fixed_point< T >::value, T >::type abs(T x) FL_NOEXCEPT
void fill_solid(CRGB *targetArray, int numToFill, const CRGB &color) FL_NOEXCEPT
Fill a range of LEDs with a solid color.
Definition fill.cpp.hpp:9
fl::hsv8 CHSV
Definition chsv.h:11
MapRedBlackTree< Key, T, Compare, fl::allocator_slab< char > > map
Definition map.h:283
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.
Definition sample.cpp.hpp:9
fl::i32 int32_t
Definition s16x16x4.h:220
unsigned char uint8_t
Definition s16x16x4.h:209

References abs(), audio, brightness, FastLED, fill_solid(), leds, and NUM_LEDS.

+ Here is the call graph for this function: