Table of Contents

Struct KeySignature

Namespace
Celeritas.Core
Assembly
Celeritas.dll

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

root byte

Tonic pitch class; reduced modulo 12.

isMajor bool

true for major, false for minor.

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

rootName string

Tonic note name.

isMajor bool

true for major, false for minor.

Exceptions

ArgumentException

rootName is not a recognized note name.

Fields

IsMajor

true for a major key, false for minor.

public readonly bool IsMajor

Field Value

bool

Root

Tonic pitch class (0=C .. 11=B).

public readonly byte Root

Field Value

byte

Methods

GetDominantKey()

Gets the dominant key (e.g., C Major → G Major, A Minor → E Minor).

public KeySignature GetDominantKey()

Returns

KeySignature

GetParallelKey()

Gets the parallel key (e.g., C Major → C Minor, A Minor → A Major).

public KeySignature GetParallelKey()

Returns

KeySignature

GetRelativeKey()

Gets the relative key (e.g., C Major → A Minor, A Minor → C Major).

public KeySignature GetRelativeKey()

Returns

KeySignature

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

degree ScaleDegree

Returns

byte

Exceptions

ArgumentOutOfRangeException

degree is 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

ushort

GetSubdominantKey()

Gets the subdominant key (e.g., C Major → F Major, A Minor → D Minor).

public KeySignature GetSubdominantKey()

Returns

KeySignature

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

string

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.