Skip to content

Commit

Permalink
Merge pull request #1656 from vanderstel/more-commonName-enharmonics
Browse files Browse the repository at this point in the history
Improve commonName for enharmonic equivalent to minor seventh chords
  • Loading branch information
mscuthbert authored Oct 21, 2023
2 parents b6af0b5 + ddca79e commit a938a8c
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions music21/chord/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4891,6 +4891,12 @@ def commonName(self) -> str:
>>> chord.Chord('C E G C-').commonName
'enharmonic equivalent to major seventh chord'
>>> 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'
Expand Down Expand Up @@ -4948,14 +4954,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,
Expand Down Expand Up @@ -5002,7 +5013,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]
Expand Down

0 comments on commit a938a8c

Please sign in to comment.