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

    Function intervalSemitones

    • The semitone span of the interval named by a diatonic number and a quality.

      The inverse of the quality derivation in spelledInterval: it turns a name back into a distance, which is what transposing by a named interval or parsing one from text needs.

      Parameters

      • numberValue: number

        Diatonic size: 1 = unison, 2 = second, ... 8 = octave.

      • quality: IntervalQualityLabel

        Quality label: 'P', 'M', 'm', or repeated 'A'/'d'.

      Returns number

      The signed semitone span the name covers when its letters ascend. Nearly every name spans upward, but a second narrowed far enough crosses zero while its letters still rise — C# up to Dbb is a doubly diminished second spanning -1 — and the sign is what keeps that name reading as the same interval a measurement of those two notes reports.

      If the quality cannot apply to the number, such as a major fifth or a diminished unison.

      import { intervalSemitones } from '@libraz/libcantus';
      intervalSemitones(5, 'P'); // 7