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

    Function toSpelledInterval

    • Resolve any interval-shaped value to plain SpelledInterval data.

      This is what lets an entry point accept an interval name, the plain data the pitch module returns, or an Interval instance without every caller branching on the form. An instance is accepted through its toJSON method rather than by its type, because the core layer cannot import the model layer that defines the class.

      Parameters

      • value: IntervalLike

        An interval name, plain interval data, or a value whose toJSON returns interval data.

      Returns SpelledInterval

      The validated interval data, always carrying descending, false for an interval that ascends.

      If the value is not interval-shaped, or its number, quality, and span do not describe the same interval.

      import { toSpelledInterval } from '@libraz/libcantus';
      toSpelledInterval('P5'); // { number: 5, quality: 'P', semitones: 7, descending: false }
      toSpelledInterval({ number: 5, quality: 'P', semitones: -7 });
      // { number: 5, quality: 'P', semitones: -7, descending: true }