Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

End location of MIDI file #56

Open
JLenzy opened this issue Dec 13, 2024 · 5 comments
Open

End location of MIDI file #56

JLenzy opened this issue Dec 13, 2024 · 5 comments

Comments

@JLenzy
Copy link

JLenzy commented Dec 13, 2024

Is it possible to get the end of the MIDI file, as opposed to the end location of the last note?
With this image as an example, it's possible for a MIDI file to have empty space after the final note. But the end() function (I believe) just returns the last note location.
For some processing purposes it would be beneficial if I could access this info!
image

@lzqlzzq
Copy link
Collaborator

lzqlzzq commented Dec 13, 2024

Actually we intentionally drop some MIDI events in order to keep simplicity and stay consistency with other high-level symbolic music processing libraries(pretty-midi, miditoolkit, etc.). And it seems to be retaining most of useful information in MIDI files.
Now these messages are taken into consideration of calculating end:

  • time_signatures
  • key_signatures
  • tempos
  • markers
  • notes(on and off)
  • controls
  • pitch_bends
  • lyrics
    Since we are having troubles desiging low-level message interface for convient manipulation in python, we won' t recently have feasible approach support other messages. Besides, in my trivial opinion, most of events is actually meaningless without note.

@JLenzy
Copy link
Author

JLenzy commented Dec 13, 2024

Thanks @lzqlzzq for the information. Just to provide some context on a use-case here, I am training models that condition on horizontal note density, e.g. the number of notes onsets that trigger within the timespan of the MIDI file.
Right now this has issues because, I either need to hard-code the span of time to analyze (e.g. look at the first 4 bars only) or have the understanding that it will not include empty space at the end of the file. With the second method, a file with a single note at the beginning can appear more dense than a file with 100 notes scattered throughout.

Not a big problem because I can accomplish this with other libraries, but I love symusic for its speed and thought there may already be a way to get this info.

@lzqlzzq
Copy link
Collaborator

lzqlzzq commented Dec 13, 2024

I can see your needs here.
I don' t know where these MIDI files from, and which type of MIDI message is at the "end" of the MIDI file. But since ableton can read it, it should have a MIDI message at the "end". You may provide your MIDI file if convient so I can see what MIDI message is that.
And a possible workaround is to insert any of these messages above at the "end", dummying the "end" of the MIDI file.

@JLenzy
Copy link
Author

JLenzy commented Dec 13, 2024

https://file.io/B2y8ejAvkCpt
here is an example - github won't let me upload a .mid file directly

@lzqlzzq
Copy link
Collaborator

lzqlzzq commented Dec 14, 2024

image
It seems mido didn' t read any other useful message after the last note off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants