Table of Contents

Class ProgressionAdvisor

Namespace
Celeritas.Core.Analysis
Assembly
Celeritas.dll

Advanced progression analyzer that generates detailed, human-readable reports. Detects cadences, chord characters, harmonic minor usage, and provides suggestions.

public static class ProgressionAdvisor
Inheritance
ProgressionAdvisor
Inherited Members

Methods

Analyze(string[])

Analyze a chord progression from symbols and generate a detailed report.

public static ProgressionReport Analyze(string[] chordSymbols)

Parameters

chordSymbols string[]

Returns

ProgressionReport

Exceptions

ArgumentNullException

chordSymbols is null.

AnalyzeFromSymbols(string[])

Backward/compat alias used by some examples.

public static ProgressionReport AnalyzeFromSymbols(string[] chordSymbols)

Parameters

chordSymbols string[]

Returns

ProgressionReport

Exceptions

ArgumentNullException

chordSymbols is null.

DetectCadence(string[], KeySignature?)

Detect the type of cadence formed by the last two chords in a progression. Returns the cadence type only; for a human-readable description, read Cadences and its Description.

public static CadenceType DetectCadence(string[] chordSymbols, KeySignature? key = null)

Parameters

chordSymbols string[]
key KeySignature?

Returns

CadenceType

Exceptions

ArgumentNullException

chordSymbols is null.

GetInversion(int[])

Get the inversion of a chord based on the bass note.

public static int GetInversion(int[] pitches)

Parameters

pitches int[]

Returns

int

Remarks

The chord is identified from its pitches by Identify(ReadOnlySpan<int>), which roots a set that is both a sixth chord and a seventh chord on its bass: F-A-C-D with F at the bottom is F6 in root position here, not Dm7 in first inversion. When the chord came from a symbol, ask GetInversion(string), which knows the root the symbol named.

Exceptions

ArgumentNullException

pitches is null.

GetInversion(string)

Get the inversion a chord symbol writes: 0 for root position, 1 for the third in the bass, 2 for the fifth, 3 for the seventh. The root is the one the symbol names, so "Dm7/F" is 1 and "Am7/C" is 1; a symbol that does not parse, or whose bass is not a chord tone, is 0.

public static int GetInversion(string chordSymbol)

Parameters

chordSymbol string

Returns

int

Exceptions

ArgumentNullException

chordSymbol is null.

GetInversionName(int)

Get inversion name for display.

public static string GetInversionName(int inversion)

Parameters

inversion int

Returns

string

ParseChordSymbol(string)

Parse a chord symbol into MIDI pitches (octave 4 = middle C), each pitch named once. Supports: C, Am, G7, Dmaj7, F#m7, Bbdim, Csus4, C/E (slash chords), etc. A bare number is lead-sheet shorthand: C2 is Cadd9, C4 is Csus4 and C5 the power chord; 6, 7, 9, 11 and 13 are extensions, and any other number fails the parse. The fifth, ninth, eleventh and thirteenth may be altered, each more than once: C7(b9,#9) has both altered ninths and no natural one, C7(b5,#5) both altered fifths, and the order the alterations are written in does not change the chord. "alt" is the minimal altered dominant, #5 and b9. An alteration displaces the natural of its own degree — the perfect fifth, or the ninth, eleventh or thirteenth of the extension chain — and nothing else: a fifth the triad's own quality names stays, so Caug7(b5) has both fifths like C7(b5,#5), and Cdim7(b5) is Cdim7; an explicit add is heard beside an alteration of its degree, so C7(b9)add9 has both Db and D; and a power chord takes an alteration like any other chord, so C5(b9) is C, G and Db. A diminished symbol with an extension is the diminished seventh chord coloured — Cdim9 is C, Eb, Gb, A and D — where Cø9 has the minor seventh; the thirteenth of Cdim13 sounds the same note as its diminished seventh an octave up, and is named, as the #11 of C7(b5,#11) is named beside the b5. A power chord beside a marker for the third it has not got — Cm5, Cmaj5, C5sus4 — is refused: the parser fails on a symbol it cannot spell rather than dropping part of it.

public static int[] ParseChordSymbol(string symbol)

Parameters

symbol string

Returns

int[]

Remarks

The parser used to accept any number and act only on 6 and 7 upward, so C2, C3 and C4 all came back as a plain C major triad and C8 as a C7, with nothing to say the number had been dropped. It also kept one alteration per degree, the last written, so C7(b9,#9) came back without its b9 and C7(#9,b9) without its #9. Four more silent drops followed the same shape: the power chord ignored every alteration but the fifth, so C5(b9) was a bare C5; an altered fifth displaced the augmented or diminished one the triad named, so Caug7(b5) was C7b5; the b5 of Cdim7(b5) was read as the half-diminished mark and turned the diminished seventh into a minor one; and the added ninth of C7(b9)add9 was taken out with the natural. A polychord also repeated a pitch its layers shared — the D of C9|D came back twice. Two more of the same shape: the diminished seventh was given for "dim7" alone, so Cdim9 came back with a minor seventh — the half-diminished ninth, a different chord — and Gdim9 read vø9 in a report; and the m, maj or sus written beside a power chord was dropped by stated policy, so Cm5 parsed to the bare fifth.

Exceptions

ArgumentNullException

symbol is null.

SuggestNext(string[], int)

Suggest the next chord(s) that would sound good after the given progression. Returns a list of suggestions with reasoning and quality scores.

public static List<ChordSuggestion> SuggestNext(string[] chordSymbols, int maxSuggestions = 5)

Parameters

chordSymbols string[]
maxSuggestions int

Returns

List<ChordSuggestion>

Exceptions

ArgumentNullException

chordSymbols is null.

TryParseChordSymbol(string, out int[])

Try to parse a chord symbol into MIDI pitches. Unlike ParseChordSymbol(string), which yields an empty array for anything it cannot parse, this reports success explicitly so callers can tell "unparsable" apart from "parsed to nothing".

public static bool TryParseChordSymbol(string symbol, out int[] pitches)

Parameters

symbol string
pitches int[]

Returns

bool

TryParseChordSymbol(string, out int[], out IReadOnlyList<string>)

Try to parse a chord symbol into MIDI pitches, also returning the parse errors encountered. Useful for surfacing why a symbol was rejected.

public static bool TryParseChordSymbol(string symbol, out int[] pitches, out IReadOnlyList<string> errors)

Parameters

symbol string
pitches int[]
errors IReadOnlyList<string>

Returns

bool