Results 1 to 6 of 6

Thread: [RESOLVED] Searching for 2 bytes lost - id3tag v1.1

  1. #1

    Thread Starter
    Hyperactive Member RS_Arm's Avatar
    Join Date
    Mar 2007
    Location
    Planet Earth
    Posts
    282

    Resolved [RESOLVED] Searching for 2 bytes lost - id3tag v1.1

    Hello guys.

    So, I'm trying to read the id3 tag from a mp3 file but I just don't know why I just can't read the track number info. Could you give me a help?

    Code:
    Dim Gens(125) As String
    
    
    Dim free As Integer
    Private Type TagInfo
        Tag As String * 3
        NomeFaixa As String * 30
        Artista As String * 30
        Album As String * 30
        Ano As String * 4
        Comentario As String * 30
        NFaixa As String * 2
        Genero As String * 1
        
    
    End Type
    
    
    
    Private Function Songinfo(filepath As String)
    Dim CurrentTag As TagInfo
    
    'Get the song info
    Open filepath For Binary As #1
        
        
    With CurrentTag
        Get #1, FileLen(filepath) - 127, .Tag
        Get #1, , .NomeFaixa
        Get #1, , .Artista
        Get #1, , .Album
        Get #1, , .Ano
        Get #1, , .Comentario
        Get #1, , .Genero
        Get #1, , .NFaixa
        
        txtTag.Text = .Tag
        txtSong.Text = RTrim(.NomeFaixa)
        txtArtist.Text = RTrim(.Artista)
        txtAlbum.Text = RTrim(.Album)
        txtAno.Text = RTrim(.Ano)
        txtComentario.Text = RTrim(.Comentario)
        txtGenero.Text = Gens(Asc(RTrim(.Genero)))
        txtNFaixa.Text = RTrim(.NFaixa)
    End With
    
    Close #1
    End Function
    
    Private Sub Command1_Click()
    Songinfo ("D:\New Folder (2)\file.mp3")
    End Sub
    
    
    Private Sub Form_Load()
    Gens(0) = "Blues"
    Gens(1) = "Classic Rock"
    '...
    End Sub
    This link might help you to help me.
    Thank you and
    Merry Christmas to everybody!
    Last edited by RS_Arm; Dec 24th, 2007 at 01:20 PM.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Searching for 2 bytes lost - id3tag v1

    If you count up your CurrentTag data stucture, it = 130 bytes, not 127 bytes. Try Get #1, LOF(#1) - 129 and see if it works.

    Also, and don't know if this matters to you.
    Your UDT has NFaixa then Genero, but you are reading Genero then NFaxia

    Edited: Also if your UDT is in the correct read-order, then you can get the UDT in one call:
    Get #1, LOF(#1) - 129, CurrentTag
    Last edited by LaVolpe; Dec 24th, 2007 at 12:58 PM.

  3. #3
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Searching for 2 bytes lost - id3tag v1

    Also please note there are two versions of ID3v1: version 1.0 and version 1.1 The older version didn't support track number information.

  4. #4

    Thread Starter
    Hyperactive Member RS_Arm's Avatar
    Join Date
    Mar 2007
    Location
    Planet Earth
    Posts
    282

    Re: Searching for 2 bytes lost - id3tag v1.1

    Using V.1.1
    LaVolpe thank you for your tips but using 130 bytes doesn't work because I was wrong saying that the description uses 30bytes-it only uses 28.
    Near perfection version:
    Code:
    Dim Gens(125) As String
    
    Dim free As Integer
    Private Type TagInfo
        Tag As String * 3
        NomeFaixa As String * 30
        Artista As String * 30
        Album As String * 30
        Ano As String * 4
        Comentario As String * 28
        NFaixa As String * 2
        Genero As String * 1
        
    
    End Type
    
    
    
    Private Function Songinfo(filepath As String)
    Dim CurrentTag As TagInfo
    
    'Get the song info
    Open filepath For Binary As #1
        
        
    With CurrentTag
        Get #1, FileLen(filepath) - 127, .Tag
        Get #1, , .NomeFaixa
        Get #1, , .Artista
        Get #1, , .Album
        Get #1, , .Ano
        Get #1, , .Comentario
        Get #1, , .NFaixa
        Get #1, , .Genero
        
        txtTag.Text = .Tag
        txtSong.Text = RTrim(.NomeFaixa)
        txtArtist.Text = RTrim(.Artista)
        txtAlbum.Text = RTrim(.Album)
        txtAno.Text = RTrim(.Ano)
        txtComentario.Text = RTrim(.Comentario)
        txtGenero.Text = Gens(Asc(RTrim(.Genero)))
        txtNFaixa.Text = (Asc(RTrim(.NFaixa)))
    End With
    
    Close #1
    End Function
    
    Private Sub Command1_Click()
    Songinfo ("D:\New Folder (2)\file.mp3")
    End Sub
    
    Private Sub Form_Load()
    Gens(0) = "Blues"
    Gens(1) = "Classic Rock"
    '...
    End Sub

  5. #5
    Hyperactive Member
    Join Date
    Aug 2006
    Location
    TeXaS
    Posts
    497

    Re: Searching for 2 bytes lost - id3tag v1.1

    is the [UDT].tag saying "TAG"?
    and i was looking at another mp3 udt struct and its like this..

    Code:
    Private Type tID3v1             'This type is standard for ID3v1 tags
      Title       As String * 30    '30 bytes Title
      Artist      As String * 30    '30 bytes Artist
      Album       As String * 30    '30 bytes Album
      Year        As String * 4     '4 bytes Year
      Comments    As String * 28    '28 bytes Comments
      IsTrack     As Byte           '1 byte Istrack / +1 byte comments
      Tracknumber As Byte           '1 byte Tracknumber / +1 byte comments
      Genre       As Byte           '1 byte Genre
    End Type
    they check the tag at len-127 before they get the udt to make sure its the right version i guess.

    EDIT: the reason im posting this, is that they have 1 byte for the track number and 1 for the istrack, which you have 2 bytes for a track number.

  6. #6

    Thread Starter
    Hyperactive Member RS_Arm's Avatar
    Join Date
    Mar 2007
    Location
    Planet Earth
    Posts
    282

    Re: Searching for 2 bytes lost - id3tag v1.1

    Billy Conner, thank you so much.
    Using your udt, now I get the track number.

    Quote Originally Posted by Billy Conner
    is the [UDT].tag saying "TAG"?
    and i was looking at another mp3 udt struct and its like this..
    Yes.

    So, my problem is solved now!

    Merry Christmas to everyone

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width