The MIDI Forum

  1. Desmond
  2. MIDI Software
  3. Tuesday, 16 July 2019
  4.  Subscribe via email
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! :(
Comment
There are no comments made yet.
Accepted Answer Pending Moderation
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);
}
References
  1. http://www.somascape.org/midi/tech/mfile.html
  2. http://www.music.mcgill.ca/~ich/classes/mumt306/StandardMIDIfileformat.html#BMA2_
Comment
There are no comments made yet.
  1. more than a month ago
  2. MIDI Software
  3. # 1
  • Page :
  • 1


There are no replies made for this post yet.
Be one of the first to reply to this post!