craffel / pretty-midi

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

Fix get_piano_roll pedal implementation #195

Open TimFelixBeyer opened 4 years ago

TimFelixBeyer commented 4 years ago

I'm not entirely sure whether I precisely understand the desired output of get_piano_roll. However, after comparing it with https://github.com/magenta/note-seq/tree/master and the piano-roll from there I think there are two small issues with it: One is an off-by-one error and the other happens when a note offset happens just before/after the pedal is pressed down:

Due to rounding, the pedal might be pressed after the note offset has already occurred. For example, both offset a and offset b round to t0, and would be held:

t0--------->t0+fs
|      *     |  pedal
| *          | offset a -> should not be held
|          * | offset b -> should be held

Again I'm not sure whether the spec of get_piano_roll is different from other piano rolls. I think regardless of that, the pedal issue should be addressed.

craffel commented 4 years ago

@maezawa-akira added the sustain pedal functionality, maybe he can comment?

TimFelixBeyer commented 3 years ago

It seems like @maezawa-akira is not active on GitHub anymore. How would you like to proceed?

page200 commented 2 years ago

after comparing it with https://github.com/magenta/note-seq/tree/master and the piano-roll from there

@TimFelixBeyer I can't find the documentation under this link. Do you have code at hand for creating a piano roll from a MIDI file in magenta?