Struct KeySignature
Key signature with root and mode
public readonly record struct KeySignature : IEquatable<KeySignature>
- Implements
- Inherited Members
Constructors
KeySignature(byte, bool)
Creates a key from a tonic pitch class (folded into 0-11) and mode.
public KeySignature(byte root, bool isMajor)
Parameters
KeySignature(string, bool)
Creates a key from a tonic note name (e.g. "C", "F#", "Bb") and mode.
public KeySignature(string rootName, bool isMajor)
Parameters
Exceptions
- ArgumentException
rootNameis not a recognized note name.
Fields
IsMajor
public readonly bool IsMajor
Field Value
Root
Tonic pitch class (0=C .. 11=B).
public readonly byte Root
Field Value
Methods
GetDominantKey()
Gets the dominant key (e.g., C Major → G Major, A Minor → E Minor).
public KeySignature GetDominantKey()
Returns
GetParallelKey()
Gets the parallel key (e.g., C Major → C Minor, A Minor → A Major).
public KeySignature GetParallelKey()
Returns
GetRelativeKey()
Gets the relative key (e.g., C Major → A Minor, A Minor → C Major).
public KeySignature GetRelativeKey()
Returns
GetScale()
Returns the diatonic scale pitch classes (0-11) for this key. Uses major or natural minor.
public int[] GetScale()
Returns
- int[]
GetScaleDegreePitchClass(ScaleDegree)
Returns the pitch class (0-11) for a diatonic scale degree in this key. Uses major or natural minor.
public byte GetScaleDegreePitchClass(ScaleDegree degree)
Parameters
degreeScaleDegree
Returns
Exceptions
- ArgumentOutOfRangeException
degreeis not a defined ScaleDegree value.
GetScaleMask()
Returns a 12-bit pitch-class mask for this key's diatonic scale (major or natural minor).
public ushort GetScaleMask()
Returns
GetSubdominantKey()
Gets the subdominant key (e.g., C Major → F Major, A Minor → D Minor).
public KeySignature GetSubdominantKey()
Returns
ToString()
Returns the tonic name followed by the mode (e.g. "C Major"), the tonic spelled as the key is written: "Bb Major" and "Eb Minor" for pitch classes 10 and 3, "F# Major" for 6.
public override string ToString()
Returns
Remarks
The tonic was read off the sharp pitch-class table, so the major key on pitch class 10 was "A# Major" — a key that would need ten sharps — and a caller who typed "Eb major" was answered "In D# Major". The name is now the first note of the key's own spelled scale, so a key and its scale cannot disagree; see Celeritas.Core.KeySpelling.