Skip to content

[patch] Spell the raised seventh above a flat seventh as #7, not a lowered tonic - #406

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/304-leading-tone-sharp-seven
Oct 9, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/304-leading-tone-sharp-seven

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #304

What changed

Scale.DegreeOf spells a chromatic pitch against its nearest scale neighbours and breaks a tie toward the flat. Above the last degree there is no upper neighbour, so the flat candidate wrapped round the octave to degree 1. In every flat-seventh mode, semitone 11 then came out as a lowered tonic: G# in A aeolian was (1, -1), and RomanNumeralOf(G#dim) returned bi°.

Now, when the flat spelling only exists by wrapping, the tie goes to the sharp spelling of the last degree. A strictly closer flat still wins, and every other tie still prefers the flat, so major-key bII, bIII, bVI and bVII don't change.

Tests

  • ScaleTests.DegreeOf_RaisedSeventhAboveAFlatSeventhIsSharpSeven: G# in A aeolian is (7, +1)
  • KeyTests.RomanNumeral_MinorLeadingToneChordIsSharpSeven: G#dim in A aeolian and F#dim in G mixolydian both give #vii°
  • KeyTests.RomanNumeral_MinorLeadingToneChordRoundTrips: RomanNumeralOf → ChordFromRomanNumeral gives back G#dim

With the Scale.cs change reverted, the first two tests fail. The round-trip test passes either way and is there as a guard. The existing DegreeOf_ChromaticPrefersFlatOfUpperDegree still passes. The full Semantics.Test suite passes on net10.0 (1483 passed, 8 skipped).

🤖 Generated with Claude Code

https://claude.ai/code/session_0176ydtLncnCjKchHXEPCh7H


Generated by Claude Code

…wered tonic

Scale.DegreeOf broke the chromatic tie toward the flat spelling even when the
flat candidate only existed by wrapping round the octave, so G# in A aeolian
came out as degree 1 lowered and Key.RomanNumeralOf labelled the minor-key
leading-tone chord "bi°". When the flat would wrap, the tie now goes to the
sharp spelling of the last degree; every other tie still prefers the flat.

Fixes #304

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0176ydtLncnCjKchHXEPCh7H
@sonarqubecloud

sonarqubecloud Bot commented Oct 8, 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.

Key.RomanNumeralOf labels the minor-key leading-tone chord as a flattened tonic: G#dim in A minor is "bi°", not "#vii°"

2 participants