News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

MP3 tag reading....Help

Started by xandaz, August 19, 2012, 11:30:16 PM

Previous topic - Next topic

xandaz

   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

ragdog

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

   thanks ragdog... i had seen a c sample and kinda felt it was the first 127 bytes. Thanks.

UoSunsetter

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

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

#5
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.