Read/write MP3 tags

Functions, classes, components, etc. Only high quality content.

Read/write MP3 tags

Postby Gintaras on Sat Jan 28, 2006 7:19 pm

id3lib

This free library allows you to read and write MP3 tags (Artist, Title, Album, etc) using QM. Supports ID3v1 and ID3v2. Very easy to use. Download id3com.dll and place in qm folder.

Home page:
http://id3lib.sourceforge.net/

ActiveX dll, version 3.05a.
id3com.zip
id3com.dll
(86.52 KiB) Downloaded 2049 times
The newest version is available at sourceforge, but only as source files.

_____________________________________________

Examples:

This macro shows Artist and Title tags of a mp3 file.

str s="C:\MP3 temp\Soma Sonic - Road to Nowhere.mp3"
typelib Id3Lib "id3com.dll"
Id3Lib.ID3ComTag t._create
BSTR b=s
t.Link(&b)
out t.Artist
out t.Title



This macro gets artist and title from a mp3 file name and sets Artist and Title tags of that mp3 file.

str s="C:\MP3 temp\Soma Sonic - Road to Nowhere.mp3"
str fn.getfilename(s)
str sa st
tok fn &sa 2 "-"
sa.trim; st.trim

;out sa
;out st


typelib Id3Lib "id3com.dll"
Id3Lib.ID3ComTag t._create
BSTR b=s
t.Link(&b)
t.Artist=sa
t.Title=st
t.SaveV1Tag
t.SaveV2Tag

Gintaras
Site Admin
 
Posts: 10232
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Postby Lindsey on Wed Oct 18, 2006 7:07 am

Thanks for the tip! This library let me automate what would otherwise have been an unbelievably laborious task.
9: ) Lindsey Dubb
Lindsey
 
Posts: 19
Joined: Sat Mar 08, 2003 12:14 pm

Re: Read/write MP3 tags

Postby TheVig on Tue Sep 02, 2008 10:02 pm

This is great!

How do you get all of the ID3 Info though?

i.e. The Pictures, Lyrics, Composer, etc...

There are quite a few more that are not in the list.

Thanks
Jimmy Vig

Also...How do the other tidbits work in this...
t._create
t._getactive
t._getcontrol
t._getfile
t._setevents


How do you use a dll...I mean how do you know what is in it and how to initialize it...I always feel like you are pulling a rabbit out of a hat when it comes to these things. Thanks
TheVig
Active Member
 
Posts: 979
Joined: Thu Feb 14, 2008 9:22 am

Re: Read/write MP3 tags

Postby Gintaras on Wed Sep 03, 2008 6:44 am

_create etc are added by QM. Documented in QM help.

How do you use a dll...I mean how do you know what is in it and how to initialize it...


I look what is in its type library:
1. Insert type library declaration using the Type Libraries dialog:

typelib XXX ...

2. Then compile the macro.
3. Then type XXX. and look what classes are there.
4. Pick a class, declare variable and look what's in the class.

XXX.Class var.

5 a. If it's not an ActiveX control that must be in a dialog, I use _create to initialize the variable:

XXX.Class var._create
var. ...

5 b. If it's an ActiveX control, I instead add the control to a dialog in the Dialog Editor.

Read more in QM help, 'Using COM components' topic.
Gintaras
Site Admin
 
Posts: 10232
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Read/write MP3 tags

Postby TheVig on Wed Sep 03, 2008 6:52 am

Holy cow...there are tons of things that pop up when I type "Id3Lib."

I'm still not sure how to use it all...I'm still making heads and tails of classes...

This really helps so far.

If you have the time...could you give example how to make "Id3Lib.ID3_CONDUCTOR" into something I could grab data from an MP3 file...that would really help me seal the deal here.

Thanks so Much!
TheVig
Active Member
 
Posts: 979
Joined: Thu Feb 14, 2008 9:22 am

Re: Read/write MP3 tags

Postby Gintaras on Wed Sep 03, 2008 6:57 am

ID3_CONDUCTOR and similar constants should be used with some function but I don't know what function it is. Need to read documentation of this component.
Gintaras
Site Admin
 
Posts: 10232
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Read/write MP3 tags

Postby TheVig on Wed Sep 03, 2008 7:02 am

Well how did you get the t.xxx to work in the example?

I'm in way over my head...I know.

I just want to understand the magic.

It'll really help me with dll's in the future.

My only programing experience is with QM...and by only...I mean I stumbled across this program looking for something that could spit out a series of Key commands to automate dating in NexGen...now I am writing full blown programs. It really is pretty rad!
TheVig
Active Member
 
Posts: 979
Joined: Thu Feb 14, 2008 9:22 am

Re: Read/write MP3 tags

Postby Gintaras on Wed Sep 03, 2008 7:12 am

Type t.xxx and look in status bar. (if xxx is a function).

For example, for Artist it is "BSTR Artist() . Property". This function does not have arguments. BSTR is the type of the value that the function returns. The property is not readonly so I can get and set the property.

str s
s=t.Artist ;;get
out s
t.Artist="an artist" ;;set


Another example. "Link(BSTR&FileName)". The function does not return a value but has 1 argument. It must be a BSTR variable.
BSTR b
b="bbbbbb"
t.Link(b)
Gintaras
Site Admin
 
Posts: 10232
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Read/write MP3 tags

Postby TheVig on Wed Sep 03, 2008 7:21 am

I'm starting to see...I played around while I've been asking questions...

You started by with "Id3Lib."
gives 3 different options other that the ID3_ stuff that you say needs a funciton.

Then you select "ID3ComTag"

ending up with "Id3Lib.ID3ComTag"

then you type 'var'._create to create the class

From there whenever you type "'var'." you get the options for the dll...

Now...Were would I look to find those functions....I have some funky MP3's written by NexGen that I need to grab whacky id3 tag info....it's not in the artist or album...or any other spot...somehow Windows media play grabs the right stuff...strange? I figure being able to just grab it all would be neat anyways...

I've looked through the documentation a bit, but there's quite a lot and I'm not even sure what I am looking for....Geeze...it's rough.

Thanks again...this really helped me understand quite a bit so far.

You know what they say...give a man a fish he eats for a day, teach a man to fish he eats for life....
TheVig
Active Member
 
Posts: 979
Joined: Thu Feb 14, 2008 9:22 am

Re: Read/write MP3 tags

Postby Gintaras on Wed Sep 03, 2008 7:58 am

displays most of tags of 10 songs from your music folder.
Macro     ?
out
typelib Id3Lib "id3com.dll"

Dir d; int n
foreach(d "Q:\MP3\*.mp3" FE_Dir 0x4)
,n+1; if(n>10) break
,str sPath=d.FileName(1)
,out "--- %s ---" sPath
,Id3Lib.ID3ComTag t._create
,BSTR b=sPath
,t.Link(b)
,;out t.NumFrames
,Id3Lib.ID3ComFrame f
,;foreach f t ;;does not work. why?
,,;out f.FrameName
,int i j
,for i 0 t.NumFrames
,,f=t.FrameByNum(i)
,,out f.FrameName
,,Id3Lib.ID3ComField fi=f.Field(Id3Lib.ID3_FIELD_TEXT)
,,;Id3Lib.ID3ComField fi=f.Field(Id3Lib.ID3_FIELD_DESCRIPTION)
,,if(fi)
,,,str s
,,,for j 1 fi.NumTextItems+1
,,,,s=fi.Text(j)
,,,,s-"[9]"
,,,,out s

Gintaras
Site Admin
 
Posts: 10232
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Read/write MP3 tags

Postby TheVig on Wed Sep 03, 2008 8:13 am

Thanks...That pretty much gets everything...still a few things missing, but better! Now, just to get it for one file :)
TheVig
Active Member
 
Posts: 979
Joined: Thu Feb 14, 2008 9:22 am

Re: Read/write MP3 tags

Postby TheVig on Wed Sep 03, 2008 9:30 am

Hmm...that works very odd. It definitely grabs information...it just is odd when testing outcome on multiple files.

Nifty.
TheVig
Active Member
 
Posts: 979
Joined: Thu Feb 14, 2008 9:22 am

Re: Read/write MP3 tags

Postby Gintaras on Wed Sep 03, 2008 9:38 am

The first version of the code did not work well with multiple files.
Gintaras
Site Admin
 
Posts: 10232
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Read/write MP3 tags

Postby ldarrambide on Fri Jan 01, 2010 12:25 am

Hi all and happy new year.

i just revive that topic because i'd like to play with mp3 files, but i can't find an id3com.dll file which does register
on my windows 7 box.

If someone has a link.

Thanks and nice 2010 to all.

Laurent.
ldarrambide
Active Member
 
Posts: 770
Joined: Wed Feb 25, 2009 1:10 am

Re: Read/write MP3 tags

Postby Gintaras on Fri Jan 01, 2010 9:38 am

Thank you, I added the dll in the first topic.
Gintaras
Site Admin
 
Posts: 10232
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Read/write MP3 tags

Postby ldarrambide on Fri Jan 01, 2010 8:23 pm

Useful and fast response as usual.
Any chance to have a binary compiled for Windows seven 32 bits of the latest one (0.8.3 i beleive)? Can't do it by myself.

Would be great.

Thanks Gintaras
ldarrambide
Active Member
 
Posts: 770
Joined: Wed Feb 25, 2009 1:10 am

Re: Read/write MP3 tags

Postby Uc9cer7exuS4s7 on Mon Oct 15, 2012 12:48 am

Hi all, reviving this old topic to ask:
Has anyone used this to change (or add) lyric tags? (unsyncronised). Or any other of the "advanced" tags. What's the exact command?

This seems pretty basic yet I've lost 2 nights and I'm still where I started!
Thanks in advance for any help.
Uc9cer7exuS4s7
 
Posts: 13
Joined: Sat Sep 27, 2008 1:55 pm

Re: Read/write MP3 tags

Postby AlexZ on Tue Jan 21, 2014 5:14 am

Hi Gintaras and all QM fellows. Happy year for everybody!

I have several mp3 files with spam in almost all the tag fields, something like BuySnakeOil.com.

I would like to remove all these strings. I used your last example, the macro removes the strings of few files but suddenly shows:

Error (RT) in MP3 Tags: Exception 0xC0000005. Access violation. Cannot write memory at 0x4. In id3com.dll at 0x35350C6 (0x3520000+0x150C6). ?
Exception in destructors of local variables of MP3 Tags.

Any help, please!

Macro MP3 Tags     ?
str spam1=" - www.SPAM.com"
str spam2="www.moreSPAM.com"

str spam.from(spam1 "|" spam2)

out
typelib Id3Lib "id3com.dll"

Dir d
foreach(d "$desktop$\MP3\*.mp3" FE_Dir 0x4)
,str sPath=d.FileName(1)
,str s=sPath
,if sPath.replacerx(spam)
,,ren s sPath
,out "--- %s ---" sPath
,Id3Lib.ID3ComTag t._create
,BSTR b=sPath
,t.Link(&b)
,;out t.NumFrames
,Id3Lib.ID3ComFrame f
,int i j
,for i 0 t.NumFrames
,,f=t.FrameByNum(i)
,,out f.FrameName
,,Id3Lib.ID3ComField fi=f.Field(Id3Lib.ID3_FIELD_TEXT)
,,;Id3Lib.ID3ComField fi=f.Field(Id3Lib.ID3_FIELD_DESCRIPTION)
,,if(fi)
,,,for j 1 fi.NumTextItems+1
,,,,s=fi.Text(j)
,,,,if s.replacerx(spam)
,,,,,BSTR bs=s
,,,,,fi.Text(j)=bs
,,,,s-"[9]"
,,,,out s
,t.SaveV1Tag
,t.SaveV2Tag

AlexZ
 
Posts: 130
Joined: Wed Aug 05, 2009 2:39 am

Re: Read/write MP3 tags

Postby Gintaras on Tue Jan 21, 2014 6:04 am

Does it show in which line is the error?
Gintaras
Site Admin
 
Posts: 10232
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Read/write MP3 tags

Postby AlexZ on Tue Jan 21, 2014 6:05 am

f=t.FrameByNum(i)
AlexZ
 
Posts: 130
Joined: Wed Aug 05, 2009 2:39 am

Re: Read/write MP3 tags

Postby Gintaras on Tue Jan 21, 2014 6:47 am

Either a bug in the component, or don't need to call SaveV2Tag for each file.
VBScript also fails after eg 10 files.
Macro Macro1867     ?
Dir d
foreach(d "$desktop$\MP3\*.mp3" FE_Dir 0x4)
,str sPath=d.FileName(1)
,str s=sPath
,out "--- %s ---" sPath
,str vbs=
,F
,;dim t
,;set t=CreateObject("Id3COM.ID3ComTag")
,;t.Link("{sPath}")
,;t.SaveV1Tag
,;t.SaveV2Tag
,VbsExec vbs

Gintaras
Site Admin
 
Posts: 10232
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Read/write MP3 tags

Postby AlexZ on Sat Jan 25, 2014 6:22 am

Any other option like Taglib or cddbcontrol.dll?

There are several implementations for the MP3 Tag Standard, but I am not sure wich one fits better with our targets.
http://id3.org/Implementations

Thanks.
AlexZ
 
Posts: 130
Joined: Wed Aug 05, 2009 2:39 am

Re: Read/write MP3 tags

Postby AlexZ on Sun Jan 26, 2014 5:03 am

It's not the best code but it works for me.

Macro MP3 Tags     ?
str spam1=" - www.SPAM.com"
str spam2="www.moreSPAM.com"

str sSpam.from(spam1 "|" spam2)

out
;typelib Id3Lib "id3com.dll"

Dir d
foreach(d "$desktop$\MP3\*.mp3" FE_Dir 0x4)
,str sPath=d.FileName(1)
,Rename_MP3Tag sPath sSpam



Function Rename_MP3Tag     ?
;/
function str'sPath str'sSpam

str s=sPath
if sPath.replacerx(sSpam)
,ren s sPath
out "--- %s ---" sPath

typelib Id3Lib "id3com.dll"

Id3Lib.ID3ComTag t._create
BSTR b=sPath
t.Link(&b)
;out t.NumFrames
Id3Lib.ID3ComFrame f
int i j
for i 0 t.NumFrames
,f=t.FrameByNum(i)
,;out f.FrameName
,Id3Lib.ID3ComField fi=f.Field(Id3Lib.ID3_FIELD_TEXT)
,;Id3Lib.ID3ComField fi=f.Field(Id3Lib.ID3_FIELD_DESCRIPTION)
,if(fi)
,,for j 1 fi.NumTextItems+1
,,,s=fi.Text(j)
,,,if s.replacerx(sSpam)
,,,,BSTR bs=s
,,,,fi.Text(j)=bs
,,,;s-"[9]"
,,,;out s
t.SaveV1Tag
t.SaveV2Tag

AlexZ
 
Posts: 130
Joined: Wed Aug 05, 2009 2:39 am


Return to QM Extensions

Who is online

Users browsing this forum: No registered users and 1 guest

cron