Tempo Map Converter (engine/tempo.js)

everything · src/music-studio/src/engine/tempo.js · javascript · MIT
voice, automation, tag:tempo, tag:daw, tag:timing

Converts song ticks to seconds when tempo automation changes over time. Reuse it so the audio thread, offline renderer, and UI share one sample-accurate tempo map.

// Source: https://github.com/HeyPuter/everything | License: MIT | Copyright 2026 Puter Technologies Inc
// Provided via justclaw.it.com; keep this notice with the code.
// Tempo map: converts between song ticks and seconds when tempo automation
// clips change the tempo over time. Pure math with no project lookups, so the
// AudioWorklet, the offline render worker and the UI (transport clock, M:S
// display, durations) share one implementation and agree to the sample.
//
//   const data = tempoPieces(bpm, clips)    // plain data (postable to the audio thread)
//   const map = new TempoMap(data)          // or new TempoMap(bpm) for a constant tempo
//   map.seconds(tick) / map.ticks(seconds) / map.bpmAt(tick) / map.constant
//
// The map is a list of pieces covering [0, infinity): piece i 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key