Skip to content

Redesign chord symbols around a shared grammar - #362

Merged
matt-edmondson merged 4 commits into
mainfrom
copilot/fix-redesign-chord-symbols
Oct 2, 2026
Merged

matt-edmondson merged 4 commits into
mainfrom
copilot/fix-redesign-chord-symbols

Conversation

Copilot AI commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Chord parsing and formatting could disagree about token boundaries, implied tensions, and slash basses, causing symbols to change meaning on round-trip. Replace the substring parser and concatenated formatter with a grammar-driven reader and canonical writer.

  • Reader/writer: Consume the complete symbol, enforce token order, reject duplicate or conflicting modifiers, and emit canonical extension, suspension, alteration, add, omission, and bass order.
  • Chord semantics: Preserve altered extension stacks, add MinorSharpFive, and update chord tones and roman-numeral analysis.
  • Compatibility: Continue reading legacy forms such as C79, Csus47, and C6add9.
  • Coverage/docs: Add grammar cases, exhaustive round trips for expressible chords, and document the grammar in the music guide.
Chord.Parse("C7add13").ToString(); // "C7add13"
Chord.Parse("C13b9").ToString();   // "C13b9"
Chord.Parse("Cm#5").ChordTones();  // minor third, augmented fifth

Co-authored-by: matt-edmondson <19528727+matt-edmondson@users.noreply.github.com>
Comment thread Semantics.Music/ChordSymbolReader.cs Fixed
Comment thread Semantics.Music/ChordSymbolWriter.cs Fixed
Comment thread Semantics.Music/ChordSymbolWriter.cs Fixed
Copilot AI and others added 2 commits October 1, 2026 10:19
Co-authored-by: matt-edmondson <19528727+matt-edmondson@users.noreply.github.com>
, #345, #346, #358

Co-authored-by: matt-edmondson <19528727+matt-edmondson@users.noreply.github.com>
Comment on lines +75 to +82
if (symbol.Length == chord.Root.Name.Length)
{
_ = symbol.Append('(').Append(alterations).Append(')');
}
else
{
_ = symbol.Append(alterations);
}
Copilot AI changed the title [WIP] Redesign chord symbols for Chord.Parse and Chord.ToString Redesign chord symbols around a shared grammar Oct 1, 2026
Copilot AI requested a review from matt-edmondson October 1, 2026 10:39
@matt-edmondson
matt-edmondson marked this pull request as ready for review October 2, 2026 03:53
@sonarqubecloud

sonarqubecloud Bot commented Oct 2, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Redesign chord symbols: one grammar for Chord.Parse and Chord.ToString (fixes #300 #322 #336 #340 #341 #344 #345 #346 #358)

2 participants