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

    Function durationToBeats

    • Length of a written duration in beats.

      Parameters

      • duration: NoteValue | DurationData

        The duration, or a bare base value as shorthand for an undotted one.

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

        beatUnit sets what one beat is; a quarter note by default, so a dotted quarter reads as 1.5. Pass { base: 'quarter', dots: 1 } to count in the felt beats of a compound meter.

      Returns number

      The length in beats.

      If the base value is unknown, the dot count is not an integer in 0..4, or a tuplet side is not a positive integer.

      import { durationToBeats } from '@libraz/libcantus';
      durationToBeats('quarter'); // 1
      durationToBeats({ base: 'quarter', dots: 1 }); // 1.5
      durationToBeats({ base: 'eighth', tuplet: { actual: 3, normal: 2 } }) * 3; // 1 — three
      // eighth-note triplets fill the beat two eighths would