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

    Function toKeyScale

    • Resolve any key-shaped value to a plain KeyScale.

      The counterpart of toSpelledInterval for keys: an entry point takes whatever form the caller has — the name a key field holds, the scale the theory module returns, or a Key instance — and gets one shape back. An instance is accepted through its toJSON method rather than by its type, so the layers below the model can read a class without importing it.

      A name is read by the one reader resolveKey and Key.parse also use, so every entry point that takes a key accepts exactly the same names: a mode word in every notation system that reader knows, and a built-in scale's own word — 'D dorian', 'D harmonic minor' — in English. The spelling the name carries is dropped here along with the scale form, which is what resolveKey is for.

      Parameters

      • value: KeyLike

        A key name, a plain key/scale, or a value whose toJSON returns data carrying one.

      Returns KeyScale

      The validated key/scale, with its root reduced to a pitch class.

      If the value names no key, or its mode mask is out of range or excludes its own root.

      import { toKeyScale } from '@libraz/libcantus';
      toKeyScale('C major').rootPc; // 0
      toKeyScale('A minor').rootPc; // 9