What's wrong
Since #293 (ad24784), Chord.Parse accepts add11 and add13 after a seventh. For example, "C7add13" parses as a dominant seventh with tensions {13} only, and a check gives tones [0,4,7,10,21].
The formatter can't write that chord back. AppendTensions (Semantics.Music/Chord.cs:598-622) writes addN only when there is no seventh. With a seventh it writes the highest natural tension as a bare stacked number ("13", "11", "9"). On reparse, ApplyExtensions expands 13 into 9 + 11 + 13.
Observed (scratch app referencing Semantics.Music)
| Input |
ToString() |
Reparsed tones |
Equal |
C7add13 |
C713 |
[0,4,7,10,14,17,21] vs original [0,4,7,10,21] |
False |
C7add11 |
C711 |
gains a 9th |
False |
C9add13 |
C713 |
gains an 11th |
False |
Cmaj7add13 |
Cmaj713 |
gains a 9th and 11th |
False |
The round-trip corpus (ChordRoundTripTests.cs:12-18) has no seventh+addN case, so the tests don't catch this.
Suggested fix
When there is a seventh:
- Write the highest contiguous natural stack as a number: 9 →
9, 9+11 → 11, 9+11+13 → 13.
- Write each remaining natural tension that isn't implied by that number as
addN. For example, {13} gives 7add13 and {9,13} gives 9add13.
The alternative is to reject addN after a seventh in the parser again, but that would undo #293.
Acceptance criteria
C7add13, C7add11, C9add13 and Cmaj7add13 are added to the round-trip corpus, and each one round-trips to equal tones.
What's wrong
Since #293 (ad24784),
Chord.Parseacceptsadd11andadd13after a seventh. For example,"C7add13"parses as a dominant seventh with tensions{13}only, and a check gives tones[0,4,7,10,21].The formatter can't write that chord back.
AppendTensions(Semantics.Music/Chord.cs:598-622) writesaddNonly when there is no seventh. With a seventh it writes the highest natural tension as a bare stacked number ("13","11","9"). On reparse,ApplyExtensionsexpands13into 9 + 11 + 13.Observed (scratch app referencing Semantics.Music)
ToString()C7add13C713[0,4,7,10,14,17,21]vs original[0,4,7,10,21]C7add11C711C9add13C713Cmaj7add13Cmaj713The round-trip corpus (
ChordRoundTripTests.cs:12-18) has no seventh+addN case, so the tests don't catch this.Suggested fix
When there is a seventh:
9, 9+11 →11, 9+11+13 →13.addN. For example,{13}gives7add13and{9,13}gives9add13.The alternative is to reject
addNafter a seventh in the parser again, but that would undo #293.Acceptance criteria
C7add13,C7add11,C9add13andCmaj7add13are added to the round-trip corpus, and each one round-trips to equal tones.