Conversation
|
I was quite surprised finding out that MIDO cannot handle running status. Such a basic MIDI feature… I am writing a new back-end and was feeding the parser with midi bytes using running status and wondered why only the first event is accepted. |
|
@Jajcus did you test if the fixes from this PR work for you? Might be good to get some feedback. |
|
@m-vo No, I have not. I wanted to make my code work with the released version of mido, so I implemented a workaround even before I found this merge request. |
|
Per the official midi.org specification, page 5, running status is "For Voice and Mode messages only" aka Channel Messages. I don’t see such filtering in your code. |
|
I made a mistake in my previous comment. Real-Time messages are a special case and the only ones that should not reset/exit the Running status. |
The code only runs in |
|
The specs says the reverse. Common messages can have data bytes (F1, F2, F3) and SysEx has data bytes but are not Running Status enabled. How does this test perform? def test_running_status_common():
"""The last known status byte should not be reused with common or exclusive message"""
assert tokenize([0xf3, 1, 2]) != [
[0xf3, 1], [0xf3, 2]
]To be spec compliant it should pass and from just reading the code, I believe it fails. FWIW I have a spec compliant Running Status implementation part of a work in progress to fix #363. I can extract/PR it since it seems to work fine while I continue working on the EOX issue which is more hairy. |
|
Thanks for the explanation. I must have jumped over the "Running Status will be stopped …" part each time. 🙈
Sounds good. 👍 Closing this PR in favor of #363 then. |
|
If anyone is willing to review my code, I just pushed my work in progress: https://github.com/EMATech/mido/tree/eox The relevant running status implementation is there: EMATech@c6e13e5#diff-657b1756ea262acda7e2095a923fc3f18e64343552164609e0b5badd451151b4 |
Thanks. Please consider opening a (draft) PR, because IMHO it's way easier to review this way. |
|
@m-vo Thanks for the suggestion, done! I didn't know "Draft PR" were a thing. |
Due to the nature of running status, missing or invalid sysex end bytes now issue a warning instead of raising a ValueError. Fix mido#341
We're now storing the last status byte whenever a message with at least one data byte is composed. If a message starts with a data byte this status byte will get injected. This is according to the MIDI spec: running status.
So the following two inputs are considered equal now:
I'm not sure about the right base branch, I'll rebase accordingly if needed.