Skip to content

Audio-reactive glass shapes

A rectangular ui.shape can bind its height to the shared audio spectrum:

ui.glass{ w = 400, h = 240,
ui.shape{ key = "column", w = 20, h = 160, dx = 40, dy = 40,
align = "topLeading", radius = 9, hit = false,
spectrum = { band = 0.5, inset = 4, response = 0.276, bounce = 0.43 },
},
}

band ranges from 0 (low frequencies) to 1 (high frequencies). The existing 60-band analyzer is area-resampled into 24 bands, then interpolated at that position. The height fraction is min(1, level^1.4 * gain) * taper. gain defaults to 1 and accepts 0–10; taper defaults to 1 and accepts 0–1.

The explicit h is the maximum envelope, including inset. The inset defaults to 0 and accepts 0–256 points. Growth preserves the bottom edge of the unrotated rectangle; rotate turns that growth direction with the rectangle. threshold defaults to 0 and accepts 0–256 points; smaller levels are hidden. Width must be positive and height greater than the inset.

Spectrum geometry has one native owner. Column rectangles require hit = false, and no spectrum shape can also use animate, morph, reveal or follow. Their spring defaults to response 0.276 and bounce 0.43, with the usual 0.05–2.5 response and 0–0.95 bounce ranges. Reduce Motion disables interpolation while levels continue to update.

With swell = { w, h } the shape follows the bass instead of a band: the mean of the three lowest of the 24 bands, times gain and capped at 1. It widens by w times that level about its centre and grows h times that level taller, keeping its top edge. band is then optional and taper, inset and threshold are unused. A swell shape keeps its hit area and never hides, and its spring also carries the shape’s own layout changes while it is bound.

A shape with morph.trigger = { beat = true } waits at progress 0 and plays its morph from 0 on each beat: whenever that bass level, before gain, rises above 0.6 after falling to 0.6 or below. A new beat restarts a running morph. The shape needs its own reveal, whose spring plays each beat. Beats are found on the spectrum’s 30 Hz step, so they start only while the same surface shows a spectrum shape, and never with animations off. A beat trigger cannot name a shape or combine with morph.source.

Only mounted bindings and beat triggers request system audio. Removing them removes that demand; the native driver stops when its surface is hidden. Enabling audio for the first time can show macOS’s system-audio recording permission prompt. Vitreus leaves the visualiser off by default. Do not read ctx.data.spectrum just to drive these shapes: the engine uses the shared 30 Hz bands without per-update Luau rendering.