jongwook / onsets-and-frames

A Pytorch implementation of Onsets and Frames (Hawthorne 2018)
MIT License
208 stars 65 forks source link

Converting midi to txt #3

Open andrei4b opened 5 years ago

andrei4b commented 5 years ago

It seems to be a problem with the midi to tsv conversion. In the original Onsets and frames paper it says:

"If a note is active when sustain goes on, that note will be extended until either sustain goes off or the same note is played again. This process gives the same note durations as the text files included with the dataset."

I noticed that I don't get the same offsets as in the text files, and then I saw that when moving the offset, you search for sustain off but not also for a new onset of the same note. Or did you omit this for a reason?

Adding what's in bold to line 45 from midi.py seems to have the result I desired:

offset = next(n for n in events[offset['index'] + 1:] if n['type'] == 'sustain_off' or n['note'] == offset['note'] or n is events[-1])

jongwook commented 5 years ago

Thanks for catching this! I must have overlooked that possibility.