Read "C6/9" as a six-nine chord, not a slash bass - #250
Merged
Merged
Conversation
Chord.TryParse treated everything after the first "/" as a slash-bass note and required it to start with a note letter, so the six-nine symbol found on most jazz lead sheets — C6/9, Cm6/9 — failed to parse at all. When the token after the slash is a bare "9" directly following a "6", read it as the six-nine idiom instead: rewrite it to the equivalent "add9" spelling the modifier reader already understands, so the ninth is added rather than implying a dominant seventh the way a bare "9" would. Reading the rewritten symbol from the top means a real slash bass after it still parses, as in "C6/9/G". Everything else after a slash is still required to be a note letter, so "C/9" and "C6/11" remain rejected. Fixes #248 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MNK9bgoZL8ocxTSncTfDEp
|
This was referenced Sep 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #248
The problem
Chord.TryParsetreated everything after the first/as a slash-bass note, callingTryParseRooton it — which requires the first character to be a note letter A–G. The six-nine symbol found on most jazz lead sheets (C6/9,Cm6/9,F6/9) is not a slash chord at all: the/9stacks an added ninth on a sixth chord."9"is not a note letter, soChord.TryParse("C6/9")returnedfalseandChord.Parse("C6/9")threwFormatException— even though the package documents sixths, ninths and slash bass as supported.The change
Semantics.Music/Chord.cs:TryReadRootno longer fails outright when the post-slash token is not a note letter. It first asksTryRewriteSixNinewhether the symbol is the six-nine idiom — a bare9directly after a6.TryRewriteSixNinerewritesC6/9toC6add9, the spellingConsumeModifiersalready understands. Routing throughadd9rather than a bare9is what keeps the ninth an addition: a bare9would run throughApplyExtensionsand imply a dominant seventh the chord does not have.C6/9/Gis a six-nine over a G bass.C6/9parses toSixth = Natural,Tensions |= Nine,Seventh = None, no bass — tones[0, 4, 7, 9, 14], which isCadd9plus the natural sixth.The guard is deliberately narrow. A
9not preceded by6(C/9), or one followed by another digit (C6/11), is still rejected, so no previously-invalid symbol other than the idiom starts parsing.ToString()is unchanged and emitsC6add9, which re-parses to an equal chord.Tests
Semantics.Test/Music/ChordTests.cs— five new tests: the parse shape, theChordTones()identity againstCadd9, the minor form, the idiom over a real slash bass, and the negative cases that must still fail.Semantics.Test/Music/ChordRoundTripTests.cs—C6/9,Cm6/9andC6/9/Gadded to the round-trip corpus.Verified by reverting
Chord.csalone and rebuilding: 5 of the 23 chord tests fail (Parse_SixNine_IsAnAddedNinthOverASixth_NotASlashBass,ChordTones_SixNine_IsAdd9PlusTheNaturalSixth,Parse_MinorSixNine,Parse_SixNine_OverASlashBass,CanonicalOutputRoundTrips).Parse_SlashOverANonNoteStillFailspasses either way by design — it pins the guard against over-broadening.With the fix restored, the full suite is green: 1255 tests, 0 failed (8 skipped, Windows-only).
Semantics.Musicbuilds clean across all five target frameworks, and the local SonarCloud analyzer pass documented inCLAUDE.mdreports nothing new in the touched files.Docs
Semantics.Music/README.mdand theChordsummary now list the six-nine idiom among the supported symbols.🤖 Generated with Claude Code
https://claude.ai/code/session_01MNK9bgoZL8ocxTSncTfDEp
Generated by Claude Code