The input is not "music".
The input is not "music". It is the room: conversation, silence, laughter, clatter, a song coming on. The sketch is two halves with one struct between them:
There is no state machine. The weights move with asymmetric attack and release, so the ring wakes on the first sound, settles slowly into calm, and cross-fades between looks because the mix is continuous.
#define FASTLED_ESP32_USE_CLOCKLESS_SPI
#include "FastLED.h"
#if defined(FL_IS_TEENSY)
#include <Audio.h>
#endif
#include "auto_brightness.h"
#include "ring_screenmap.h"
#define NUM_LEDS 244
#ifndef PIN_DATA
#define PIN_DATA 3
#endif
#define BRIGHTNESS 8
#define GRID_WIDTH 16
#define GRID_HEIGHT 16
#define LED_DIAMETER 0.15f
"A ring that listens to the room and lights the room back. Grant mic "
"access, or drag in a .wav.");
100, 1);
0, 100, 1);
auto input =
audio.audioInput();
if (input) {
fl::printf(
"MoodRing: audio routed via FastLED.add() (auto-pump)\n");
}
}
fl::printf(
"MoodRing: audio using manual pump (fallback)\n");
}
Serial.println(
"MoodRing setup complete");
}
}
fl::printf(
"MoodRing %s c/f/g=%.2f/%.2f/%.2f pres=%.2f en=%.2f tr=%+.2f "
"punch=%.2f shim=%.2f bands=%.2f/%.2f/%.2f bpm=%.0f conf=%.2f "
"warm=%.2f ar=%.2f pulses=%d\n",
}
}
}
} else {
}
static const char *sLastRegime = "";
const char *regime =
gListener->regimeName();
if (regime != sLastRegime) {
sLastRegime = regime;
}
static fl::u32 sFrame = 0;
}
} else {
}
FastLED.setBrightness(finalBrightness);
}
fl::UIAudio audio("Audio Input")
fl::UIDescription description("Demo of the Animatrix effects. @author of fx is StefanPetrick")
fl::UISlider brightness("Brightness", BRIGHTNESS, 0, 255)
uint8_t applyBrightnessCompression(float inputBrightnessPercent, uint8_t maxBrightness, float lowThreshold, float highThreshold)
float getAverageBrightness(fl::span< const CRGB > leds)
fl::ScreenMap makeRingScreenMap(int numLeds, int gridWidth, int gridHeight, float diameter)
fl::UISlider autoBrightnessLowThreshold("Auto Brightness Low Threshold", 8, 0, 100, 1)
fl::UICheckbox autoBrightness("Auto Brightness", true)
fl::UISlider autoBrightnessHighThreshold("Auto Brightness High Threshold", 22, 0, 100, 1)
fl::UISlider autoBrightnessMax("Auto Brightness Max", 84, 0, 255, 1)
FASTLED_TITLE("AnimartrixRing")
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
fl::UICheckbox pulses("Beat Pulses", true)
fl::UISlider pulseOrigin("Pulse Origin (turns)", 0.0f, 0.0f, 1.0f, 0.01f)
fl::UISlider presenceReleaseMs("Settle Into Calm (ms)", 900, 200, 4000, 50)
fl::shared_ptr< mood_ring::RoomListener > gListener
mood_ring::MoodPainter gPainter
fl::UICheckbox listen("Listen", true)
fl::UISlider grooveGain("Layer: Groove", 1.0f, 0.0f, 1.0f, 0.05f)
fl::UISlider grooveEnter("Groove Enter Confidence", 0.60f, 0.1f, 1.0f, 0.01f)
fl::UISlider trailOverride("Trail Keep Override", -1.0f, -1.0f, 0.98f, 0.02f)
fl::UISlider breathGain("Layer: Breath", 1.0f, 0.0f, 1.0f, 0.05f)
static void applyUiTuning()
fl::shared_ptr< fl::audio::Processor > gProcessor
fl::UICheckbox trails("Trails", true)
fl::UICheckbox debugPrint("Debug: Print Sense", false)
fl::UISlider grooveExit("Groove Exit Confidence", 0.35f, 0.0f, 0.9f, 0.01f)
fl::UISlider punchGain("Punch Gain", 1.5f, 0.0f, 3.0f, 0.05f)
static void printSense(const mood_ring::RoomSense &s)
fl::UISlider flowGain("Layer: Flow", 1.0f, 0.0f, 1.0f, 0.05f)
fl::UISlider grooveAttackMs("Trust A Beat After (ms)", 800, 100, 4000, 50)
@ TypicalLEDStrip
Typical values for SMD5050 LEDs.
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
void printf(const char *format) FL_NO_EXCEPT
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.
shared_ptr< T > make_shared(Args &&... args) FL_NO_EXCEPT
float shimmer
treble transient
float punchGain
scales the bass transient
float arousal
0 calm .. 1 energetic
float punch
bass transient (a hit, not loudness)
float grooveAttackMs
how slowly we start trusting a beat
float presenceReleaseMs
how slowly silence settles in
float energy
smoothed loudness
float trend
[-1, 1] falling .. rising
float grooveExit
confidence where groove is fully off
float presence
sound is present (silence -> 0)
float warmth
0 cool .. 1 warm, from valence
float grooveEnter
confidence where groove is fully on
float trailOverride
< 0 follows the regime blend
Everything a visual is allowed to react to.
Everything the UI is allowed to tune on the listening side.
Aggregator header for the fl/ui/ family of per-element UI types.