MCC
Loading...
Searching...
No Matches
MCC::Key Class Reference

A tonic and a diatonic mode, with the key signature they imply. More...

#include <Key.h>

Collaboration diagram for MCC::Key:
Collaboration graph

Public Member Functions

constexpr Key () noexcept
 Creates the invalid key (SPEC-ERR-2).
constexpr Key (NoteName tonic, KeyMode mode) noexcept
 Creates tonic in mode; invalid beyond seven sharps or flats.
constexpr bool IsValid () const noexcept
 Returns true unless this is the invalid key.
constexpr NoteName Tonic () const noexcept
 Returns the tonic.
constexpr KeyMode Mode () const noexcept
 Returns the mode.
constexpr KeySignature Signature () const noexcept
 Returns the key signature, or the invalid signature.
Scales::Id ScaleId () const noexcept
 Returns the catalog scale of the mode, or Scales::Id::Invalid.
MCC::Scale Scale () const noexcept
 Returns the key's scale spelled from its tonic.
MCC_CONSTEXPR14 NoteName Spell (MCC::PitchClass pitchClass) const noexcept
 Writes pitchClass in this key's context (SPEC-KEY-3).
MCC_CONSTEXPR14 MCC::Pitch Spell (MCC::ChromaticIndex index) const noexcept
 Writes a sounding chromatic index as a pitch in this key's context.

Static Public Member Functions

static MCC_CONSTEXPR14 Key FromSignature (KeySignature signature, KeyMode mode) noexcept
 Returns the key with signature in mode (2 sharps + Minor = B minor).
static constexpr Key Invalid () noexcept
 Returns the invalid key.

Friends

constexpr bool operator== (const Key &a, const Key &b) noexcept
 Compares tonic spelling and mode.
constexpr bool operator!= (const Key &a, const Key &b) noexcept
 Negation of operator==.

Detailed Description

A tonic and a diatonic mode, with the key signature they imply.

The key is modelled separately from its scale (SPEC-KEY-2): Signature() follows from the tonic's position on the circle of fifths and the mode, and a tonic whose signature would exceed seven sharps or flats (G# major) produces the invalid key. Spell() writes any pitch class in the key's context: diatonic pitch classes use the key's own letters; a chromatic one alters a diatonic note by a semitone, preferring the spelling with fewer accidentals and, on a tie, a raised note in sharp keys and a lowered note in flat keys (SPEC-KEY-3).


The documentation for this class was generated from the following file: