Skip to content

Chord.Parse reads "-"/"+" alteration signs as chord quality: "C7-9" becomes Cm9, "C7-5" becomes Cm7, "Cmaj7-5" becomes CmMaj7, "C7+9" becomes Caug9 #345

Description

@matt-edmondson

What's wrong

Lead sheets often write an alteration as - or + after a number:

  • C7-9 or C7(-9) means C7♭9
  • C7-5 means C7♭5
  • C7+9 means C7♯9

The parser only recognises b, ♭, # and ♯ as alteration signs (ConsumeTensions, Chord.cs:288-312; ConsumeFifthAlteration, Chord.cs:315-329). Instead:

  • a - anywhere in the body is read as a minor third (IsMinor, Chord.cs:381-384, body.Contains('-'));
  • a + anywhere is read as augmented (DetermineQuality, Chord.cs:360).

Parentheses are stripped first (Chord.cs:66), so the explicit form C7(-9) is misread the same way.

Reproduced

These results come from running each input through the built library at 7167117:

Input Result today (ToString / tones) Meant
C7-9 / C7(-9) Cm79, [0,3,7,10,14] C7♭9, [0,4,7,10,13]
C7-5 Cm7, [0,3,7,10] C7♭5, [0,4,6,10]
Cmaj7-5 Cmmaj7, [0,3,7,11] Cmaj7♭5, [0,4,6,11]
C7-13 Cm713 C7♭13
C7+9 Caug79, [0,4,8,10,14] C7♯9, [0,4,7,10,15]

Each input is parsed as a different chord rather than rejected. In the ♭5 cases the alteration is lost entirely.

Suggested fix

  • When - or + directly follows a digit (so not at the start of the body), read -5/-9/-13 as b5/b9/b13 and +9/+11 as #9/#11. Do this before the quality is decided.
  • Then make IsMinor look for - only at the start of the body.
  • Keep the existing readings of C-, C-7, C-9 (minor ninth), C-7b5, C+, C7+ and C7+5.

Rejecting these spellings would also be acceptable; misreading them is not.

Acceptance criteria

  • Each row in the table produces the "Meant" tones and round-trips.
  • C-7, C-9, C-7b5, C+, C7+ and C7+5 are unchanged.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions