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

    Function keyFromFifths

    • The key a signature denotes: the inverse of keySignatureFifths for the two modes a signature is conventionally read in.

      A signature names two keys — three sharps is both A major and F# minor — so the mode decides which one is built. The tonic is spelled the way that key is written, including the theoretical keys past ±7 (nine sharps is D# major).

      Parameters

      • fifths: number

        The signed number of sharps (positive) or flats (negative).

      • mode: KeyMode = 'major'

        Which of the signature's two keys to build; defaults to major.

      Returns ResolvedKey

      The spelled tonic and the matching key/scale.

      If fifths is not an integer in [-12, 12], or mode is not one of 'major' or 'minor'.

      import { keyFromFifths, formatNote } from '@libraz/libcantus';
      formatNote(keyFromFifths(-2).tonic); // 'Bb'
      formatNote(keyFromFifths(-2, 'minor').tonic); // 'G'