chordSymbolFigureFromChord fails to identify RomanNumeral with sus4 or 7sus4 figures (missing 5th)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 58/100
Direzione di ricerca
Start with the reproduction in the issue, which calls chordSymbolFigureFromChord on a RomanNumeral built from II7sus4. The compare() helper and CHORD_TYPES in music21/harmony.py decide whether a pitch set without the fifth matches the 7sus templates, and _parseFigure in music21/roman.py shows how the shorthand is expanded. Done means the repro returns a G#7sus-style figure, with the tests in the harmony module still passing; whether a missing fifth should be allowed is a maintainer decision to check first.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
music21 version
9.9.1
Operating System(s) checked
macOS, Linux
Problem summary
chordSymbolFigureFromChord() fails to identify RomanNumeral chords constructed with sus4 or 7sus4 figures (e.g., II7sus4). The function returns Chord Symbol Cannot Be Identified.
This happens because the RomanNumeral parser generates figured bass shorthand that omits the perfect 5th (e.g., 7sus4 resolves to intervals [7, 4]). When this incomplete pitch collection is passed to chordSymbolFigureFromChord(), the internal dictionary matching strictly requires the 5th to be present for any standard suspended or dominant suspended chord templates, causing the match to fail.
Steps to reproduce
import music21
# Create a 7sus4 roman numeral
rn = music21.roman.RomanNumeral("II7sus4", "F#")
# Attempt to extract its chord symbol figure
chord_figure = music21.harmony.chordSymbolFigureFromChord(rn)
print(f"Chord figure: {chord_figure}")
print(f"Pitches present: {[p.name for p in rn.pitches]}")
Expected vs. actual behavior
Expected behavior: chordSymbolFigureFromChord should return G#7sus (or similar) recognizing the suspended dominant chord.
Actual behavior:
Chord figure: Chord Symbol Cannot Be Identified
Pitches present: ['G#', 'C#', 'F#']
More information
The issue stems from a combination of how the RomanNumeral sets up pitches and how chordSymbolFigureFromChord evaluates them.
- Omitted Fifth in Figured Bass Resolution: In
music21.roman._parseFigure,expandShortHandis called to expand7sus4to['7', '4']. Because the 5th is not explicit,rn.pitchescorrectly omits the 5th, yielding only the Root, P4, and m7['G#', 'C#', 'F#']. - Strict Root Forcing: Because it is a
RomanNumeral, the root is strictly forced (e.g.<music21.pitch.Pitch G#4>). - Failure in
harmony.py: Inmusic21/harmony.pywithinchordSymbolFigureFromChord, thecompare()helper function iterates throughCHORD_TYPES. The notation string for a standard suspended 7th requires the 5th to be present, and it is not explicitly marked as a permitted omission for this chord type. Because the 5th is missing,comparereturnsFalsefor the7sustemplates, eventually falling back toChord Symbol Cannot Be Identified.
Attempted Workarounds
Manually injecting the perfect 5th into the roman numeral before passing it to the analyzer allows it to match correctly:
rn = music21.roman.RomanNumeral("II7sus4", "F#")
rn.add("D#5") # Explicitly add the missing P5
print(music21.harmony.chordSymbolFigureFromChord(rn))
# Output: 'G#7sus'
- Lingua principale
- Python
- Stelle
- 2.6k
- Fork
- 459
- Merge medio
- 1g 7h
- PR unite (30g)
- 40
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di cuthbertLab/music21
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
cuthbertLab/music21#2084 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
cuthbertLab/music21#2082 ·
I maintainer di solito rispondono entro 1 giorno
-
`TypeError` in `ChordReducer.run()` on multi-part `stream.Score` without instrument `partId`sAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
cuthbertLab/music21#2074 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
cuthbertLab/music21#2055 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Slur bezier-x/y from start element gets overwritten by stop element's valuesForse di nuovo libera @bingliscodes l’ha presa 10 giorni fa e non c’è nessuna pull request aperta. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
cuthbertLab/music21#2019 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di cuthbertLab/music21
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
lidofinance/diffyscan#239 ·
I maintainer di solito rispondono entro 1 giorno
-
docs: the dev-setup table and AGENTS.md name the reviewed_by guard that CI's Changelog job runsApertaarea: tools documentation good first issue ready for a contributor
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
eyalgolan/statecraft-israel#873 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
GET rooms API returns 500 due to nonexistent Room.is_active attributeForse già presa @Mars-60 l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
Add cover art to song rowsApertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 5 giorni
-
Harmony OPeNDAP SubSetter (HOSS) Geographic production rssmif16d 7 XYZ_PROV
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
nasa/harmony-autotester#341 ·