I am trying to extract all notes by instruments from a mid file. The question has been asked : "Music21: Get all Notes per Instrument from a MIDI File", but the answer doesn't work out. Some notes are missing.
In my mid file, the Japanese "Shakuhachi" is used but nothing is printed when the following code is executed:
PATH_FILE = 'my_file.mid'
piece = converter.parse(PATH_FILE)
s2 = instrument.partitionByInstrument(piece)
if s2 is not None:
for i in s2.recurse().parts:
if i.partName == "Shakuhachi":
iNotes = i.notesAndRests.stream()
for note in iNotes:
print(note)
6 instruments are used in the midi file but I can only extract notes from the Piano instrument. Is there is something wrong with the code or are there other techniques to extract notes given an instrument ?
![Here is a view from the software Logic Pro X, showing that the Shakuhashi is used : ]1