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

Export Unpitched to MIDI #1315

Merged
merged 9 commits into from
May 23, 2022
Merged

Export Unpitched to MIDI #1315

merged 9 commits into from
May 23, 2022

Conversation

jacobtylerwalls
Copy link
Member

@jacobtylerwalls jacobtylerwalls commented May 21, 2022

Fixes #238

  • add tests

@coveralls
Copy link

coveralls commented May 21, 2022

Coverage Status

Coverage increased (+0.004%) to 93.051% when pulling 0e98d60 on unpitched-midi-export into 0d3d7b1 on master.

@@ -1776,6 +1776,7 @@ class Unpitched(NotRest):

def __init__(self, displayName=None, **keywords):
super().__init__(**keywords)
self._chordAttached: t.Optional['music21.percussion.PercussionChord'] = None
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was already being set in ChordBase._add_core_or_init(), but without being initialized anywhere.

@jacobtylerwalls jacobtylerwalls changed the title WIP -- export Unpitched to MIDI Export Unpitched to MIDI May 21, 2022
@jacobtylerwalls jacobtylerwalls marked this pull request as ready for review May 21, 2022 17:59
@mscuthbert
Copy link
Member

Super wonderful! Thank you!

Is there a test for if the instrument is stored directly on the unpitched element? Can be added later.

@mscuthbert mscuthbert merged commit c39094a into master May 23, 2022
@mscuthbert mscuthbert deleted the unpitched-midi-export branch May 23, 2022 01:43
Comment on lines +4090 to +4100
# Change the stored instrument: affects that note only
m.notes.first().storedInstrument = instrument.Agogo()

trks = streamHierarchyToMidiTracks(m)
mixed_trk = trks[1]

self.assertTrue({ev.channel for ev in mixed_trk.events}, {10})
note_ons = [
ev for ev in mixed_trk.events if ev.type is midiModule.ChannelVoiceMessages.NOTE_ON]
self.assertEqual(len(note_ons), 3)
self.assertEqual([ev.pitch for ev in note_ons], [67, 60, 60])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, if I'm following, then that's tested here: put Agogo on the first unpitched note in the stream and get midi note 67 on that one only.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, missed it -- thanks!

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

Successfully merging this pull request may close these issues.

Percussion to midi
3 participants