YatingMusic/miditoolkit

Omitted notes during midi parsing

kyungyunlee opened this issue · 2 comments

Hi,
I was wondering if there is a possibility that a note might have been omitted during the midi parsing stage.

I have an example audio from the groove dataset (https://magenta.tensorflow.org/datasets/groove) , where some notes seem to be missing after parsing. I hope you can try by downloading the dataset from the website, since I don't think I should upload it here :)
For example,
'groove/drummer1/eval_session/1_funk-groove1_138_beat_4-4.mid' this file, one kick drum is missing in the first bar on the 3rd beat.

I might be mistaken, so please let me know if this could happen from using the midi_parser.
Thank you!!

Hi,

I test the midi file you mentioned on three different packages - miditoolkit, pretty_midi, mido. Here is my testing code:

from miditoolkit.midi import parser as mid_parser  
import pretty_midi as pm
import mido

# testcase
path_midi = 'groove/drummer1/eval_session/1_funk-groove1_138_beat_4-4.mid'
 
# load                                   
mt_obj = mid_parser.MidiFile(path_midi)
pm_obj = pm.PrettyMIDI(path_midi)
mido_obj = mido.MidiFile(path_midi)

# check
print('pretty-midi:', len(pm_obj.instruments[0].notes))
print('miditoolkit:', len(mt_obj.instruments[0].notes))

# mido msg
cnt_note_on = 0
cnt_note_off = 0
note_ons = []
note_offs = []
for msg in mido_obj:
    if msg.type == 'note_on' :
        if msg.velocity == 0:
            note_offs.append(msg)
        else:
            note_ons.append(msg)
    if msg.type == 'note_off':
        note_offs.append(msg)

# check
print(' cnt_note_on:', len(note_ons))
print('cnt_note_off:', len(note_offs))

And the ouput is:

pretty-midi: 410
miditoolkit: 410
 cnt_note_on: 410
cnt_note_off: 410

I also dump the midi obj and compare it with the original one in Logic ProX, but I couldn't find missing notes.

Could you run my codes and post the results, or take a snapshot of DAW?

I made a mistake when counting bars... :/
Thank you so much for the fast check and help!
The library has been useful :)