16#if !SKETCH_HAS_LOTS_OF_MEMORY
45#define NUM_LEDS ((WIDTH) * (HEIGHT))
46#define IS_SERPINTINE false
47#define TIME_ANIMATION 1000
51UICheckbox enableVolumeVis(
"Enable volume visualization",
false);
52UICheckbox enableRMS(
"Enable RMS visualization",
false);
53UICheckbox enableFFT(
"Enable FFT visualization",
true);
55UIButton advanceFrame(
"Advance frame");
56UISlider decayTimeSeconds(
"Fade time Seconds", .1, 0, 4, .02);
57UISlider attackTimeSeconds(
"Attack time Seconds", .1, 0, 4, .02);
58UISlider outputTimeSec(
"outputTimeSec", .17, 0, 2, .01);
61UISlider fadeToBlack(
"Fade to black by", 5, 0, 20, 1);
64 decayTimeSeconds.value(), outputTimeSec.value(),
90 const int N = data.
size();
91 for (
int i = 0; i < N; ++i) {
92 int32_t x32 = int32_t(data[i]);
95 float rms = sqrt(
float(sumSq) / N);
100 Serial.begin(115200);
105 auto screenmap = ledsXY.toScreenMap();
106 screenmap.setDiameter(.2);
108 decayTimeSeconds.onChanged([](
float value) {
109 audioFadeTracker.setDecayTime(value);
112 attackTimeSeconds.onChanged([](
float value) {
113 audioFadeTracker.setAttackTime(value);
116 outputTimeSec.onChanged([](
float value) {
117 audioFadeTracker.setOutputTime(value);
121 .setScreenMap(screenmap);
126 if (fadeToBlack.as_int()) {
128 for (
int i = 0; i <
NUM_LEDS; ++i) {
129 auto &c = framebuffer[i];
135 CRGB* row1 = &framebuffer[frameBufferXY(0,
y)];
136 CRGB* row2 = &framebuffer[frameBufferXY(0,
y - 1)];
137 memcpy(row1, row2,
WIDTH *
sizeof(
CRGB));
139 CRGB* row = &framebuffer[frameBufferXY(0, 0)];
148 if (advanceFrame.isPressed()) {
161 static uint32_t frame = 0;
166 bool do_frame = doFrame();
172 float fade = audioFadeTracker(sample.pcm().data(), sample.pcm().size());
175 soundLevelMeter.processBlock(sample.pcm());
177 auto dbfs = soundLevelMeter.getDBFS();
180 for (
int i = 0; i < sample.pcm().size(); ++i) {
181 int32_t
x =
ABS(sample.pcm()[i]);
200 auto max_x = fftOut.bins_raw.size() - 1;
201 for (
int i = 0; i < fftOut.bins_raw.size(); ++i) {
203 auto v = fftOut.bins_db[i];
214 c.fadeToBlackBy(255 - heatIndex);
215 framebuffer[frameBufferXY(
x, 0)] = c;
220 if (enableVolumeVis) {
221 framebuffer[frameBufferXY(
x,
HEIGHT / 2)] =
CRGB(0, 255, 0);
225 float rms = sample.rms();
229 framebuffer[frameBufferXY(rms,
HEIGHT * 3 / 4)] =
CRGB(0, 0, 255);
232 uint16_t fade_width = fade * (
WIDTH - 1);
235 int index = frameBufferXY(fade_width, h);
236 auto c =
CRGB(255, 255, 0);
237 framebuffer[index] = c;
UITitle title("Chromancer")
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
central include file for FastLED, defines the CFastLED class/object
Tracks a smoothed peak with attack, decay, and output-inertia time-constants.
LED controller for WS2812 LEDs with GRB color order.
CRGB ColorFromPalette(const CRGBPalette16 &pal, uint8_t index, uint8_t brightness, TBlendType blendType)
const TProgmemRGBPalette16 HeatColors_p
Approximate "black body radiation" palette, akin to the FastLED HeatColor() function.
void downscale(const CRGB *src, const XYMap &srcXY, CRGB *dst, const XYMap &dstXY)
FASTLED_FORCE_INLINE T clamp(T value, T min, T max)
FASTLED_FORCE_INLINE U map_range(T value, T in_min, T in_max, U out_min, U out_max)
Implements a simple red square effect for 2D LED grids.
CRGB & fadeToBlackBy(uint8_t fadefactor)
fadeToBlackBy is a synonym for nscale8(), as a fade instead of a scale
Representation of an RGB pixel (Red, Green, Blue)
UIDescription description("Advanced layered and blended wave effects.")