audio-beat-clockOfficial · by ShadereraBeat clock
Measure a song (tempo fitted to its onsets, beat grid, downbeats, onsets, band energy, sections) and cut the picture to it: bars, beats, 1/16s, band levels, hit pulses at t.
“Use the shaderera-plugins skill to add audio-beat-clock to this film and wire it in, then run check and show me a still.”
- Type
- component · Audio & Music
- Version
- 0.1.0 · published
- Licence
- MIT
- Built on
- No other plugins
- npm
- No packages
- Tags
- music, beat sync, bpm, beat grid, onsets, audio reactive, analysis
How to
use it.
Measure the song once, then cut every change to its grid: bars, beats, 1/16s, band levels and hits at t.
node tools/analyze-music.ts audio/song.mp3 # writes audio/song.analysis.jsonimport { bandsOf, clockFromAnalysis, hitsOf, loadAnalysis, pulse } from './music/beat.ts'// in openconst analysis = await loadAnalysis(host, 'audio/song.mp3', 'audio/song.analysis.json')const clock = clockFromAnalysis(analysis) // { trim } if the film starts later in the songconst bands = bandsOf(analysis) // (t) => [sub, low, mid, high], 0–1const hits = hitsOf(analysis, { strength: 200 }) // strong onsets, in film time// in render(t)const drop = clock.at(17) // bar 17's downbeatconst flash = pulse(t, hits, 0.08)const [sub] = bands(t)The tempo is found by autocorrelation, then fitted to the song's strong onsets on beats, eighths or sixteenths, whichever they sit closest to, so the grid does not drift over a long song. The analyser prints how far the onsets sit from it. Listen to check the tempo anyway: if the picture drifts, the measured BPM may be a ratio of the real one; run again with --min-bpm/--max-bpm around what you hear.
loadAnalysis refuses an analysis measured from other bytes than the song, so a replaced song never plays against an old grid. analysis.sections holds up to 12 times where the sound changes most (novelty peaks), candidates for section starts. Needs ffmpeg on PATH.