Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

match d43, d65, etc. #1363

Merged
merged 3 commits into from
Aug 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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']

mscuthbert marked this conversation as resolved.
Show resolved Hide resolved
>>> 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