|
-
Jun 24th, 2002, 08:08 PM
#1
Thread Starter
Fanatic Member
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:
with id3info
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:
'This module is used to read and write to ID3v1.1 tags.
Public Type ID3info
filename As String
Hastag As Boolean
Tag As String * 3
songname As String * 30
artist As String * 30
album As String * 30
year As String * 4
comment As String * 28
Null As Byte
track As Byte
genre As Byte
End Type
Public Matrix
Public Function GetID3info()
Open filename For Binary Access Read As #1
Get #1, FileLen(filename) - 127, Tag
If Not Tag = "TAG" Then
Close #1
Hastag = False
Exit Function
End If
Hastag = True
filename = filename
Get #1, , songname
Get #1, , artist
Get #1, , album
Get #1, , year
Get #1, , comment
Get #1, , track
Get #1, , genre
Close #1
End Function
Public Function WriteID3info()
Open filename For Binary Access Write As #1
Seek #1, FileLen(filename) - 127
Put #1, , Tag
Put #1, , songname
Put #1, , artist
Put #1, , album
Put #1, , year
Put #1, , comment
Put #1, , Null
Put #1, , track
Put #1, , genre
Close #1
End Function
With GetID3info
songname = .songname
artist = .artist
album = .album
year = .year
comment = .comment
track = .track
genre = .genre
End With
Matrix = Array("Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge", _
"Hip -Hop", "Jazz", "Metal", "New Age", "Oldies", "Other", "Pop", "R&b", "Rap", "Reggae", _
"Rock", "Techno", "Industrial", "Alternative", "Ska", "Death Metal", "Pranks", _
"Soundtrack", "Euro -Techno", "Ambient", "Trip -Hop", "Vocal", "Jazz Funk", "Fusion", _
"Trance", "Classical", "Instrumental", "Acid", "House", "Game", "Sound Clip", "Gospel", _
"Noise", "AlternRock", "Bass", "Soul", "Punk", "Space", "Meditative", "Instrumental Pop", _
"Instrumental Rock", "Ethnic", "Gothic", "Darkwave", "Techno -Industrial", "Electronic", _
"Pop -Folk", "Eurodance", "Dream", "Southern Rock", "Comedy", "Cult", "Gangsta", "Top 40", _
"Christian Rap", "Pop/Funk", "Jungle", "Native American", "Cabaret", "New Wave", _
"Psychadelic", "Rave", "Showtunes", "Trailer", "Lo -Fi", "Tribal", "Acid Punk", "Acid Jazz", _
"Polka", "Retro", "Musical", "Rock & Roll", "Hard Rock", "Folk", "Folk/Rock", "National Folk", _
"Swing", "Bebob", "Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde", "Gothic Rock", _
"Progressive Rock", "Psychedelic Rock", "Symphonic Rock", "Slow Rock", "Big Band", "Chorus", _
"Easy Listening", "Acoustic", "Humour", "Speech", "Chanson", "Opera", "Chamber Music", "Sonata", _
"Symphony", "Booty Bass", "Primus", "Porn Groove", "Satire", "Slow Jam", "Club", "Tango", "Samba", "Folklore")
Any help appreciated.
-
Jun 24th, 2002, 08:37 PM
#2
Member
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.
-
Jun 24th, 2002, 09:07 PM
#3
Thread Starter
Fanatic Member
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.
-
Jun 24th, 2002, 09:48 PM
#4
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|