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

    Function relativeKeyOf

    • The relative key: for a plain major or minor key, the same key signature read in the other mode.

      C major and A minor share a signature, and so are each other's relative; the relation is its own inverse for a plain major or minor key. Because the new tonic is read off the circle of fifths rather than transposed by semitones, the relative of Db major is Bb minor and not its enharmonic A# minor.

      A key that is not a plain major or minor is read through the mode its third names and stepped from where its tonic stands on the circle, the origin every relation here shares: the relative of D dorian is F major, the relative of the D minor its third names. The shared-signature reading does not carry over to those — D dorian is written with no accidentals and F major with one — and the modes have no relative of their own for it to be measured against.

      Parameters

      • tonic: NoteLike

        The spelled tonic of the key, as a note name, note data, or a Note.

      • key: KeyLike

        The key/scale, as a key name, a key/scale, or a Key; its mask decides which mode the relative is in.

      Returns ResolvedKey

      The relative key and the tonic spelling it is written with.

      If the tonic or the mask is malformed, or if the resulting signature falls outside [-12, 12] fifths.

      import { formatNote, majorKey, parseNote, relativeKeyOf } from '@libraz/libcantus';
      formatNote(relativeKeyOf(parseNote('C'), majorKey(0)).tonic); // 'A'
      formatNote(relativeKeyOf('Db', majorKey(1)).tonic); // 'Bb'