Skip to content

Chord round-trip breaks for a seventh with add11/add13: "C7add13" prints as "C713", which reparses as C13 with a 9th and 11th #300

Description

@matt-edmondson

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:

  1. Write the highest contiguous natural stack as a number: 9 → 9, 9+11 → 11, 9+11+13 → 13.
  2. 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.

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