fix: clamp harmony inversion to valid range when quality changes#482
Draft
FelipeDefensor wants to merge 2 commits into
Draft
fix: clamp harmony inversion to valid range when quality changes#482FelipeDefensor wants to merge 2 commits into
FelipeDefensor wants to merge 2 commits into
Conversation
When the chord quality is changed to one with fewer available inversions (e.g. from dominant-seventh to major triad), music21 raised ChordException if the stored inversion exceeded the new maximum. Clamping the inversion via get_inversion_amount() before constructing ChordSymbol and to_roman_numeral() prevents the crash. Closes #468.
The previous fix clamped inversion when constructing ChordSymbol and when calling to_roman_numeral(), but letter_symbol_label still appended '/&<interval>' using the unclamped stored value. So after switching from dominant-seventh + 3rd inversion to a triad, the rendered label read 'C/&7' even though a triad has no 3rd inversion. Extracts clamping into a clamped_inversion property and uses it in all three rendering paths so the display stays consistent.
f885f8e to
47c22bb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
music21.harmony.ChordSymboland before callingto_roman_numeral().get_inversion_amount(quality)helper fromtilia.timelines.harmony.constants.Test plan
Closes #468