Qbasicnews.com
November 21, 2019, 07:46:04 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Find version and # of bytes in MP3 ID3v2 tag header.  (Read 2154 times)
Dex4now
Member
*
Posts: 75


WWW
« on: March 18, 2004, 12:54:08 AM »

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:

http://www.id3.org/id3v2.3.0.html  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.  Smiley

Dex

Edit: Links fixed. Doggone things were case sensitive!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!