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

    Function barIndexAt

    • Bar index of a beat: 0 for the first full bar, negative inside a pickup.

      Bars accumulate across meter changes, so the bar after a 4/4-to-3/4 change is the next bar and not the first bar of a new count.

      Parameters

      • beatInQuarters: number

        Absolute position in quarter-note beats.

      • meter: MeterLike

        A single signature, or the piece's meter map.

      Returns number

      The 0-based bar index.

      import { barIndexAt, parseTimeSignature } from '@libraz/libcantus';
      const meters = [
      { startBeat: 0, ts: parseTimeSignature('4/4') },
      { startBeat: 8, ts: parseTimeSignature('3/4') },
      ];
      barIndexAt(11, meters); // 3