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

    Function tryResolveKeyName

    • Read a key name, reporting failure instead of throwing it.

      The scale-word form is tried first, because a name ending in a mode word — 'D harmonic minor' — would otherwise be read as the plain minor key that word names and lose the scale it was written with. It is English-only, so a name asked for in another notation system goes straight to the key-name parser, which reads that system.

      Parameters

      • text: string

        The key name.

      • Optionalopts: NoteNameOptions

        system reads the name in that notation system instead of detecting it.

      Returns ParseResult<ResolvedKey>

      The key the name denotes, or the error explaining why the text is not one.

      import { tryResolveKeyName } from '@libraz/libcantus';
      const result = tryResolveKeyName('D dorian');
      result.ok ? result.value.variant : result.error.message; // 'modal'