From 57e02594f958c840276d1ce953f747a96acb42f0 Mon Sep 17 00:00:00 2001 From: Joseph VanderStel Date: Wed, 18 Oct 2023 21:10:38 -0400 Subject: [PATCH 1/2] Improve commonName for enharmonic equivalent to minor seventh chords --- music21/chord/__init__.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/music21/chord/__init__.py b/music21/chord/__init__.py index 3457dccda..b12a21322 100644 --- a/music21/chord/__init__.py +++ b/music21/chord/__init__.py @@ -4891,6 +4891,9 @@ def commonName(self) -> str: >>> chord.Chord('C E G C-').commonName 'enharmonic equivalent to major seventh chord' + + >>> chord.Chord('C4 E4 G4 B--4').commonName + 'enharmonic equivalent to minor seventh chord' ''' if any(not p.isTwelveTone() for p in self.pitches): return 'microtonal chord' @@ -4948,14 +4951,19 @@ def commonName(self) -> str: forteClass = self.forteClass # forteClassTn = self.forteClassTn - def _isSeventhWithPerfectFifthAboveRoot(c: Chord) -> bool: + def _isSeventhWithPerfectFifthsAboveRootAndThird(c: Chord) -> bool: ''' For testing minor-minor sevenths and major-major sevenths ''' if not c.isSeventh(): return False hypothetical_fifth = c.root().transpose('P5') - return hypothetical_fifth.name in c.pitchNames + if hypothetical_fifth.name not in c.pitchNames: + return False + hypothetical_seventh = c.third.transpose('P5') + if hypothetical_seventh.name not in c.pitchNames: + return False + return True enharmonicTests = { '3-11A': self.isMinorTriad, @@ -5002,7 +5010,7 @@ def _isSeventhWithPerfectFifthAboveRoot(c: Chord) -> bool: # minor seventh or major seventh chords, # but cannot just test isSeventh, as # that would permit C E G A## (A## as root) - if _isSeventhWithPerfectFifthAboveRoot(self): + if _isSeventhWithPerfectFifthsAboveRootAndThird(self): return ctn[0] else: return 'enharmonic equivalent to ' + ctn[0] From ddca79e5851d2597086151607145bddeb003d2d5 Mon Sep 17 00:00:00 2001 From: Joseph VanderStel Date: Thu, 19 Oct 2023 11:10:30 -0400 Subject: [PATCH 2/2] increase coverage --- music21/chord/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/music21/chord/__init__.py b/music21/chord/__init__.py index b12a21322..17702aa5c 100644 --- a/music21/chord/__init__.py +++ b/music21/chord/__init__.py @@ -4892,8 +4892,11 @@ def commonName(self) -> str: >>> chord.Chord('C E G C-').commonName 'enharmonic equivalent to major seventh chord' - >>> chord.Chord('C4 E4 G4 B--4').commonName + >>> chord.Chord('C E G B--').commonName 'enharmonic equivalent to minor seventh chord' + + >>> chord.Chord('C E G A').commonName + 'minor seventh chord' ''' if any(not p.isTwelveTone() for p in self.pitches): return 'microtonal chord'