TagLib

Share your advanced PureBasic knowledge/code with the community.
lexvictory
Addict
Addict
Posts: 1027
Joined: Sun May 15, 2005 5:15 am
Location: Australia
Contact:

Re: TagLib

Post by lexvictory »

I managed to get 1.6 compiled for x86 and x64
http://demonioardente.us.to/pb/taglib1.6_msvc_bin.zip

you'll probably need to change the import lines. this compilation has tag_c lib files (as pb uses the C binding).
Demonio Ardente

Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Re:

Post by ricardo »

Rings wrote:i would also use that stuff under windows, but
some polink errors occurs.
maybe i did only use wrong names.
I just download the binarys from the website and did:

Code: Select all

CompilerSelect #PB_Compiler_OS
 CompilerCase #PB_Compiler_OS = #PB_OS_Linux
  ImportC "/usr/lib/libtag_c.so"
 CompilerCase #PB_OS_Windows
  ImportC #PB_Compiler_Home + "\PureLibraries\Windows\Libraries\tag_c.lib"
  ImportC #PB_Compiler_Home + "\PureLibraries\Windows\Libraries\tag.lib"
 CompilerEndSelect
any help would be fine Inner, to make this piece of code
cross-compatible ;)

Where can we get the needed .lib files?

Founded at: https://github.com/alho/PB-MP3-Dupe-Finder/downloads

One question how to get APE tags?
ARGENTINA WORLD CHAMPION
lexvictory
Addict
Addict
Posts: 1027
Joined: Sun May 15, 2005 5:15 am
Location: Australia
Contact:

Re: TagLib

Post by lexvictory »

http://thiakil.com/public/pb/taglib1.6_msvc_bin.zip

thats the zip i posted for TagLib 1.6
Demonio Ardente

Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Re: TagLib

Post by ricardo »

How to get id3v2 apic?
ARGENTINA WORLD CHAMPION
erion
Enthusiast
Enthusiast
Posts: 128
Joined: Sun Jan 24, 2010 11:12 pm

Re: TagLib

Post by erion »

Hi all,

I needed this for a project, so I have compiled v1.8 (x86 only), and have updated Inner's wrapper for the C bindings. Sadly it's MSVC 10, so it depends on a few dlls, but it works nicely.

I have also included Inner's ported reader example.

http://erion.tdrealms.com/taglib

Cheers,
Erion
To see a world in a grain of sand,
And a heaven in a wild flower,
Hold infinity in the palm of your hand,
And eternity in an hour.

- W. B.

Visit my site, also for PureBasic goodies http://erion.tdrealms.com
Sebert
New User
New User
Posts: 8
Joined: Wed Mar 26, 2014 2:50 pm

Re: TagLib

Post by Sebert »

Hi there,

first of all I am a newbie to Purebasic, so forgive me If I've made a rookie mistake here.

I tried the example_reader code with a mp3 file:

Code: Select all

XIncludeFile "tag_c.pbi"

file=taglib_file_new("Sarajevo 2014.mp3")
If file
 Debug "Open"
 tag = taglib_file_tag(file);
  properties = taglib_file_audioproperties(file)
OpenConsole()
 PrintN("-- TAG --");
 PrintN("title - \"+PeekS(taglib_tag_title(tag)))
 PrintN("artist - \"+PeekS(taglib_tag_artist(tag)))
 PrintN("album - \"+PeekS(taglib_tag_album(tag))) 
 PrintN("year  - \"+Str(taglib_tag_year(tag)))
 PrintN("comment - \"+PeekS(taglib_tag_comment(tag)))
 PrintN("track - \"+Str(taglib_tag_track(tag)));
 PrintN("genre - \"+PeekS(taglib_tag_genre(tag)));

 seconds = taglib_audioproperties_length(properties) % 60
 minutes = (taglib_audioproperties_length(properties) - seconds) / 60

 PrintN("-- AUDIO --");
 PrintN("bitrate  - "+Str(taglib_audioproperties_bitrate(properties)))
 PrintN("sample rate - "+Str(taglib_audioproperties_samplerate(properties)))
 PrintN("channels  - "+Str(taglib_audioproperties_channels(properties)))
 PrintN("length   - "+Str(minutes)+":"+Str(seconds));

 taglib_tag_free_strings()

 taglib_file_free(file)
Else
PrintN("Unable to open file.")
EndIf
Input()
CloseConsole()
a) I got the console output. It showed the correct values/tags.
b) No Debug Messages ?

Then I tried your example for writing with the very same file.
I used Erions updated version of your wrapper:
http://erion.tdrealms.com/taglib

Code: Select all

XIncludeFile "tag_c.pbi"

Debug "Start"

file=taglib_file_new("Sarajevo 2014.mp3")
If file
  Debug "Open"
  tag = taglib_file_tag(file);
 
  Debug taglib_tag_set_artist(tag,"muhahahaha")
  Debug taglib_tag_set_title(tag,"muhahahaha")
  taglib_file_save(file)

  taglib_tag_free_strings()
  taglib_file_free(file)
EndIf 
Nothing. I tried it with and without the Debug command in front of the taglib_tag_set.
No debug messages, no changed tags.

What am I missing here?
I know it is a bold attempt for a newbie, but I am really interested what I am doing wrong.

Best Regards

Sebert
erion
Enthusiast
Enthusiast
Posts: 128
Joined: Sun Jan 24, 2010 11:12 pm

Re: TagLib

Post by erion »

Hello,

I have just updated TagLib to v1.9.1.

Setting tags seem to work, I tested with an mp3 file. Perhaps that was a bug in 1.8...
Please redownload and see if this fixes anything.

Erion
To see a world in a grain of sand,
And a heaven in a wild flower,
Hold infinity in the palm of your hand,
And eternity in an hour.

- W. B.

Visit my site, also for PureBasic goodies http://erion.tdrealms.com
Sebert
New User
New User
Posts: 8
Joined: Wed Mar 26, 2014 2:50 pm

Re: TagLib

Post by Sebert »

Hi,

thank you for the update.

Unfortunately writing tags still doesn't work for me :-(
erion
Enthusiast
Enthusiast
Posts: 128
Joined: Sun Jan 24, 2010 11:12 pm

Re: TagLib

Post by erion »

Hello,
I have tested the latest Taglib v1.9.1, specifically with ogg files, and I got positive results in all cases.
Here's the code I used:

Code: Select all

XIncludeFile "tag_c.pbi"

file=taglib_file_new("test.ogg")
If file
 Debug "Open"
 tag = taglib_file_tag(file);
  properties = taglib_file_audioproperties(file)
OpenConsole()
 PrintN("-- TAG --");
 taglib_tag_set_title(tag, "This is a test")
 PrintN("title - \"+PeekS(taglib_tag_title(tag)))
 PrintN("artist - \"+PeekS(taglib_tag_artist(tag)))
 PrintN("album - \"+PeekS(taglib_tag_album(tag))) 
 PrintN("year  - \"+Str(taglib_tag_year(tag)))
 PrintN("comment - \"+PeekS(taglib_tag_comment(tag)))
 PrintN("track - \"+Str(taglib_tag_track(tag)));
 PrintN("genre - \"+PeekS(taglib_tag_genre(tag)));
taglib_file_save(file)
 seconds = taglib_audioproperties_length(properties) % 60
 minutes = (taglib_audioproperties_length(properties) - seconds) / 60

 PrintN("-- AUDIO --");
 PrintN("bitrate  - "+Str(taglib_audioproperties_bitrate(properties)))
 PrintN("sample rate - "+Str(taglib_audioproperties_samplerate(properties)))
 PrintN("channels  - "+Str(taglib_audioproperties_channels(properties)))
 PrintN("length   - "+Str(minutes)+":"+Str(seconds));
   taglib_tag_free_strings()

 taglib_file_free(file)
Else
PrintN("Unable to open file.")
EndIf
Input()
CloseConsole()
I was using the latest PB 5.22 x86 (32 bit) version, with unicode mode disabled.

If it still doesn't work, here are a few things to try:
1. taglib_file_save() returns a boolean, i.e. 1 on success, 0 on failure. Put Debug or a MessageRequester around it, and see what it returns for you. Remember to enable the debugger in the debug menu of PB's ide if you are using Debug
2. If you get a 0, and you run Windows Vista or above, UAC can block access to the file, depending on where test.ogg is located. For example, UAC will not allow you to write to the root of your C drive, the Program Files directory, etc. Make sure you have write permission.
3. If you are monitoring the changed tags via a media player (Winamp/Foobar 2000, etc), they could lock the file if it is open or under playback. Make sure nothing has opened the file when you are saving the tags via TagLib.
If it still fails, the cause could be a damaged file. Try a different file, see if it writes the tags properly.

These are all the things I could think of for now.

Hth,
Erion
To see a world in a grain of sand,
And a heaven in a wild flower,
Hold infinity in the palm of your hand,
And eternity in an hour.

- W. B.

Visit my site, also for PureBasic goodies http://erion.tdrealms.com
Sebert
New User
New User
Posts: 8
Joined: Wed Mar 26, 2014 2:50 pm

Re: TagLib

Post by Sebert »

Hi Erion,

thank you very much for your help.
Reading tags works just fine, so I'll give your suggestions 1 & 2 a try in the next few days and get back to you!

Edit: As long as I include "tag_c.pbi", I don't get any debug messages. I tried

Code: Select all

XIncludeFile "tag_c.pbi"
Debug "DebugTest"
and the Debugger stays "silent".....

Regards

Sebastian
Poshu
Enthusiast
Enthusiast
Posts: 459
Joined: Tue Jan 25, 2005 7:01 pm
Location: Canada

Re: TagLib

Post by Poshu »

Could anyone build an osx and a linux version? That could be a great addon to purebasic if it was multi platform.
Sebert
New User
New User
Posts: 8
Joined: Wed Mar 26, 2014 2:50 pm

Re: TagLib

Post by Sebert »

erion wrote:Hello,
I have tested the latest Taglib v1.9.1, specifically with ogg files, and I got positive results in all cases.
Here's the code I used:

Code: Select all

XIncludeFile "tag_c.pbi"

file=taglib_file_new("test.ogg")
If file
 Debug "Open"
 tag = taglib_file_tag(file);
  properties = taglib_file_audioproperties(file)
OpenConsole()
 PrintN("-- TAG --");
 taglib_tag_set_title(tag, "This is a test")
 PrintN("title - \"+PeekS(taglib_tag_title(tag)))
 PrintN("artist - \"+PeekS(taglib_tag_artist(tag)))
 PrintN("album - \"+PeekS(taglib_tag_album(tag))) 
 PrintN("year  - \"+Str(taglib_tag_year(tag)))
 PrintN("comment - \"+PeekS(taglib_tag_comment(tag)))
 PrintN("track - \"+Str(taglib_tag_track(tag)));
 PrintN("genre - \"+PeekS(taglib_tag_genre(tag)));
taglib_file_save(file)
 seconds = taglib_audioproperties_length(properties) % 60
 minutes = (taglib_audioproperties_length(properties) - seconds) / 60

 PrintN("-- AUDIO --");
 PrintN("bitrate  - "+Str(taglib_audioproperties_bitrate(properties)))
 PrintN("sample rate - "+Str(taglib_audioproperties_samplerate(properties)))
 PrintN("channels  - "+Str(taglib_audioproperties_channels(properties)))
 PrintN("length   - "+Str(minutes)+":"+Str(seconds));
   taglib_tag_free_strings()

 taglib_file_free(file)
Else
PrintN("Unable to open file.")
EndIf
Input()
CloseConsole()
I was using the latest PB 5.22 x86 (32 bit) version, with unicode mode disabled.

If it still doesn't work, here are a few things to try:
1. taglib_file_save() returns a boolean, i.e. 1 on success, 0 on failure. Put Debug or a MessageRequester around it, and see what it returns for you. Remember to enable the debugger in the debug menu of PB's ide if you are using Debug
2. If you get a 0, and you run Windows Vista or above, UAC can block access to the file, depending on where test.ogg is located. For example, UAC will not allow you to write to the root of your C drive, the Program Files directory, etc. Make sure you have write permission.
3. If you are monitoring the changed tags via a media player (Winamp/Foobar 2000, etc), they could lock the file if it is open or under playback. Make sure nothing has opened the file when you are saving the tags via TagLib.
If it still fails, the cause could be a damaged file. Try a different file, see if it writes the tags properly.

These are all the things I could think of for now.

Hth,
Erion
1.taglib_tag_set_artist(tag,"muhahahaha") returns 2
taglib_file_save(file) returns 1
2. UAC is deactivated
3. Made no difference
Tried several files and several formats....

Regards

Sebastian
erion
Enthusiast
Enthusiast
Posts: 128
Joined: Sun Jan 24, 2010 11:12 pm

Re: TagLib

Post by erion »

Hi,
This is very interesting. It appears that everything works as expected here, yet something goes wrong inside TagLib, despite the fact that it reports everything being fine.
If you have another computer, you could try the same example code on the same audio file. Other than that, unfortunately, I have no idea what to do next, especially because this does not seem to be a PB issue. TagLib seems to write out the tags properly, but they are not reflected in the actual file.

You may be able to get some help regarding this issue if you send an email explaining your problem to taglib-devel(at)kde(dot)org
Replace (at) and (dot) to @ and . respectively.

Sorry for not being able to help more!

Best,
Erion
To see a world in a grain of sand,
And a heaven in a wild flower,
Hold infinity in the palm of your hand,
And eternity in an hour.

- W. B.

Visit my site, also for PureBasic goodies http://erion.tdrealms.com
Post Reply