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.
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.
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.ofrefuses it — the two APIs answer the same input alike, and the refusal reaches every entry point built on this one.