Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Find version and # of bytes in MP3 ID3v2 tag header.
This won't be a real big challenge. Maybe newbies, (like me), or veterans who are bored, will be interested.

I got started in this while trying to better understand the data contained in the ID3v2 header of an MP3 file. There's some good info about this here: Scroll down to paragraph 3.1.

Anyway, the "challenge", is to write a QB program that will read the header of an mp3 file, then report what version/sub-version and number of bytes are contained in the ID3 tag.

All of this info is in the first 10 bytes of the file, so no big problem there. And if its an ID3v2 tag, the first 3 bytes will always be "49 44 33" - (ID3). The 4th byte will be the major revision number, and the 5th byte the minor revision number.
The 6th byte is some "options" flags and bytes 7 through 10 are the tag size.

So far so good - but here's the catch: bytes 7 through 10 store the tag size in an oddball fashion. The link above explains it pretty well, but basically, its in HEX notation, but with MSD bit of each byte ignored, making the highest possible hex value 7F 7F 7F 7F.
Makes for some tricky math.

For instance; 00 00 02 01 = 257 and 00 00 0C 28 = 1576

If anyone's interested, it made for some good practice programming. Here's some files that you can download to help out, or to just see how I did it:

(They're all scanned for virus's.)

HeadByte.exe The compiled program, if you want to see it work without peeking at the source code.

HeadByte.bas The source code. (No peeking - unless you want to.) Wink

Header.exe A simple app to show you the first 10 bytes of an mp3 file. (Or any file, for that matter.)

trash.mp3 A garbage mp3 file thats not much more than a header just to test the above programs. (Although, none of the above programs will harm any files. They just read, no writing involved.)

Header.exe and HeadByte.exe both have minimul help files built in. Just invoke either with nothing else on the command line. Both of these have been tested on a DOS 6.22 machine and a Win98SE machine with no problems.

Let me know what you think. Smile


Edit: Links fixed. Doggone things were case sensitive!

Forum Jump:

Users browsing this thread: 1 Guest(s)