19#if !SKETCH_HAS_LOTS_OF_MEMORY
49#define NUM_LEDS ((WIDTH) * (HEIGHT))
50#define IS_SERPINTINE false
51#define TIME_ANIMATION 1000
56UICheckbox enableVolumeVis(
"Enable volume visualization",
false);
57UICheckbox enableRMS(
"Enable RMS visualization",
false);
58UICheckbox enableFFT(
"Enable FFT visualization",
true);
60UIButton advanceFrame(
"Advance frame");
61UISlider decayTimeSeconds(
"Fade time Seconds", .1, 0, 4, .02);
62UISlider attackTimeSeconds(
"Attack time Seconds", .1, 0, 4, .02);
63UISlider outputTimeSec(
"outputTimeSec", .17, 0, 2, .01);
66UISlider fadeToBlack(
"Fade to black by", 5, 0, 20, 1);
69 decayTimeSeconds.value(), outputTimeSec.value(),
95 const int N = data.
size();
96 for (
int i = 0; i < N; ++i) {
97 int32_t x32 = int32_t(data[i]);
100 float rms = sqrt(
float(sumSq) / N);
105 Serial.begin(115200);
110 auto screenmap = ledsXY.toScreenMap();
111 screenmap.setDiameter(.2);
113 decayTimeSeconds.onChanged([](
float value) {
114 audioFadeTracker.setDecayTime(value);
117 attackTimeSeconds.onChanged([](
float value) {
118 audioFadeTracker.setAttackTime(value);
121 outputTimeSec.onChanged([](
float value) {
122 audioFadeTracker.setOutputTime(value);
126 .setScreenMap(screenmap);
131 if (fadeToBlack.as_int()) {
133 for (
int i = 0; i <
NUM_LEDS; ++i) {
134 auto &c = framebuffer[i];
140 CRGB* row1 = &framebuffer[frameBufferXY(0,
y)];
141 CRGB* row2 = &framebuffer[frameBufferXY(0,
y - 1)];
142 memcpy(row1, row2,
WIDTH *
sizeof(
CRGB));
144 CRGB* row = &framebuffer[frameBufferXY(0, 0)];
153 if (advanceFrame.isPressed()) {
167 bool do_frame = doFrame();
173 float fade = audioFadeTracker(sample.pcm().data(), sample.pcm().size());
176 soundLevelMeter.processBlock(sample.pcm());
178 auto dbfs = soundLevelMeter.getDBFS();
182 for (
int i = 0; i < sample.pcm().size(); ++i) {
183 int32_t
x =
ABS(sample.pcm()[i]);
202 auto max_x = fftOut.bins_raw.size() - 1;
204 for (
int i = 0; i < fftOut.bins_raw.size(); ++i) {
206 auto v = fftOut.bins_db[i];
217 c.fadeToBlackBy(255 - heatIndex);
218 framebuffer[frameBufferXY(
x, 0)] = c;
223 if (enableVolumeVis) {
224 framebuffer[frameBufferXY(
x,
HEIGHT / 2)] =
CRGB(0, 255, 0);
228 float rms = sample.rms();
232 framebuffer[frameBufferXY(rms,
HEIGHT * 3 / 4)] =
CRGB(0, 0, 255);
235 uint16_t fade_width = fade * (
WIDTH - 1);
238 int index = frameBufferXY(fade_width, h);
239 auto c =
CRGB(255, 255, 0);
240 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)
#define FASTLED_UNUSED(x)
UIDescription description("Advanced layered and blended wave effects.")