const metronome = useMetronome({ bpm: 100, beatsPerBar: 4, countInBars: 1 });
<TakeRecorder onRecordingStarted={({ nowMs }) => {
const started = metronome.start();
if (started) {
live.setTempo({
bpm: 100,
startTakeMs: nowMs() + (started.firstBeatPerformanceMs - performance.now()),
click: { ...started.click, countInBeats: started.countInBeats },
});
}
}} onTakeCompleted={() => metronome.stop()} />
A click track: a short noise click on every beat, the first of each bar accented, with a count-in before the first beat of the piece.
start()must be called from a user gesture — a click — so the browser lets audio run. It returns when the first beat after the count-in falls, on theperformance.now()clock, which is what a live session's set tempo is anchored to, and with the click itself: handed to the live session, a click the microphone hears is found and taken out of the audio before it is read. Headphones are still the better arrangement.