Audio · function

beatGrid

A beat map from a tempo the player supplies rather than one we detected.

Explained in Your first game.

function beatGrid(bpm: number, offsetSec: number, durationSec: number): BeatMap
import { beatGrid } from '@driftengine/audio';

Parameters

ParameterTypeDescription
bpmnumber
offsetSecnumber
durationSecnumber

In depth

The reason this exists is the workflow, not the maths. On TikTok and Reels the trending sound is added in the app, replacing whatever audio the clip arrived with — so the thing that has to line up is not our audio against theirs, it is our cuts against their sound. A player who taps along to the track they intend to use gets an edit that fits it, and it works with any song in existence precisely because we never touch the song.

The output is an ordinary BeatMap, so nothing downstream needs to know where its beats came from.