Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 05-10-2005, 12:18 PM   #1
Member (8 bit)
 
04nmr85's Avatar
 
Join Date: Sep 2004
Location: Pennsylvania
Posts: 231
Send a message via AIM to 04nmr85
Question Extracting Id3 Tag Information using VB 6.0

I'm working with visual basic 6.0, as the title says. I'll post the code i have right now and then explain whats going on.


Public Type Id3Tag
Header As String * 3
SongTitle As String * 30
Artist As String * 30
Album As String * 30
Year As String * 4
Comment As String * 30
Genre As Byte
End Type

Public Sub GetInfo(FileName As String, Id3Tag As Id3Tag)
Dim Id3TagTemp As Id3Tag
Dim FileNum As Integer

If FileName = "" Then
MsgBox "Please Select a File"
Exit Sub
End If

FileNum = FreeFile

Open FileName For Binary As FileNum

With Id3TagTemp
Get FileNum, FileLen(FileName) - 127, .Header
Id3Tag.Header = Trim(.Header)
Get FileNum, FileLen(FileName) - 124, .SongTitle
Id3Tag.SongTitle = Trim(.SongTitle)
Get FileNum, FileLen(FileName) - 94, .Artist
Id3Tag.Artist = Trim(.Artist)
Get FileNum, FileLen(FileName) - 64, .Album
Id3Tag.Album = Trim(.Album)
Get FileNum, FileLen(FileName) - 34, .Year
Id3Tag.Year = Trim(.Year)
Get FileNum, FileLen(FileName) - 30, .Comment
Id3Tag.Comment = Trim(.Comment)
Get FileNum, FileLen(FileName) - 1, .Genre
Id3Tag.Genre = Trim(.Genre)
End With

Close FileNum
End Sub

This code is located in a Module. At the top i've declared a type Id3 tag. Then i have a sub procedure that is GetInfo which takes two parameters and that is a path of a file selected in a filelist box located on another form and a variable of type Id3Tag. Now i've found samples of code on the net and thats where most of this came from. I've changed it to what i need however. The problem i'm having now is that i can get the information from some mp3s but not others. Most specifically i can't get the id3 tag info from all the songs i ripped from cd's using iTunes. I downloaded some mp3's from www.purevolume.com and they work perfect. I get all the tag information from those, but not the ones ripped using iTunes. I've purchased a few songs from iTunes itself and I can get the tag information from those. I'm not sure whats wrong. Is there a difference in the way Id3v1 tags are set up vs. Id3v2 tags are set up? How can i tell the version of the Id3 tag that is used by an mp3? What programs are out there already that i could use to rip the music from my cds? I could use Windows Media Player but mine seems to be broken, it says it can't find a connection to the interent even tho i have dsl and it's connected all the time. So any help or ideas would be appreciated. If you need to know more, just ask and i'll try and help as much as possible. Thanks in advance!

EDIT: Spelling

EDIT: I did some looking in iTunes and the id3 tag version that the mp3s extracted with that are v2.2. So now my question is whats the difference in how v1 tags are set up vs. v2 tags are set up?

Last edited by 04nmr85; 05-10-2005 at 12:24 PM.
04nmr85 is offline   Reply With Quote
Old 05-10-2005, 12:35 PM   #2
Professional gadfly
 
doctorgonzo's Avatar
 
Join Date: Jan 2002
Location: Minneapolis, MN
Posts: 6,364
Send a message via MSN to doctorgonzo
What I would do is simply open the MP3 files in a hex editor to figure out the difference between the two ID3 tag formats.

For ripping, I use Exact Audio Copy.
doctorgonzo is offline   Reply With Quote
Old 05-10-2005, 12:45 PM   #3
Member (8 bit)
 
04nmr85's Avatar
 
Join Date: Sep 2004
Location: Pennsylvania
Posts: 231
Send a message via AIM to 04nmr85
Using a hex editor might be a little to advanced for me, i'm not sure tho. I've never done it before. I'm only a novice programmer, in my 3 quarter i believe at ITT Tech. How would I use a Hex editor to figure out the difference? Maybe you could point me to some information if you don't feel like explaining it. I'll go google it in the meanwhile.
04nmr85 is offline   Reply With Quote
Old 05-10-2005, 12:54 PM   #4
Professional gadfly
 
doctorgonzo's Avatar
 
Join Date: Jan 2002
Location: Minneapolis, MN
Posts: 6,364
Send a message via MSN to doctorgonzo
A hex editor just shows the file in binary form. You obviously know enough about the file format to figure out where the ID3 tag information is stored, since that information is in the code (the 127, 124, 94 numbers are byte offsets to the information in the tag, stored at the end of the file).

Just quickly looking at an MP3 file I have, it appears that ID3v2 tags are stored at the beginning of the file, while v1 tags are at the end, so you are going to need completely different code for them.
doctorgonzo is offline   Reply With Quote
Old 05-10-2005, 03:04 PM   #5
Member (8 bit)
 
04nmr85's Avatar
 
Join Date: Sep 2004
Location: Pennsylvania
Posts: 231
Send a message via AIM to 04nmr85
Hmm, it does look like it's stored at the beginning of the file. Thats kind of interesting. I guess all i have to do now is figure out where everything is located. Thanks Doc
04nmr85 is offline   Reply With Quote
Old 05-10-2005, 03:12 PM   #6
Member (8 bit)
 
04nmr85's Avatar
 
Join Date: Sep 2004
Location: Pennsylvania
Posts: 231
Send a message via AIM to 04nmr85
Oh and I found a hex editor on the net that i'm using now to look at the mp3 files. I found it here at this site http://www.softcircuits.com/cygnus/. I'm looking and i see all these numbers and i'm wondering what all of them mean. I believe the right-most column are the byte values, the middle column the hex values and then the right colum ascii values. My understanding of these values is very limited, maybe you could help me understand them a little better?
04nmr85 is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:22 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2