Results 1 to 4 of 4

Thread: Structure and Format of Module

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    Structure and Format of Module

    Ok, I don't need help with figuring out the ID3 stuff anymore, but I'm trying to put everything in a module so it's less messy. The part I'm having trouble with is setting it up to where I can get information like this:

    VB Code:
    1. with id3info
    2. text1.text = RTrim(getid3info.Album)

    It should be easy to find my error just by looking at my code in the module, so I'll just paste it here:
    VB Code:
    1. 'This module is used to read and write to ID3v1.1 tags.
    2.  
    3. Public Type ID3info
    4.     filename As String
    5.     Hastag As Boolean
    6.     Tag As String * 3
    7.     songname As String * 30
    8.     artist As String * 30
    9.     album As String * 30
    10.     year As String * 4
    11.     comment As String * 28
    12.     Null As Byte
    13.     track As Byte
    14.     genre As Byte
    15. End Type
    16.  
    17. Public Matrix
    18.  
    19.  
    20.  
    21.  
    22. Public Function GetID3info()
    23.     Open filename For Binary Access Read As #1
    24.     Get #1, FileLen(filename) - 127, Tag
    25.     If Not Tag = "TAG" Then
    26.     Close #1
    27.     Hastag = False
    28.         Exit Function
    29.         End If
    30.         Hastag = True
    31.     filename = filename
    32.     Get #1, , songname
    33.     Get #1, , artist
    34.     Get #1, , album
    35.     Get #1, , year
    36.     Get #1, , comment
    37.     Get #1, , track
    38.     Get #1, , genre
    39.     Close #1
    40. End Function
    41.  
    42. Public Function WriteID3info()
    43.  
    44.     Open filename For Binary Access Write As #1
    45.         Seek #1, FileLen(filename) - 127
    46.         Put #1, , Tag
    47.         Put #1, , songname
    48.         Put #1, , artist
    49.         Put #1, , album
    50.         Put #1, , year
    51.         Put #1, , comment
    52.         Put #1, , Null
    53.         Put #1, , track
    54.         Put #1, , genre
    55.     Close #1
    56. End Function
    57.    
    58.     With GetID3info
    59.         songname = .songname
    60.         artist = .artist
    61.         album = .album
    62.         year = .year
    63.         comment = .comment
    64.         track = .track
    65.         genre = .genre
    66.     End With
    67.    
    68. Matrix = Array("Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge", _
    69. "Hip -Hop", "Jazz", "Metal", "New Age", "Oldies", "Other", "Pop", "R&b", "Rap", "Reggae", _
    70. "Rock", "Techno", "Industrial", "Alternative", "Ska", "Death Metal", "Pranks", _
    71. "Soundtrack", "Euro -Techno", "Ambient", "Trip -Hop", "Vocal", "Jazz Funk", "Fusion", _
    72. "Trance", "Classical", "Instrumental", "Acid", "House", "Game", "Sound Clip", "Gospel", _
    73. "Noise", "AlternRock", "Bass", "Soul", "Punk", "Space", "Meditative", "Instrumental Pop", _
    74. "Instrumental Rock", "Ethnic", "Gothic", "Darkwave", "Techno -Industrial", "Electronic", _
    75. "Pop -Folk", "Eurodance", "Dream", "Southern Rock", "Comedy", "Cult", "Gangsta", "Top 40", _
    76. "Christian Rap", "Pop/Funk", "Jungle", "Native American", "Cabaret", "New Wave", _
    77. "Psychadelic", "Rave", "Showtunes", "Trailer", "Lo -Fi", "Tribal", "Acid Punk", "Acid Jazz", _
    78. "Polka", "Retro", "Musical", "Rock & Roll", "Hard Rock", "Folk", "Folk/Rock", "National Folk", _
    79. "Swing", "Bebob", "Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde", "Gothic Rock", _
    80. "Progressive Rock", "Psychedelic Rock", "Symphonic Rock", "Slow Rock", "Big Band", "Chorus", _
    81. "Easy Listening", "Acoustic", "Humour", "Speech", "Chanson", "Opera", "Chamber Music", "Sonata", _
    82. "Symphony", "Booty Bass", "Primus", "Porn Groove", "Satire", "Slow Jam", "Club", "Tango", "Samba", "Folklore")

    Any help appreciated.

  2. #2
    Member BinaryAnge's Avatar
    Join Date
    Jun 2002
    Location
    Columbus,Ohio
    Posts
    51

    help is here

    im not sure what your question was. one thing i notice is your udt of the tag. The id3 tag v1.1 layout is


    Public Type Tag
    Tag As String * 3
    SongName As String * 30
    Artist As String * 30
    Album As String * 30
    Year As String * 4
    Comment As String * 30
    Genre As String * 1
    End Type

    also, you dont need to open for binary comparison or use get and puts. try insted to use text streams. something like this

    dim FSO as new Filesystemobject
    dim TS as Textstream
    dim hFile as file
    dim Song as string

    set TS = FSO.opentextfile(MyFile, ForReading)
    set hFile = FSO.Getfile(filepath)

    Song = TS.Read(hFile.Size - 128)
    If TS.Read(3) = "TAG" Then
    With ID3Tag
    .Tag = "TAG"
    .SongName = TS.Read(30)
    .Artist = TS.Read(30)
    .Album = TS.Read(30)
    .Year = TS.Read(4)
    .Comment = TS.Read(30)
    .Genre = TS.Read(1)
    End With

    you can also do the eqivilent with the ts.write to write the changes to the tag.

    something you MUST consider. every id3tag editor ive ever crossed is always done wrong. if you change the id3 tag, you should overwrite the old one. no one ever does, and so when they change it. their song file (mp3. wav) gets 128 bytes bigger with the extra junk burried inside. this is garbage code and dumbass programming. DO NOT USE APPEND. insted rewrite the whole songfile - 128, then add the new tag, thus overwriting the old id3tag with the new.

    if you have a hex editor such as ultra edit, use it to open a few of your mp3s. go to the very end. you'll see the info for the id3 tag. remember, id3 tag readers only check the last 128 bytes, so old tags can be hidden behind the one being read. you'll probably see alot where there are multiple tags at the end of the file, but only the last one is used.
    The Programmers Credo -
    Protect dumb-ass from himself.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    About the Garbage code......

    By looking at the code I posted, There is nothing added right? because it seeks to the last 128 bytes before adding any information, thus, overwriting any previous tag.

  4. #4
    Member BinaryAnge's Avatar
    Join Date
    Jun 2002
    Location
    Columbus,Ohio
    Posts
    51

    yes

    actually yours does look right, overwriting the old tag.
    The Programmers Credo -
    Protect dumb-ass from himself.

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