LED meter
glint · Examples · Tutorials · Gallery
A hardware-style spectrum analyser: 32 bars of LEDs, green to red, with peak-hold dots that fall slowly (a tiny feedback pass remembers the peaks).
Audio-reactive: it moves with music from a microphone, line-in or a file.

An example in glint, a free live shader editor in the browser: the GLSL code floats over the running picture and recompiles as you type.
The code
2 passes, drawn in this order each frame, in GLSL.
Peaks: fragment shader
#version 300 es
precision highp float;
uniform float time;
uniform vec2 resolution;
uniform vec3 spectrum;
uniform float beat;
uniform float beatTime;
uniform int beatCount;
uniform sampler2D fft;
uniform sampler2D feedback;
uniform float timeDelta;
in vec2 v_texcoord;
out vec4 fragColor;
// 1 on each kick, fading; without audio, a steady pulse twice a second.
float kick() { return beatCount > 0 ? beat : pow(1.0 - fract(time * 2.0), 4.0); }
// Seconds since the last kick, and which kick it was (the same fallback).
float sinceKick() { return beatCount > 0 ? beatTime : fract(time * 2.0) / 2.0; }
float kickId() { return beatCount > 0 ? float(beatCount) : floor(time * 2.0); }
// One FFT bin, 0..1 across the spectrum (bass on the left).
float bin(float x) { return texture(fft, vec2(x, 0.25)).r; }
float level(float x) { return bin(pow(x, 2.0) * 0.55 + 0.005); }
void main() {
// One value per bar: the higher of this frame's level and the falling peak.
float x = (floor(gl_FragCoord.x / resolution.x * 32.0) + 0.5) / 32.0;
float now = level(x);
// Without audio: a gentle sweep so it still does something.
if (beatCount == 0) now = max(now, 0.5 + 0.4 * sin(time * 2.0 - x * 9.0) * sin(time * 0.7 + x * 3.0));
float peak = texture(feedback, vec2(x, 0.5)).r - timeDelta * 0.25;
fragColor = vec4(max(peak, now), now, 0.0, 1.0);
}Meter: fragment shader
#version 300 es
precision highp float;
uniform sampler2D prevPass;
uniform vec2 resolution;
in vec2 v_texcoord;
out vec4 fragColor;
void main() {
vec2 st = gl_FragCoord.xy / resolution;
vec2 p = vec2(st.x * 1.1 - 0.05, st.y * 1.15 - 0.08);
vec3 col = vec3(0.02, 0.02, 0.03);
if (p.x > 0.0 && p.x < 1.0 && p.y > 0.0 && p.y < 1.0) {
float barX = (floor(p.x * 32.0) + 0.5) / 32.0;
vec2 v = texture(prevPass, vec2(barX, 0.5)).rg;
float seg = floor(p.y * 24.0);
float y = (seg + 0.5) / 24.0;
vec2 cell = vec2(fract(p.x * 32.0), fract(p.y * 24.0));
float led = step(0.12, cell.x) * step(cell.x, 0.88) * step(0.15, cell.y) * step(cell.y, 0.85);
vec3 hue = y < 0.6 ? vec3(0.2, 1.0, 0.3) : y < 0.85 ? vec3(1.0, 0.85, 0.1) : vec3(1.0, 0.2, 0.15);
float on = step(y, v.g);
float peak = step(abs(y - floor(v.r * 24.0) / 24.0 - 0.5 / 24.0), 0.5 / 24.0);
col += led * hue * (0.07 + 0.93 * max(on, peak));
}
fragColor = vec4(col, 1.0);
}More Audio-reactive examples
Kick ripples · Beat kaleidoscope · Lissajous scope · Strobe shapes · Bass blob · Vinyl · Sonar · Neon runner