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

Stream with instrument but no notes crashes when writing MIDI #1013

Closed
jacobtylerwalls opened this issue May 11, 2021 · 0 comments · Fixed by #1014
Closed

Stream with instrument but no notes crashes when writing MIDI #1013

jacobtylerwalls opened this issue May 11, 2021 · 0 comments · Fixed by #1014

Comments

@jacobtylerwalls
Copy link
Member

music21 version

dev

Steps to reproduce

p = stream.Part()
p.insert(instrument.Instrument())
p.write('midi')

Traceback

Traceback (most recent call last):
  File "/Users/jwalls/music21/music21/midi/translate.py", line 2533, in streamToMidiFile
    midiTracks = streamHierarchyToMidiTracks(s,
  File "/Users/jwalls/music21/music21/midi/translate.py", line 2420, in streamHierarchyToMidiTracks
    updatePacketStorageWithChannelInfo(packetStorage, channelByInstrument)
  File "/Users/jwalls/music21/music21/midi/translate.py", line 2357, in updatePacketStorageWithChannelInfo
    initCh = channelByInstrument[instObj.midiProgram]
KeyError: None

More information
Only a problem if there are no notes.
I think we assume parts with no notes are Conductor tracks. Simple fix.

Noticed responding to a m21 list thread May 2021.

@jacobtylerwalls jacobtylerwalls changed the title Stream without notes containing generic Instrument crashes when writing MIDI Stream with instrument but no notes crashes when writing MIDI May 11, 2021
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 a pull request may close this issue.

1 participant