InputLightweight
Audio analysis
A track studied ahead of time: beats, loudness.
Studying a music track ahead of time: where the beats are, how loud each part is, where the drop comes. Visuals can then land on the beat in place of reacting late. Beat detection fails on music without a steady kick.
- Breaks when
- beat detection is unreliable off 4/4
- Also called
- beat detection, Meyda, onset detection
Prompts
Precomputed beat map for a music page
Analyze an MP3 offline with the Web Audio API in a Node script (decode with an OfflineAudioContext or a decoder library): compute per-frame energy in 4 bands, detect onsets (spectral flux with adaptive threshold), estimate BPM by autocorrelation, and write beats.json (times in seconds, band energies at 30 fps). In the page, schedule visuals 100 ms before each beat so the pulse lands on the sound rather than after it.
Live features with Meyda
Use Meyda on an AudioContext source with bufferSize 1024: rms, spectralCentroid, zcr and 13 MFCCs per frame; smooth rms with attack/release, map centroid to a color temperature and rms to scale. Log the feature ranges for the first 10 s so the mapping can be calibrated per track.
Section detection
From a precomputed feature track, detect song sections (intro, verse, chorus) by novelty in a self-similarity matrix of MFCCs and use them to switch scenes: each section boundary triggers a camera cut and a palette change. Show the SSM as a small image for debugging.
Related
Resources · 1
- Meyda audio featuresmeydaGitHub · code · demoJun 10, 2026