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

    Function beatsToDuration

    • Spell a length in beats as the note value a score would show.

      The spelling is the conventional one, not merely an arithmetically valid one: 1.5 beats is a dotted quarter rather than a quarter tied to an eighth, and a third of a beat is an eighth triplet rather than a twenty-fourth note. Plain values are preferred to dotted ones and both to tuplets, and within the tuplets triplets come before quintuplets and septuplets.

      Lengths are matched within 1e-6 quarter notes, so a rounded decimal such as 0.3333333 still reads as a triplet. The tolerance is measured in quarter notes whatever beatUnit names, so a longer beat unit narrows it in proportion: under { beatUnit: 'whole' } it is 2.5e-7 of a beat.

      Parameters

      • beats: number

        The length in beats.

      • options: { beatUnit?: NoteValue | DurationData } = {}

        beatUnit sets what one beat is; a quarter note by default.

      Returns SpelledDuration

      The base value, its dot count, and its tuplet when it has one.

      If beats is not positive, or — as a NoSolutionError — if no single note value spells it, as for 5 beats in 4/4. Use beatsToTiedDurations for those.

      import { beatsToDuration } from '@libraz/libcantus';
      beatsToDuration(1.5); // { base: 'quarter', dots: 1 }
      beatsToDuration(1 / 3); // { base: 'eighth', dots: 0, tuplet: { actual: 3, normal: 2 } }