cuthbertLab / music21

music21 is a Toolkit for Computational Musicology
https://www.music21.org/
Other
2.11k stars 400 forks source link

streamScore.voicesToParts bug? #558

Closed 6r1d closed 4 years ago

6r1d commented 4 years ago

Hello. Today I noticed a strange behavior of voicesToParts method.

Test file. Test code:

from music21 import midi, instrument
streamScore = midi.translate.midiFilePathToStream('./_secret.mid')
streamScore = streamScore.voicesToParts()
for part in streamScore:
    print(instrument.Instrument.bestName(part))

Traceback:

File "main.py", line 6, in <module>
  print(instrument.Instrument.bestName(part))
File "/home/grid/.local/lib/python3.6/site-packages/music21/instrument.py", line 203, in bestName
  elif self.instrumentName is not None:
AttributeError: 'Part' object has no attribute 'instrumentName'

I think voicesToParts method is not setting an instrumentName property, but I am not sure how it should be done correctly.


UPD: there's other interesting detail I noticed in this file.

When I open it in MuseScore or MidiEditor, I see "xDrums" and "bDrums" channels there.

If I comment a line with voicesToParts call and leave streamScore as it was, I only see those channels: Sitar, Fretless Bass, Oboe, Piano, Sitar, Electric Bass, Oboe, Piano.

There clearly are some percussion notes, so I assume music21 is losing whole channel? I can hear percussion notes in "xDrums" loud and clear, while "bDrums" is strangely a grand piano channel.


UPD2: I tested the same ideas using converter.parse, everything remains the same.

mscuthbert commented 4 years ago

bestName is not a staticmethod. there's a programming error in your test-code, I'm afraid.

6r1d commented 4 years ago

I see, good to know. Still, the question about part names not matching track names in source MIDI remains.