Skip to content

Commit

Permalink
Merge pull request #1363 from malcolmsailor/dominant_7ths
Browse files Browse the repository at this point in the history
match d43, d65, etc.
  • Loading branch information
mscuthbert authored Aug 10, 2022
2 parents c2f5c6d + 41f264a commit 6f684b3
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions music21/roman.py
Original file line number Diff line number Diff line change
Expand Up @@ -1597,7 +1597,8 @@ class RomanNumeral(harmony.Harmony):
>>> rn_minor_64_secondary.secondaryRomanNumeral
<music21.roman.RomanNumeral V in e minor>
Dominant 7ths can be specified by putting d7 at end:
Dominant 7ths can be specified by the character 'd' followed by the figure
indicating the inversion of the chord:
>>> r = roman.RomanNumeral('bVIId7', key.Key('B-'))
>>> r.figure
Expand All @@ -1606,13 +1607,20 @@ class RomanNumeral(harmony.Harmony):
>>> cp(r)
['A-5', 'C6', 'E-6', 'G-6']
>>> r = roman.RomanNumeral('VId7')
>>> r = roman.RomanNumeral('VId42')
>>> r.figure
'VId7'
'VId42'
>>> r.key = key.Key('B-')
>>> cp(r)
['G5', 'B5', 'D6', 'F6']
['F5', 'G5', 'B5', 'D6']
>>> r = roman.RomanNumeral('IVd43', key.Key('B-'))
>>> r.figure
'IVd43'
>>> cp(r)
['B-4', 'D-5', 'E-5', 'G5']
>>> r2 = roman.RomanNumeral('V42/V7/vi', key.Key('C'))
>>> cp(r2)
Expand Down Expand Up @@ -1803,6 +1811,11 @@ class RomanNumeral(harmony.Harmony):
>>> cp(r)
['G5', 'B5', 'D6', 'F6']
>>> r = roman.RomanNumeral('IVd6/5')
>>> r.key = key.Key('Eb')
>>> cp(r)
['C5', 'E-5', 'G-5', 'A-5']
>>> r = roman.RomanNumeral('vio', em)
>>> cp(r)
['C#5', 'E5', 'G5']
Expand Down Expand Up @@ -2361,10 +2374,14 @@ def _setImpliedQualityFromString(self, workingFigure):
workingFigure = workingFigure[1:]
impliedQuality = 'augmented'
# impliedQualitySymbol = '+'
elif workingFigure.endswith('d7'):
elif 'd' in workingFigure:
m = re.match(r'(?P<leading>.*)d(?P<figure>7|6/?5|4/?3|4/?2|2)$', workingFigure)
if m is None:
raise RomanException(
f'Cannot make a dominant-seventh chord out of {workingFigure}. '
"Figure should be in ('7', '65', '43', '42', '2').")
# this one is different
# # TODO(msc): what about d65, etc.?
workingFigure = workingFigure[:-2] + '7'
workingFigure = m.group('leading') + m.group('figure')
impliedQuality = 'dominant-seventh'
# impliedQualitySymbol = '(dom7)'
elif self.caseMatters and self.romanNumeralAlone.upper() == self.romanNumeralAlone:
Expand Down

0 comments on commit 6f684b3

Please sign in to comment.