MP3 ID3 API Calls for excel

  • Thread starter Thread starter Chad Cameron
  • Start date Start date
C

Chad Cameron

I am trying to setup a sheet that has filenames, ID3 info fr all my MP3's.
Does anyone know of a site that can provide API info for ID3 tags? or a way
to get the info into excel?

Thanks
Chad
 
I don't know a lot about MP3 tags except that they occupy the last 128 bytes
of an mp3.

I did some Google searching and found the offsets. It seems to work.

Type MP3Tag
ID As String * 3
Title As String * 30
Artist As String * 30
Album As String * 30
Year As String * 4
Comment As String * 28
ID3Tag As Byte
TrackNumber As Byte
End Type

Sub test()
Const cRecordLen = 128
Dim strFile As String, lngFileLen As Long
Dim tag As MP3Tag, intFF As Integer

strFile = "C:\MP3\Prodigy - Always Outnumbered Never Outgunned\06 -
Prodigy - Wake Up Call.mp3"
lngFileLen = FileLen(strFile)

intFF = FreeFile
Open strFile For Binary Access Read As intFF

Get intFF, lngFileLen - cRecordLen + 1, tag

If tag.ID = "TAG" Then
Debug.Print tag.Album; Tab; tag.TrackNumber; Tab; tag.Title
End If

Close intFF
End Sub
 
Perfect, that is exactly what I need.

Now the next step is once I have all the info listed in columns, how do I
update the file if I change some of the data? Well, I know how to change
it, what is the command to save the .mp3?

TIA,
Greatly appreciated
Chad
 
Hi

I have a freeware mp3 tagwriter OCX that I found that was written for vb5,
but it works great in VBA. Just drop it on a worksheet oer a user .
If you email me, I will send it and a working example workbook to you.

HTH

Ken
 
I looked at the link. I used a chunk of the code, but the mp3 file doesn't
update the id3 info. When I step through it appears to work, but when I
open the mp3 the id3 info is the same.
Here is the code:

Sub xWrite()
strFile = Cells(2, 1) 'Filename of mp3
lngFileLen = FileLen(strFile)
intFF = FreeFile
Open strFile For Binary Access Write As intFF
tag.Title = ActiveCell.Offset(0, 3)
tag.Artist = ActiveCell.Offset(0, 4)
tag.Album = ActiveCell.Offset(0, 5)
tag.Year = ActiveCell.Offset(0, 6)
tag.Comment = ActiveCell.Offset(0, 7)
tag.TrackNumber = ActiveCell.Offset(0, 8)
Put intFF, lngFileLen - cRecordLen + 1, tag
Debug.Print tag.Title; 'check if the info is updated
Close intFF
End Sub
 
I am wrong, it is not updating the file, it is deleting all the id3 info.
I will have to look deeper into my code.
 
Maybe my arithmetic is off, but for 3 + 90 + 4 + 28 + 2, I get 127 rather than
128. Maybe that is the problem -- off by 1 byte.
 
You seem to have left out some critical parts of the code example you were
given.

I don't see where you are (1) defining the structure of the user-defined type
variable, (2) dimensioning the variable tag as that UDT, or (3) setting a
value for cRecordLen. But also see my other post re the length of the tab
record.
 
Thanks for the reply, All the variable definisions are global and not
shown. I got 127 too, but I assumed that if you start at 1 and go to 128
there are only 127 numbers in between, but that could be a problem.
 
Hi Myrna.

I discovered the 127 too, which is why I start reading 127 from the end of
the file - even though I said it was 128 from the end of the file.
- cRecordLen + 1

I've never read the API for mpeg so I'm not 100% sure of the structure. I
assumed the OP was after a quick'n'dirty dump util.

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top