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

    Function formatTimeSignature

    • Render a time signature as "n/d", or as "a+b+c/d" when it carries an additive grouping and grouping is requested.

      The additive form is what parseTimeSignature reads back, and it adds its terms to get the numerator — so only a grouping written in denominator units can be rendered that way. A grouping counted in main pulses whose groups are all the same length (9/8 as [1, 1, 1], 12/8 as [2, 2]) states the division the bare signature already has, so it falls back to the plain form at no cost. One whose groups differ (12/8 as [1, 1, 2]) states an accent no signature text can carry, and asking for the additive form of it is refused rather than answered with a bar that weighs its pulses differently.

      The plain form drops the grouping, so a round trip through it reads 7/8 as flat rather than as 2+2+3; ask for the additive form to keep it.

      Parameters

      • ts: MeterLike

        The time signature, in any form that names one; a meter map is rendered as the signature it opens in.

      • opts: { grouping?: boolean } = {}

        Set grouping: true to render an additive grouping.

      Returns string

      The formatted signature.

      If grouping: true is asked of a grouping that no signature text can spell: one counted in main pulses, on a compound numerator, whose groups are not all the same length.

      import { formatTimeSignature } from '@libraz/libcantus';
      const aksak = { numerator: 7, denominator: 8, grouping: [2, 2, 3] };
      formatTimeSignature(aksak); // '7/8'
      formatTimeSignature(aksak, { grouping: true }); // '2+2+3/8'