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

    Function resolveKey

    • Resolve any key-shaped value to the whole key it names.

      The counterpart of toKeyScale, and the one to prefer: both read the same shapes, but this one keeps what it read. A caller that genuinely wants only the pitch classes asks for them with scaleOf, which says so at the place it happens.

      What the value does not carry is derived rather than dropped: a bare scale is spelled by spelledKeyOf, the same reading the rest of the library uses, and its form is read from its mask. A key that carries a spelled tonic keeps that one — the caller's spelling outranks any the library would pick. A name carries one too, and it is kept: 'Ab minor' resolves to an A flat minor rather than being reduced to pitch classes and spelled back as the G# minor those read best as.

      What it carries is checked rather than trusted. Accepting a wide range of shapes is not the same as accepting whatever those shapes hold, and a key whose tonic or form contradicts its own scale is refused here in the words Key.of refuses it — the two APIs answer the same input alike, and the refusal reaches every entry point built on this one.

      Parameters

      • value: KeyLike

        A key name, a plain key/scale, a resolved key, or a value whose toJSON returns one of those.

      Returns ResolvedKey

      The key, whole.

      If the value names no key, its mask is out of range or excludes its own root, its tonic spells a pitch class its scale is not rooted on, or its form is not one that mask holds.

      import { formatNote, resolveKey } from '@libraz/libcantus';
      formatNote(resolveKey('Ab minor').tonic); // 'Ab'
      resolveKey('C major').tonic.letter; // 0