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.
Hello. Today I noticed a strange behavior of
voicesToParts
method.Test file. Test code:
Traceback:
I think
voicesToParts
method is not setting aninstrumentName
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 leavestreamScore
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.