Struct ModalKey
Extended key signature with modal information.
public readonly struct ModalKey : IEquatable<ModalKey>
- Implements
- Inherited Members
Remarks
Validated on construction rather than at each consumer. ModeLibrary.GetIntervals and friends take a ModalKey and guard the mode they read out of it, which would blame a parameter named "mode" for a caller who only ever passed a "key". Rejecting it here puts the blame where the bad value entered.
Constructors
ModalKey(byte, Mode)
Extended key signature with modal information.
public ModalKey(byte root, Mode mode)
Parameters
Remarks
Validated on construction rather than at each consumer. ModeLibrary.GetIntervals and friends take a ModalKey and guard the mode they read out of it, which would blame a parameter named "mode" for a caller who only ever passed a "key". Rejecting it here puts the blame where the bad value entered.
Exceptions
- ArgumentOutOfRangeException
modeis not a defined Mode value.
Properties
Mode
The mode/scale type.
public Mode Mode { get; }
Property Value
Exceptions
- ArgumentOutOfRangeException
modeis not a defined Mode value.
ParallelMajor
Get the parallel major of this mode.
public ModalKey ParallelMajor { get; }
Property Value
Exceptions
- ArgumentOutOfRangeException
modeis not a defined Mode value.
ParallelMinor
Get the parallel minor of this mode.
public ModalKey ParallelMinor { get; }
Property Value
Exceptions
- ArgumentOutOfRangeException
modeis not a defined Mode value.
RelativeMajor
The major key built on the same notes as this mode — for Lydian on C, that is G major.
public ModalKey RelativeMajor { get; }
Property Value
Remarks
Every diatonic mode has one, not only the minor-sounding ones: the table listed Aeolian, Dorian, Phrygian and Locrian and let Lydian and Mixolydian fall through to the default, which returns the mode's own root. So C Lydian claimed C major as its relative major though the two differ by the F sharp that makes it Lydian, and the answer was silently the same as ParallelMajor. A mode with no diatonic parent — harmonic minor, whole tone, the pentatonics — still falls through to the parallel major, since there is no major scale on the same notes to point at.
Exceptions
- ArgumentOutOfRangeException
modeis not a defined Mode value.
Root
Root note (0-11, where 0=C).
public byte Root { get; }
Property Value
Exceptions
- ArgumentOutOfRangeException
modeis not a defined Mode value.
Methods
Equals(ModalKey)
Indicates whether this key equals other (same root and mode).
public bool Equals(ModalKey other)
Parameters
otherModalKey
Returns
Exceptions
- ArgumentOutOfRangeException
modeis not a defined Mode value.
Equals(object?)
Indicates whether obj is a ModalKey equal to this one.
public override bool Equals(object? obj)
Parameters
objobject
Returns
Exceptions
- ArgumentOutOfRangeException
modeis not a defined Mode value.
FromKeySignature(KeySignature)
Convert from simple KeySignature.
public static ModalKey FromKeySignature(KeySignature key)
Parameters
keyKeySignature
Returns
Exceptions
- ArgumentOutOfRangeException
modeis not a defined Mode value.
GetHashCode()
Returns a hash code combining root and mode.
public override int GetHashCode()
Returns
Exceptions
- ArgumentOutOfRangeException
modeis not a defined Mode value.
ToKeySignature()
Convert to simple KeySignature (loses modal info for non-standard modes). A mode with a major third above its root is a major key; one whose only third is minor is a minor key.
public KeySignature ToKeySignature()
Returns
Remarks
The parity is read off the mode's own intervals rather than a list of modes. The list named the seven diatonic modes and the two minor scales and sent everything else to major, so the minor pentatonic, the blues scale, the whole-half diminished scale and Locrian natural 2 — the half-diminished scale — all came back as a major key though none of them has a major third. Where a scale has both thirds, as the altered and half-whole diminished scales do, the major third decides: they are dominant scales, whose minor third is heard as a sharp ninth over a chord whose own third is major. Every mode this library defines has one third or the other; a scale with neither would convert to major, which is where every unlisted mode went before, so no answer that was right has moved.
Exceptions
- ArgumentOutOfRangeException
modeis not a defined Mode value.
ToString()
Returns the key as a note name and mode (e.g. "C Major"), the tonic spelled as the
scale is written — "Ab Major", "F Locrian", "Bb Blues" — never "G# Major" — and the mode
by its musical name: "Phrygian Dominant", "Whole Tone", "Minor Pentatonic".
public override string ToString()
Returns
Remarks
The modes past the four named ones printed their enum member — "D# MinorPentatonic", "E PhrygianDominant", "C DiminishedHalfWhole" — which is a C# identifier, not a name.
Exceptions
- ArgumentOutOfRangeException
modeis not a defined Mode value.
Operators
operator ==(ModalKey, ModalKey)
Indicates whether two keys are equal.
public static bool operator ==(ModalKey left, ModalKey right)
Parameters
Returns
Exceptions
- ArgumentOutOfRangeException
modeis not a defined Mode value.
operator !=(ModalKey, ModalKey)
Indicates whether two keys differ.
public static bool operator !=(ModalKey left, ModalKey right)
Parameters
Returns
Exceptions
- ArgumentOutOfRangeException
modeis not a defined Mode value.