fbpx


The MIDI Forum

  Tuesday, 16 July 2019
  1 Replies
  7.1K Visits
0
Votes
Undo
  Subscribe
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! :(
4 years ago
·
#4171
0
Votes
Undo
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);
}
  • Page :
  • 1
There are no replies made for this post yet.