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

Ignore Unpitched objects in key analysis #1543

Merged
merged 4 commits into from
Mar 30, 2023

Conversation

jacobtylerwalls
Copy link
Member

Fixes #1525

@coveralls
Copy link

coveralls commented Mar 26, 2023

Coverage Status

Coverage: 93.072% (-0.0007%) from 93.073% when pulling dd1b7fb on ignore-unpitched-key-analysis into e45753d on master.

@mscuthbert
Copy link
Member

We should be able to replace this:

        for n in streamObj.notes:
            length = n.quarterLength
             if n.isChord:
                 for m in n.pitchClasses:
                     pcDist[m] += length
             elif isinstance(n, percussion.PercussionChord):
                 for m in n.notes:
                     if isinstance(m, note.Note):
                         pcDist[m.pitch.pitchClass] += length
             else:
                 pcDist[n.pitch.pitchClass] += length

with:

        for n in streamObj.notes:
            length = n.quarterLength
            for p in n.pitches:
                  pcDist[p.pitchClass] += length

@jacobtylerwalls
Copy link
Member Author

jacobtylerwalls commented Mar 29, 2023

Unfortunately, I see this (and having a vague memory of running into this while dev'ing, should have called it out):

Shall I fix this first in a separate PR? EDIT: done! in #1547

>>> from music21 import percussion, note
>>> pChord = percussion.PercussionChord([
...     note.Unpitched(),
...     note.Note('E-4'),
...     note.Note('B-4'),
... ])
>>> pChord.notes
(<music21.note.Unpitched object at 0x10d793850>, <music21.note.Note E->, <music21.note.Note B->)
>>> pChord.pitches
()

@jacobtylerwalls jacobtylerwalls merged commit 37763c4 into master Mar 30, 2023
@jacobtylerwalls jacobtylerwalls deleted the ignore-unpitched-key-analysis branch March 30, 2023 01:22
@mscuthbert
Copy link
Member

THANKS!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

An exception occurred: 'Unpitched' object has no attribute 'pitch'
3 participants