Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Read/write MP3 tags
#1
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.

.zip   id3com.zip (Size: 86.52 KB / Downloads: 2,700) The newest version is available at sourceforge, but only as source files.

_____________________________________________

Examples:

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

Code:
Copy      Help
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.

Code:
Copy      Help
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
#2
Thanks for the tip! This library let me automate what would otherwise have been an unbelievably laborious task.
9: ) Lindsey Dubb
#3
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
#4
_create etc are added by QM. Documented in QM help.

Quote: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.
#5
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!
#6
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.
#7
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!
#8
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)
#9
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....
#10
displays most of tags of 10 songs from your music folder.
Macro
Code:
Copy      Help
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
#11
Thanks...That pretty much gets everything...still a few things missing, but better! Now, just to get it for one file Smile
#12
Hmm...that works very odd. It definitely grabs information...it just is odd when testing outcome on multiple files.

Nifty.
#13
The first version of the code did not work well with multiple files.
#14
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.
#15
Thank you, I added the dll in the first topic.
#16
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
#17
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.
#18
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
Code:
Copy      Help
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
#19
Does it show in which line is the error?
#20
f=t.FrameByNum(i)
#21
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
Code:
Copy      Help
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
#22
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.
#23
It's not the best code but it works for me.

Macro MP3 Tags
Code:
Copy      Help
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
Code:
Copy      Help
;/
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


Forum Jump:


Users browsing this thread: 1 Guest(s)