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

Improve commonName for enharmonic equivalent to minor seventh chords #1656

Merged
merged 2 commits into from
Oct 21, 2023
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
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
Loading