Sign in to follow this  
floste

Midi-file: how do "delta-times" differ from "running status"-data

Recommended Posts

floste    100
Ive got a quite special problem and couldn't find any answer using google. Thats why i decides to ask my question here: In midi-files there is the time to wait followed by the event-id and the event-data. These three informations repeat over and over till the end of the track. The delta-time is terminated by a missing msb. The status is only one byte long. But how long is the event-data? There is a specification saying how many parameters a certain command has, but there is also a thingy called "Running status", wich means if two messages have the same statusbyte and no delta-time these two informations are just left out and only the new event-data is written. Because a delta-time may be just one byte long i cannot just use the msb to find the end. how to solve this then? I hope everyone understands me, because my inglish is not very good.

Share this post


Link to post
Share on other sites
Zahlman    1682
As far as I can tell from a few minutes of research and a vague recollection:

The delta-time is included in running mode; only the command is left out. So depending on the command you read the first time, you know how many bytes are data, and then the next byte must start the delta-time.

You know whether the data after the delta-time is a command or data for running mode because command bytes will always have the high bit set. (Running mode will not be used for a meta-event because there is no reason to have two meta-events of the same type in a row.)

Share this post


Link to post
Share on other sites
floste    100
Ive just re-coded the whole parser seperating the playing from the reading. The result is even shorter and more readable.

Now it works quite well!

Thx

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this