@libraz/libcantus - v1.1.0
    Preparing search index...

    Function beatsToSeconds

    • Wall-clock seconds from the start of a tempo map to a beat.

      The result integrates every tempo segment the span crosses; it is not the tempo in effect at beat applied to the whole span.

      A beat before the map's first event reports negative elapsed time, at the opening tempo: a pickup sounds before the downbeat, and asking when it sounds is a fair question.

      Parameters

      • beat: number

        Position in quarter-note beats.

      • map: TempoMap

        The tempo map; its first event is the time origin.

      Returns number

      Elapsed seconds, 0 at the map's first event and negative before it.

      If the map is empty, unsorted, or carries a tempo outside 0.1..1000 quarter-note beats per minute.

      import { beatsToSeconds } from '@libraz/libcantus';
      const map = [{ startBeat: 0, bpm: 120 }, { startBeat: 4, bpm: 60 }];
      beatsToSeconds(8, map); // 6 = 4 beats at 120 + 4 beats at 60