Skip to content

WaveEffect

Source: WaveEffect.h

WaveEffect

class WaveEffect
src/light/effects/WaveEffect.h:30

Inherits: EffectBase

Effect of a traveling wave across the layer.

WaveEffect card WaveEffect controls Author: Ewoud Wijma (MoonLight), https://github.com/ewowi/MoonLight/blob/main/src/MoonLight/Nodes/Effects/E_MoonLight.h

Each column plots one point of a moving wave, so the lit points trace a scrolling curve. A fading trail follows it, which is the classic oscilloscope look.

Prior art: MoonLight's Wave effect, whose six shapes and travel this reproduces.

Public Attributes

uint8_t bpm = 30 : Travel speed, as phase advance per minute.

uint8_t fade = 32 : How much of the trail each frame keeps, so 0 clears the old wave at once.

uint8_t type = 2 : Which waveform shape is drawn.

Public Methods

virtual inline const char * tags() const override : Catalog tags for the visual catalog.

virtual inline Dim dimensions() const override : Writes the z=0 plane, which extrude duplicates through a volume.

virtual inline void defineControls() override : Publish the travel speed, the trail and the waveform shape.

virtual inline void prepare() override : Size the persistent trail plane, clearing it when the geometry changed under it.

virtual inline void tick() override : Fade the trail, advance the travel, then plot each column's point of the wave.

Public Static Attributes

constexpr const char * kTypeOptions = {"Sawtooth", "Triangle", "Sine", "Square", "Sin3", "Noise"}

constexpr uint8_t kTypeCount = 6 : How many waveform shapes the select offers.

Public Static Methods

static inline lengthType waveYForTest(uint8_t type, uint8_t phase, lengthType h) : Test seam: the pure waveform map from phase to y, needing no buffer or clock.

More info

The axis convention

The waveform sets a y, so its shape lives on height and width is the travel axis. A 1-tall grid therefore shows no wave. To drive a strip or a row of lights, lay it out as 1xN, the project's 1D convention.

How a column finds its point

Each column's phase is the travel plus its own skew, which is what moves the wave sideways. That phase maps through the selected waveform to a y inside the grid, and that pixel lights. A vertical segment then joins the previous column, so a sawtooth or square reads as one line.