GuitarPrometheus::MusicModels::KeySignature
GuitarPrometheus::MusicModels::KeySignature
A key signature in 12-tone equal temperament. More…
#include <MusicalConcepts.h>
Public Functions
| Name | |
|---|---|
| KeySignature() Default constructor: C major (fifths=0, Ionian). | |
| KeySignature(int fifths, Mode mode) Construct from MusicXML’s <fifths> + <mode> directly. | |
| KeySignature(PitchClass tonic, Accidental tonicAccidental, Mode mode) Construct from a tonic note + mode (human-friendly). | |
| int | getFifths() const Number of sharps (positive) or flats (negative) in this key. |
| Mode | getMode() const Mode of this key. |
| PitchClass | getTonic() const Pitch class of this key’s tonic. |
| Accidental | getTonicAccidental() const Accidental on this key’s tonic (e.g., Flat for Bb minor). |
| Accidental | getKeyAccidental(PitchClass p) const Resolve the accidental for a given pitch class in this key. |
Detailed Description
class GuitarPrometheus::MusicModels::KeySignature;A key signature in 12-tone equal temperament.
Stored internally as fifths (the position on the circle of fifths, matching MusicXML’s <fifths> element, range -7..+7) plus a Mode. Accidentals for each pitch class are resolved from fifths alone via a static lookup table — Mode is preserved for display and round-trip purposes (so “Bb minor” can come back out as Bb + Aeolian) but has no effect on accidental resolution.
Public Functions Documentation
function KeySignature
KeySignature()Default constructor: C major (fifths=0, Ionian).
Provided so types containing [KeySignature](/api-reference/classes/classguitarprometheus_1_1musicmodels_1_1keysignature/) (like Measure) are default-constructible.
function KeySignature
KeySignature( int fifths, Mode mode)Construct from MusicXML’s <fifths> + <mode> directly.
Parameters:
- fifths -7..+7. Out-of-range values throw std::invalid_argument.
- mode The mode of the key (Ionian, Dorian, etc.).
function KeySignature
KeySignature( PitchClass tonic, Accidental tonicAccidental, Mode mode)Construct from a tonic note + mode (human-friendly).
Parameters:
- tonic Pitch class of the tonic note.
- tonicAccidental Accidental on the tonic (Natural, Sharp, Flat).
- mode Mode of the key.
Internally computes the fifths value from the tonic and mode. If the resulting fifths falls outside -7..+7 (e.g., C# Lydian requires 8 sharps), throws std::invalid_argument.
function getFifths
int getFifths() constNumber of sharps (positive) or flats (negative) in this key.
function getMode
Mode getMode() constMode of this key.
function getTonic
PitchClass getTonic() constPitch class of this key’s tonic.
function getTonicAccidental
Accidental getTonicAccidental() constAccidental on this key’s tonic (e.g., Flat for Bb minor).
function getKeyAccidental
Accidental getKeyAccidental( PitchClass p) constResolve the accidental for a given pitch class in this key.
Return: One of {Flat, Natural, Sharp}; never None or doubles for standard keys (-7..+7 fifths).
Updated on 2026-05-29 at 07:39:52 +0000