craffel / pretty-midi

Utility functions for handling MIDI data in a nice/intuitive way.
MIT License
856 stars 151 forks source link

Notes missing in piano roll #207

Open page200 opened 2 years ago

page200 commented 2 years ago

get_piano_roll doesn't show some of the notes. You can easily find such cases by choosing a low fs value.

Here instead of int(note.start*fs):int(note.end*fs), a different rounding mechanism might solve the problem, preventing the duration from being 0 for example as follows: int(note.start*fs):max(int(note.end*fs),int(note.start*fs)+1)

Thank you and happy holidays!

craffel commented 2 years ago

I think this is a matter of convention, i.e. if a note falls entirely within a sampling interval should it be included or not? I would welcome a PR to make this behavior configurable (I think int(floor(...)):int(ceil(...)) would make most sense).

TimFelixBeyer commented 2 years ago

FYI, I tried to fix this in PR #195