API / MusicTheory
ChordSymbol record
A lead-sheet chord symbol such as
Am7, D/F#, B♭Δ7 or C7b9#11: a root, a chord type, optional tensions and an optional bass that need not be a chord tone (C/Bb).Constructors
ChordSymbol(Note Root, ChordType Type, Note? Bass = null, IReadOnlyList<Interval>? Tensions = null)A lead-sheet chord symbol such as
Am7, D/F#, B♭Δ7 or C7b9#11: a root, a chord type, optional tensions and an optional bass that need not be a chord tone (C/Bb).Root- The chord root (octave is not significant).
Type- The chord type.
Bass- The slash bass, or null when the root is in the bass.
Tensions- Tensions on top of the type, in order: altered (
b9,#11,b13,b5,#5) replace the natural degree, natural ones (add9,13) are added.
Properties
Note? Bass { get; init; }The slash bass, or null when the root is in the bass.
Note Root { get; init; }The root.
ChordType Type { get; init; }The chord type.
IReadOnlyList<Interval> Tensions { get; init; }The tensions, never null (empty when there are none).
Methods
bool Equals(ChordSymbol? other)Equal when root and bass have the same spelling (octave ignored) and the type matches.
int GetHashCode()static ChordSymbol Parse(string text)Parses a chord symbol: an upper-case root (
#, b, ♯, ♭ accidentals), a suffix and an optional /bass. Accepts common aliases: m/min/-, maj7/M7/Δ/Δ7/ma7, dim/°/o, m7b5/ø/ø7/m7(b5), aug/+, sus, add2, 6/9/69, 7alt, mMaj7/m(maj7), 5, and parenthesised alterations (7(b9)).Throws FormatException The text is not a chord symbol.
static ChordSymbol Parse(string text, ChordSymbolParseOptions options)Parses a chord symbol with the given options; see
ChordSymbol.Parse.Throws ArgumentNullException options is null.
Throws FormatException The text is not a chord symbol.
Chord ToChord()The chord this symbol names. A bass that is a chord tone becomes the matching inversion; a bass that is not a chord tone (
C/Bb) stays on ChordSymbol.Bass only.string ToString(ChordSymbolStyle style)Renders the symbol in the given style, e.g.
Bbmaj7, D/F#, Bø7.string ToString()Renders the symbol in
ChordSymbolStyle.Ascii.ChordSymbol Transpose(Interval interval)Transposes root and bass by an interval, keeping interval spelling (D/F# up a m2 is Eb/G).
ChordSymbol Transpose(int semitones, KeySignature targetKey)Transposes root and bass by semitones and spells them in
targetKey. A black-key note outside the key keeps the direction of its own accidental (a flat Eb moved to G is Bb, not A#).ChordSymbol Transpose(KeySignature from, KeySignature to)Moves the chord from one key to another by the interval between the tonics, so a borrowed Eb in C is Bb in G. It falls back to the spelling of
to only to avoid a double accidental.static bool TryParse(string? text, out ChordSymbol? symbol)Tries to parse a chord symbol; see
ChordSymbol.Parse. Returns false (never throws) for N.C., %, empty strings and other non-chords.static bool TryParse(string? text, ChordSymbolParseOptions options, out ChordSymbol? symbol)Tries to parse a chord symbol with the given options; see
ChordSymbol.TryParse. Never throws on the text.Throws ArgumentNullException options is null.
IReadOnlyList<Note> Voice(int octave = 4)Piano voicing: the chord in root position from
octave (interval spelling, so the #9 of E7#9 is F##), ascending, with a slash bass placed below the root.