fbpx
Skip to main content

MIDI Forum

Reading delta-time ...
 
Notifications
Clear all

Reading delta-time from file

2 Posts
1 Users
0 Reactions
7,605 Views
Desmond
Posts: 2
New Member
Topic starter
 

Probably the dumbest first question ever!

I’m creating a mid file reader/writer in C#.net and I’m a bit confused about the MTrk event delta-time. Is delta-time stored in one or two bytes? And if it can differ, how can I find the number of bytes to read? Is the first byte of delta the variable length? I'm a bit confused! 🙁

 
Posted : 16/07/2019 10:17 am
Desmond
Posts: 2
New Member
Topic starter
 

Ok I think i've got it now 🙂
http://www.somascape.org helped as it stated delta-time is a variable length value.
This means my code needs to call the following at the start of each event...

doubleword ReadVarLen()
{
register doubleword value;
register byte c;
if((value = getc(infile)) & 0x80)
{
value &= 0x7f;
do
{
value = (value << 7) + ((c = getc(infile))) & 0x7f);
} while (c & 0x80);
}
return(value);
}

 
Posted : 16/07/2019 2:09 pm
Share: