-
Notifications
You must be signed in to change notification settings - Fork 152
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
Writing and reading back in should be roughly lossless #52
Comments
I was going to file a bug but I'll attach it to this bug. In TimeSignature, you don't keep around the notated 32nd-notes in a MIDI quarter-note (24 MIDI Clocks) so when you write a file, this information is lost. An incoming TimeSignature might be: If you don't want to store info, you could at least set some reasonable default such as you do when you write the default 4/4 time signature: That seems like a reasonable default. I personally don't care all that much. I just don't want these files to break some sequencer software because of 0 values in these fields. |
Also it's probably not a good idea to always add a default time signature. At the very least only add a time signature if there's not already a time signature defined at time 0. |
Ah, interesting, I hadn't noticed that we were missing that information when writing out (here). Do you know if this is totally meta-information, or will they ever effect playback?
I think I read somewhere that it's bad practice in a MIDI file to not include any time signature changes, but it turns out about 10% of the MIDI files I've found "in the wild" have no time signature events. So, not sure which the best choice is, but I agree that we shouldn't add a default time signature at time 0 if there's already one there. |
I doubt if it affects playback. It broke a unit test that verifies that a
|
For sure. Since this issue is kind of a far-reaching one, I created a separate issue, which I can resolve soon #61. |
Out of curiosity, I grabbed 10,000 random MIDI files and computed the relative occurrence of different values in the third and fourth data slots of
Thank goodness 8 appears in slot 4 97% of the time, I'm curious about the files for which it doesn't (161 32nd notes in a quarter note in 24 different time signature change events??)... I would think that slot 3 only effects metronomes, so can be safely ignored (with a suitable warning saying it is always set to 24 on write-out), but I am a little suspicious that having a "number of 32nd notes per quarter note" which is not 8 will effect playback. I will investigate, at some point. |
Can you post this MIDI file somewhere so we can test it out? |
I created a separate issue #131 with more details about the cause. |
Related: #161 "Inconsistent behaviour for short (zero-duration) notes" |
I.e. if you write a MIDI file out and read it back in, you should get at least the same collection of notes, time signature changes, tempo changes, pitch bends, key signatures, etc. (all of the data that
pretty_midi
stores)The text was updated successfully, but these errors were encountered: