0

In this terabyte era, I find variable-length quantities tiresome. And with my novice abilities I'm struggling to write a C program to write MIDI. I don't want to use an existing library because I don't want to credit anyone.

I had the idea to force all VLQs in my output file to four bytes. I figured that if I stick to the specifications for most-significant-bits, there shouldn't be anything to invalidate my file.

So, with MIDI variable-length quantity rules, are these equivalent ways of writing the number 1?

00000001

10000000 10000000 10000000 00000001

Or is there some nuance that I'm missing?

user240254
  • 11
  • 6

1 Answers1

2

Technically, that would be a legal MIDI file. I have one example at https://github.com/jazz-soft/test-midi-files/blob/main/midi/test-vlq-4-byte.mid Microsoft Media Player plays it correct, however other MIDI players may have problems with it.

  • It would be better to write the proper minimum-length value. The MIDI FIle standard provides sample code to do so, as does the answer to https://stackoverflow.com/questions/24711585/decode-midi-variable-length-field?rq=1 – Paul Dempsey Feb 20 '23 at 20:24