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

Some of the data sanitization applied in write() should be usable when reading #85

Open
douglaseck opened this issue Aug 31, 2016 · 3 comments

Comments

@douglaseck
Copy link
Contributor

pretty_midi.py write() function does a lot of nice sanity checking and normalization of the data. For example, it sorts note onsets by time, pitch and velocity. It also checks for note-on and note-off ordering. And some other nice stuff (default time signature, etc).

Much of this sanitization should be available without having to write the file and read it back in. It would mean pulling a bunch of code out of write() into a sanitize_instruments() function. It would have to be slightly rewritten to operate over instruments rather than tracks. I guess we'd want it to be non-destructive so that it would be optional to use at the time of reading in.

@craffel
Copy link
Owner

craffel commented Sep 1, 2016

Sounds useful to me!

It also checks for note-on and note-off ordering

I don't think this particular distinction exists in pretty_midi, unless you mean checking that a given Note has start < end; that's covered by Instrument.remove_invalid_notes.

@douglaseck
Copy link
Contributor Author

I mean
https://github.com/craffel/pretty-midi/blob/master/pretty_midi/pretty_midi.py#L1340

On Thu, Sep 1, 2016 at 10:12 AM, Colin Raffel [email protected]
wrote:

Sounds useful to me!

It also checks for note-on and note-off ordering

I don't think this particular distinction exists in pretty_midi, unless
you mean checking that a given Note has start < end; that's covered by
Instrument.remove_invalid_notes
https://github.com/craffel/pretty-midi/blob/master/pretty_midi/instrument.py#L292
.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#85 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/APQ6Qh9t09v3wHA-iNvv0D_25gja6KSGks5qlweVgaJpZM4JyLTc
.

@craffel
Copy link
Owner

craffel commented Sep 1, 2016

I don't think that part is not relevant for pretty_midi's representation of MIDI data, because all notes are independent. That is, all notes in pretty_midi include an explicit correspondence between note on and note off, which isn't true in MIDI (hence the need for that code).

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