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

Don't set status byte on Meta Message (Fix #1574) #1575

Merged
merged 2 commits into from
May 18, 2023

Conversation

TimFelixBeyer
Copy link
Contributor

Fixes #1574
When loading a MIDI file, messages can set a (running) status byte. However, meta messages don't set the status byte.

This leads to problem on several MIDI files, for example 8584aaa73eb54bae39708da8be5e6282.mid from the lakh dataset.

It could be argued that the != 0xff check is too conservative as running status is only applicable for messages in the range 0x8n - 0xEn, the proposal is this way to be aligned with other python midi libraries:
https://github.com/mido/mido/blob/bff6bf2a8711e33782de5661ed5ccdffb0bb1688/mido/midifiles/midifiles.py#L204-L206

When loading a MIDI file, messages can set a (running) status byte. However, meta messages don't set the status byte.
Compare e.g. here: https://github.com/mido/mido/blob/bff6bf2a8711e33782de5661ed5ccdffb0bb1688/mido/midifiles/midifiles.py#L204-L206 

This leads to problem on several MIDI files, for example 8584aaa73eb54bae39708da8be5e6282.mid from the lakh dataset.
@coveralls
Copy link

coveralls commented May 16, 2023

Coverage Status

Coverage: 93.104% (+0.003%) from 93.101% when pulling 2cc61a4 on TimFelixBeyer:patch-4 into 0f9d6cc on cuthbertLab:master.

@mscuthbert
Copy link
Member

Only q: Should a meta 0xFF message set lastStatusByte to None instead or is the lastStatusByte still valid?

(btw -- preference for using elif in the patch rather than an else clause followed directly by if with no else)

@TimFelixBeyer
Copy link
Contributor Author

Only q: Should a meta 0xFF message set lastStatusByte to None instead or is the lastStatusByte still valid?

I believe the lastStatusByte is still valid - the second source I mentioned in #1574 contains this quote about meta events “Also, they can be interleaved within other messages without affecting running status in any way” - that’s how Mido treats it as well.

@mscuthbert
Copy link
Member

I believe the lastStatusByte is still valid - the second source I mentioned in #1574 contains this quote about meta events “Also, they can be interleaved within other messages without affecting running status in any way” - that’s how Mido treats it as well.

Great -- thank you for that clarification. With it, I'm thrilled to merge. (The elif is a nice bonus)

@mscuthbert mscuthbert merged commit acf926c into cuthbertLab:master May 18, 2023
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

Successfully merging this pull request may close these issues.

MIDI MetaMessages shouldn't set status byte
3 participants