music21 seems to modify MIDI file when reading/rewritting it

48 views Asked by At

I've got a midi file from the Groove MIDI dataset. Here is an example: groove/drummer1/eval_session/1_funk-groove1_138_beat_4-4.mid.

I'm using music21 to manipulate the midi file, but it seems that it does not read/write properly the file. Here is a quick experiment to show that:

from pathlib import Path

import music21

file_path = Path("groove/drummer1/eval_session/1_funk-groove1_138_beat_4-4.mid")

stream = music21.converter.parse(file_path, quantizePost=False)
stream.write("midi", fp="/tmp/test_write.mid")

So I am basically reading the file from disk, and then immediately rewriting it. But when I open the two files in a MIDI editor, they are different: Two pianorolls side by side

Am I doing something wrong? The files I'm dealing with are drums tracks, maybe there is something different to do in that case?

Versions:

  • Python: 3.11.5
  • Music21: 9.1.0
0

There are 0 answers