Skip to content

Commit

Permalink
Fix #1685: Harmony parsing errors with doubled characters (#1688)
Browse files Browse the repository at this point in the history
The code intended to only remove the parsed `chordKind` from the string, but in cases where the `chordKind` char occurs multiple times, this would remove all occurrences of the char.
  • Loading branch information
TimFelixBeyer authored Mar 3, 2024
1 parent 0927e39 commit f2f7bad
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion music21/harmony.py
Original file line number Diff line number Diff line change
Expand Up @@ -1890,7 +1890,7 @@ def _getKindFromShortHand(self, sH):
for charString in getAbbreviationListGivenChordType(chordKind):
if sH == charString:
self.chordKind = chordKind
return originalsH.replace(charString, '')
return originalsH[len(sH):]
return originalsH

def _hasPitchAboveC4(self, pitches):
Expand Down Expand Up @@ -3162,6 +3162,12 @@ def testExpressSusUsingAlterations(self):

self.assertEqual(ch1.pitches, ch2.pitches)

def testDoubledCharacters(self):
ch1 = ChordSymbol('Co omit5')
ch2 = ChordSymbol('Cdim omit5')

self.assertEqual(ch1.pitches, ch2.pitches)

def x_testPower(self):
'''
power chords should not have inversions
Expand Down

0 comments on commit f2f7bad

Please sign in to comment.