Author Topic: MP3 tag reading....Help  (Read 3484 times)

xandaz

  • Member
  • **
  • Posts: 105
  • I luv you babe
MP3 tag reading....Help
« on: August 19, 2012, 11:30:16 PM »
   Hi guys... i really haven't got any code to provide. Can tab reading be done via funtions? like mci? or do i need to read the file?
   Thanks
nothing to report.

ragdog

  • Member
  • ****
  • Posts: 610
Re: MP3 tag reading....Help
« Reply #1 on: August 19, 2012, 11:41:29 PM »
Use ReadFile or Mapping file

for ID3v1

Offset   Lenght   Information

0           3           „TAG“ label ID3v1-Blocks
3           30           Songtitel
33           30           Artist
63           30           Album
93           4           Year
97          30           Comments
127          1           Genre

Is a simply way

for ID3v1.1, ID3v2, ID3v2.2, v2.3 and v2.4 must you look for this structur all can you find by google

or Donkey have writte a good example can you find in the forum backup

xandaz

  • Member
  • **
  • Posts: 105
  • I luv you babe
Re: MP3 tag reading....Help
« Reply #2 on: August 22, 2012, 12:32:12 AM »
   thanks ragdog... i had seen a c sample and kinda felt it was the first 127 bytes. Thanks.
nothing to report.

UoSunsetter

  • Guest
Re: MP3 tag reading....Help
« Reply #3 on: August 26, 2012, 12:05:04 AM »
I've written an MP3 player with IDv1 tag reader in C++ like 2 years ago. If you are OK with that old and simple tag version, I can find it from my archive and provide you c++ code. I would have converted them to MASM for you if I had enough ASM skills  :( It is quite simple actually. Just reading last 128 bytes(not sure but something like that), and the structure is like 30 char for artist 30 char for album etc.. Maybe it's the same tag version that you found in C language.

Btw, IDv1 may be outdated a bit since it limits  the user in terms of length. However, reading other tags seemed harder to me :P

ragdog

  • Member
  • ****
  • Posts: 610
Re: MP3 tag reading....Help
« Reply #4 on: September 09, 2012, 04:17:26 AM »
Hi

I have search on the old board and have found a example
http://www.masmforum.com/board/index.php?topic=10107.msg74019#msg74019

jj2007

  • Member
  • *****
  • Posts: 9388
  • Assembler is fun ;-)
    • MasmBasic
Re: MP3 tag reading....Help
« Reply #5 on: September 09, 2012, 05:54:48 AM »
Format specs are inter alia here. Below a quick & dirty attempt. ID3v1 is found at the end of file, ID3v2 at the beginning - this is code for ID3v1.
Sample output:
songtitle       01 - (Da Le) Yaleo
artist          Santana
album           Supernatural
year            1999
Id3comment
track           Track 1


include \masm32\MasmBasic\MasmBasic.inc   ; download
ID3v1 STRUCT
  header   db 3 dup(?)
  songtitle   db 30 dup(?)
  artist   db 30 dup(?)
  album   db 30 dup(?)
  year   db 4 dup(?)
  Id3comment   db 28 dup(?)
  zerobyte   db ?
  track   db ?
  genre   db ?

ID3v1 ENDS

  Init
  Let esi=New$(128)   ; create a 128 byte string
  Open "I", #1, CL$()   ; open commandline-specified file for reading
  sub Lof(#1), 128   ; get offset lof-128
  Seek #1, eax      ; move file pointer
  Input #1, esi, 128   ; fill the string
  Close
  xor ecx, ecx
  .Repeat
   .if byte ptr [esi+ecx]<=32
      mov byte ptr [esi+ecx], " "   ; convert to plain text
   .endif
   inc ecx
  .Until ecx>=ID3v1.track   ; but not the track byte
  Dim TagDesc$( 8 )
  Let TagDesc$(0)="songtitle "
  Let TagDesc$(1)="artist    "
  Let TagDesc$(2)="album     "
  Let TagDesc$(3)="year      "
  Let TagDesc$(4)="Id3comment"
  Let TagDesc$(5)="track     "
  Let TagDesc$(6)="genre     "
  Dim Tag$( 8 )
  Let Tag$(0)=Mid$(esi, 1+ID3v1.songtitle, 30)
  Let Tag$(1)=Mid$(esi, 1+ID3v1.artist, 30)
  Let Tag$(2)=Mid$(esi, 1+ID3v1.album, 30)
  Let Tag$(3)=Mid$(esi, 1+ID3v1.year, 4)
  Let Tag$(4)=Mid$(esi, 1+ID3v1.Id3comment, 28)
  movzx ecx, byte ptr [esi.ID3v1.track]
  Let Tag$(5)=Str$("Track %i", ecx)
  For_ ebx=0 To 5
   PrintLine TagDesc$(ebx), Tb$, Tag$(ebx)
  Next
  Inkey "ok"
  Exit
end start

Edit: The ID3v2 header can be found here. Attention the size field is big endian, you need a bswap eax or similar to get it working.
« Last Edit: September 09, 2012, 10:44:11 AM by jj2007 »