From 8b27f5d60ffa9c36be64212bf9ba02995f7588ff Mon Sep 17 00:00:00 2001 From: Malcolm Sailor Date: Sun, 7 Aug 2022 19:35:02 -0400 Subject: [PATCH 1/2] match d43, d65, etc. --- music21/roman.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/music21/roman.py b/music21/roman.py index 3726791e1b..d378004f84 100644 --- a/music21/roman.py +++ b/music21/roman.py @@ -1606,13 +1606,20 @@ class RomanNumeral(harmony.Harmony): >>> cp(r) ['A-5', 'C6', 'E-6', 'G-6'] - >>> r = roman.RomanNumeral('VId7') + >>> r = roman.RomanNumeral('VId2') >>> r.figure - 'VId7' + 'VId2' >>> 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) @@ -1785,6 +1792,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'] @@ -2334,10 +2346,9 @@ def _setImpliedQualityFromString(self, workingFigure): workingFigure = workingFigure[1:] impliedQuality = 'augmented' # impliedQualitySymbol = '+' - elif workingFigure.endswith('d7'): + elif m := re.match(r'(?P.*)d(?P
7|6/?5|4/?3|4/?2|2)$', workingFigure): # 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: From 867c69dcd4a522c2cc2218c9688ebe86e3184402 Mon Sep 17 00:00:00 2001 From: Malcolm Sailor Date: Tue, 9 Aug 2022 06:49:31 -0400 Subject: [PATCH 2/2] small fixes --- music21/roman.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/music21/roman.py b/music21/roman.py index d378004f84..6936c1093d 100644 --- a/music21/roman.py +++ b/music21/roman.py @@ -1597,7 +1597,8 @@ class RomanNumeral(harmony.Harmony): >>> rn_minor_64_secondary.secondaryRomanNumeral - 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 @@ -1606,9 +1607,9 @@ class RomanNumeral(harmony.Harmony): >>> cp(r) ['A-5', 'C6', 'E-6', 'G-6'] - >>> r = roman.RomanNumeral('VId2') + >>> r = roman.RomanNumeral('VId42') >>> r.figure - 'VId2' + 'VId42' >>> r.key = key.Key('B-') >>> cp(r) @@ -2346,7 +2347,12 @@ def _setImpliedQualityFromString(self, workingFigure): workingFigure = workingFigure[1:] impliedQuality = 'augmented' # impliedQualitySymbol = '+' - elif m := re.match(r'(?P.*)d(?P
7|6/?5|4/?3|4/?2|2)$', workingFigure): + elif 'd' in workingFigure: + m = re.match(r'(?P.*)d(?P
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 workingFigure = m.group('leading') + m.group('figure') impliedQuality = 'dominant-seventh'