FastLED 3.10.6
Loading...
Searching...
No Matches
mood_painter.h
Go to the documentation of this file.
1// mood_painter.h - mix the three layers, then trails and pulses.
2//
3// The painter owns the float scratch buffers and the post-process state.
4// It is the only thing that writes to the real LED array, and it does so
5// exactly once per frame, after every contribution has been summed in
6// float. That single quantisation is what keeps the output free of stair
7// steps.
8#pragma once
9
10#include "FastLED.h"
11#include "fl/stl/span.h"
12#include "fl/stl/stdint.h"
13#include "fl/stl/vector.h"
14
15#include "layers.h"
16#include "mood_palette.h"
17#include "ring_canvas.h"
18#include "room_sense.h"
19
20namespace mood_ring {
21
23 bool trails = true;
24 bool pulses = true;
25 float trailOverride = -1.0f;
26 float pulseOrigin = 0.0f;
27 float breathGain = 1.0f;
28 float flowGain = 1.0f;
29 float grooveGain = 1.0f;
30};
31
33 public:
36 void draw(const RoomSense &s, fl::u32 nowMs, fl::span<CRGB> out);
37
38 int activePulseCount() const;
39
41
42 private:
43 void ensureBuffers(fl::size n);
44 void mixLayers(const RoomSense &s);
45 void applyTrails(float keep);
46 void emitPulse(float strength, bool downbeat, fl::u32 nowMs);
47 void drawPulses(const MoodPalette &pal, fl::u32 nowMs);
48
52
58
59 float mHueDrift = 0.0f;
60 fl::u32 mLastMs = 0;
61
62 struct Pulse {
63 fl::u32 startMs = 0;
64 float strength = 0.0f;
65 bool downbeat = false;
66 bool active = false;
67 };
68 static const int kMaxPulses = 8;
70};
71
72} // namespace mood_ring
Busy room without a beat.
Definition layers.h:39
Music with a beat.
Definition layers.h:69
fl::vector< RGBf > mBufGroove
fl::vector< RGBf > mTrail
persistence shadow
fl::vector< RGBf > mBufFlow
void drawPulses(const MoodPalette &pal, fl::u32 nowMs)
void mixLayers(const RoomSense &s)
void applyTrails(float keep)
Pulse mPulses[kMaxPulses]
void ensureBuffers(fl::size n)
float mHueDrift
slow hue travel, turns of the wheel
fl::vector< RGBf > mBufBreath
static const int kMaxPulses
void emitPulse(float strength, bool downbeat, fl::u32 nowMs)
void draw(const RoomSense &s, fl::u32 nowMs, fl::span< CRGB > out)
Render one frame into out.
fl::vector< RGBf > mMix
this frame, summed
float trailOverride
< 0 follows the regime blend
Everything a visual is allowed to react to.
Definition room_sense.h:31