Skip to content

Support sus4 chords in root-finding algorithm - #1988

Closed
p2rez wants to merge 1 commit into
cuthbertLab:masterfrom
p2rez:fix/sus4-root-finding
Closed

Support sus4 chords in root-finding algorithm#1988
p2rez wants to merge 1 commit into
cuthbertLab:masterfrom
p2rez:fix/sus4-root-finding

Conversation

@p2rez

@p2rez p2rez commented Jul 23, 2026

Copy link
Copy Markdown

Fixes #1650.

Note: This contribution was developed with AI assistance (Claude/Anthropic), as declared per the contributing guidelines.

Problem

chord.Chord('F B- C E-').root() incorrectly returned C instead of F. The _findRoot method's rootnessFunction only scored notes based on thirds, fifths, sevenths, etc. above them, but gave no credit for a fourth, so sus4 chord roots were never correctly identified.

Solution

Added sus4 chord detection to _findRoot. Before scoring, we check whether any note in the chord has both a third and fifth above it. If none do (indicating a sus4 chord), we apply a bonus to notes that have both a fourth and fifth above them, giving sus4 roots the same base score as notes with a third above them in regular chords.

This avoids incorrectly boosting notes in chords that happen to have an eleventh (like C11 = C E G B- D F), where C has both a third and fifth above it, so the sus4 path is not triggered.

Tests

Added testSus4RootFinding in test/test_chord.py covering:

Basic sus4 seventh chord from the issue (F B- C E- → F)
Simple sus4 triad (C F G → C)
sus4 with seventh (C F G B- → C)
Regression: regular major, minor, dominant seventh still correct
Regression: C11 chord still returns C, not F

All 27 tests pass.

Add sus4 chord detection to _findRoot's rootnessFunction. When no note
in the chord has both a third and fifth above it (indicating a sus4 chord),
apply a bonus to notes that have a fourth and fifth above them.

Fixes: chord.Chord('F B- C E-').root() now correctly returns F instead of C.

Resolves cuthbertLab#1650
@mscuthbert mscuthbert closed this Jul 23, 2026
@mscuthbert

mscuthbert commented Jul 23, 2026

Copy link
Copy Markdown
Member

tests do not cover more difficult cases. unwieldy 2-part sol (thanks for AI attempt)

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.

Support sus4 chords in root-finding algorithm

2 participants