Repository navigation
Description
MoodRing: VisualControlBus + pulse overlay — make a beat do something a speed knob cannot
Follow-up to #2256, first increment after #3884 split examples/MoodRing/ out of examples/AnimartrixRing/.
The gap
MoodRing ships a working sound classifier. It does not yet ship a sound-reactive visual.
Every audio event, in all three states, funnels into a single scalar — engine speed. From examples/MoodRing/sound_orchestrator.cpp, the BpmLocked path:
const float kickPulse = pulseFromEvent(mLastKickMs, 0.50f);
const float snarePulse = pulseFromEvent(mLastSnareMs, 0.25f);
const float downbeatPulse = pulseFromEvent(mLastDownbeatMs, 0.80f);
float pulse = kickPulse + snarePulse + downbeatPulse;
...
float speed = mCfg.bpmLockedBaseSpeed * bpmScale + pulse + phaseBow;
if (mEngine) mEngine->setSpeed(speed);A kick, a snare, and a downbeat are three different musical events that produce three different magnitudes of the same effect: the animation briefly speeds up. The Disorganized and Silence paths likewise return a speed and nothing else.
So the three states differ in which animation plays, not in how the ring behaves. That is structurally the same critique #2256 opens with — "the same visual just runs faster or slower" — and it is still true. What landed replaced one time-warp with three time-warps plus better animation picks.
The fix is not the next roadmap item alphabetically. It is whichever item makes a beat produce something a speed knob cannot.
Scope
This issue covers #2256's PR-B (VisualControlBus) and the pulse half of PR-E (event overlay), deliberately as one unit.
The bus alone is invisible — it is plumbing. Landing it by itself produces no observable change and nothing to evaluate. The pulse overlay is the cheapest possible proof the bus is worth having, and it is the first increment where a kick does something structurally new. Pairing them keeps the PR reviewable while making it demonstrable.
Out of scope, deferred to their own follow-ups: sector emphasis, sparkle, trails tuning, mood-quadrant bias (PR-F), the NoiseRing engine (PR-G), and the patch schema (PR-H).
Design
1. VisualControlBus
The stable authoring surface. State selects which inputs feed which outputs; consumers read only the bus, never the raw detectors. This is the MilkDrop q1..q32 analogue — one intermediate layer so visuals don't churn every time the audio pipeline changes.
struct VisualControlBus {
// Continuous (smoothed, recomputed every frame)
float transportSpeed; // [0.1 .. 4.0] -> FxEngine::setSpeed
float radialPressure; // [0.0 .. 1.0] inward/outward bias
float rotationBias; // [-1.0 .. 1.0] clockwise vs counter
float paletteDrift; // [0.0 .. 1.0] rate of hue travel
float sparkleDensity; // [0.0 .. 1.0] treble-driven shimmer
float decayAmount; // [0.0 .. 1.0] post-process persistence
float lowBand, midBand, highBand; // [0.0 .. 1.0] smoothed band energy
// Event lane (consumed-and-cleared each frame)
float pulseStrength; // 0 when no pulse, else 0.2 .. 1.0
bool pulseIsDownbeat;
bool snareAccent;
bool hihatTick;
};This increment populates every field but only consumes transportSpeed, decayAmount, and the event lane. The rest are wired and observable in the debug readout so the follow-up overlays have a surface to attach to without reopening the derivation.
2. Derivation
All inputs are existing fl::audio::Processor getters — verified present on the current tree (src/fl/audio/audio_processor.h:187-276): getBPM, getSilenceDuration, getTempoBPM, isKick, isSnare, isHiHat, getDownbeatConfidence, getMeasurePhase, getCurrentBeatNumber, getVibeBassAtt/getVibeMidAtt/getVibeTrebAtt, getEqBass/getEqMid/getEqTreble.
// Relative-minus-attenuated: the "punch" signal. This is what makes a
// transient read as a HIT rather than as loudness -- a sustained loud
// passage has bass ~= bassAtt and therefore near-zero punch.
float bassPunch = fl::max(0.0f, p.getVibeBass() - p.getVibeBassAtt());
float midPunch = fl::max(0.0f, p.getVibeMid() - p.getVibeMidAtt());
float trebPunch = fl::max(0.0f, p.getVibeTreb() - p.getVibeTrebAtt());
bus.lowBand = softKnee(p.getEqBass());
bus.midBand = softKnee(p.getEqMid());
bus.highBand = softKnee(p.getEqTreble());
// Hard clamp so a transient cannot fling the engine to an unusable speed.
bus.transportSpeed = clamp(baseSpeed + k_speedGain * bassPunch, 0.1f, 4.0f);
bus.radialPressure = envFollow(0.7f * bus.lowBand + 0.3f * bassPunch,
/*attackMs=*/15, /*releaseMs=*/220);
bus.rotationBias = (bus.midBand - 0.5f) * 2.0f;
if (state == BpmLocked)
bus.rotationBias += 0.3f * sinf(2 * PI * p.getMeasurePhase());
bus.paletteDrift = 0.5f * bus.midBand + 0.35f * bus.highBand
+ 0.15f * (p.getTempoBPM() / 180.0f);
bus.sparkleDensity = envFollow(0.6f * trebPunch + 0.4f * (p.isHiHat() ? 1.f : 0.f),
/*attackMs=*/5, /*releaseMs=*/180);
// Long trails when ambient, crisp when locked to a beat.
bus.decayAmount = (state == Silence) ? 0.85f
: (state == BpmLocked) ? 0.35f
: 0.60f;
// Event lane is BpmLocked-only; Disorganized expresses itself continuously.
if (state == BpmLocked) {
if (p.isKick()) bus.pulseStrength = 1.00f;
else if (onValidatedBeat()) bus.pulseStrength = 0.60f;
bus.pulseIsDownbeat = (p.getCurrentBeatNumber() == 1);
bus.snareAccent = p.isSnare();
bus.hihatTick = p.isHiHat();
}softKnee and envFollow are ~10 lines each. No new dependency.
3. Per-state policy
| Bus signal | Silence | Disorganized | BpmLocked |
|---|---|---|---|
transportSpeed |
0.25 fixed | base + 0.8*bassPunch |
base * BPM/120 + 0.4*bassPunch |
radialPressure |
slow breathing LFO | lowBand weighted |
clamped, pulse-driven |
paletteDrift |
0.05 fixed | mid+treb weighted | step on downbeat, else 0 |
sparkleDensity |
0 | treble-punch driven | hihat-driven |
decayAmount |
0.85 | 0.60 | 0.35 |
pulseStrength |
0 | 0 | kick / validated beat |
4. Pulse overlay
Runs after fxEngine.draw(millis(), leds) and before FastLED.show(). Pure post-process on the 1D ring — no src/fl/ changes, and engine-agnostic by construction, so NoiseRing inherits it for free later.
class RingOverlay {
public:
void apply(fl::span<CRGB> leds, const VisualControlBus &bus, fl::u32 nowMs);
private:
void compositeTrails(fl::span<CRGB> leds, float decay);
void emitPulse(fl::span<CRGB> leds, float strength, bool downbeat);
CRGB mTrail[NUM_LEDS]; // persistence shadow buffer
};Two passes this increment:
- Trails —
trail[i] = scale8(trail[i], 255*(1-decayAmount)) + (leds[i] >> 2), blended back ontoleds. The feedback echo is what makes a beat feel musical rather than merely visible, and it is what givesdecayAmountits per-state meaning. - Pulse ring — on
pulseStrength > 0, paint an expanding Gaussian band from a configurable origin index, wideningk * elapsedpixels and fading over its lifetime. Downbeats get a wider band plus a palette flip. Multiple in-flight pulses composite additively so a fast passage reads as overlapping rings, not as one retriggered ring.
Per the span convention in agents/docs/cpp-standards.md:137, the overlay takes fl::span<CRGB> rather than pointer-plus-count. Consistent with the getAverageBrightness signature adopted in #3884.
5. Files
examples/MoodRing/
MoodRing.ino EDIT: derive bus, apply overlay before show()
sound_orchestrator.{h,cpp} EDIT: emit a VisualControlBus instead of a float
visual_control_bus.{h,cpp} NEW
ring_overlay.{h,cpp} NEW
No src/fl/** changes.
6. UI additions
[Visual Control Bus]
Base Speed 0..4 default 1.0
Bass Punch Gain 0..3 default 1.5
[Overlay]
[x] Trails on
[x] Pulse Ring on (BpmLocked only)
Pulse Origin Offset 0..244 default 0
Trail Decay Override -1..1 default -1 (use bus value)
[Debug]
[x] Print bus every N frames
Acceptance criteria
- A kick in
BpmLockedproduces a visible travelling ring, not a speed change. - Downbeats are visibly larger than ordinary beats.
- A sustained loud passage with no transients produces little pulse activity —
punchis relative-minus-attenuated, so loudness alone must not fake a beat. Silencevisibly holds longer trails thanBpmLocked; the difference is legible without reading the debug output.- Turning every overlay toggle off reproduces today's behaviour exactly, so the overlay is provably additive.
- No
src/fl/**diff.
Test plan
bash test --cpp— unit + example host build, MoodRing included.bash compile wasm --examples MoodRing— the sketch users actually run.- Manual: drive the WASM build with a track that has an unambiguous four-on-the-floor kick, confirm one ring per kick and a wider ring per bar.
- Manual: drive it with sustained non-rhythmic noise, confirm the ring does not emit a pulse grid.
Corrections to #2256
Three parts of the design doc now contradict the tree and would misdirect anyone implementing from it verbatim:
- §6 file plan targets the wrong directory. It lists
examples/AnimartrixRing/for the orchestrator, bus, and overlay files. As of refactor(examples): split MoodRing out of AnimartrixRing #3884 that work belongs inexamples/MoodRing/; AnimartrixRing is now a pure sampling demo with no audio. - §6 says
audio_reactive.{h,cpp}"KEEP: legacy path, gated by UI toggle". Those files are deleted. feat(examples/animartrix): 3-state audio orchestrator with hysteresis (Closes #2713) #2809 superseded that path with the orchestrator and refactor(examples): split MoodRing out of AnimartrixRing #3884 removed the dead code. §7's "Enable Sound Orchestrator — default off, preserves legacy path" is likewise obsolete: there is no legacy path, and MoodRing defaults the orchestrator on. - §1's enum gotcha is stale. It warns that only
RGB_BLOBS5is reachable and that rotatingRGB_BLOBS/_2/_3/_4requires extending the enum and registry.AnimartrixAnimnow carries all five (src/fl/fx/2d/animartrix.hpp:33-37), so that work is already done — a task someone would otherwise repeat for no reason.
Refs #2256
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Aug 17, 2026
Implemented in #3886.
Correcting acceptance criterion 5. I wrote "turning every overlay toggle off reproduces today's behaviour exactly, so the overlay is provably additive." That criterion was wrong, and #3886 does not meet it as written — flagging rather than quietly dropping it.
Two intentional changes to the base signal path make it unmeetable:
Disorganizednow keys offbassPunchrather than rawvibeBass, so loudness no longer drives speed the way it did.What the criterion was reaching for, and what does hold: with both overlay toggles off, the strip contains exactly what the engine drew. The overlay passes are provably additive. That is the testable property; the original phrasing conflated it with "the whole sketch is unchanged".
Criterion 5 should read:
The other five criteria stand as written.