TagLib

Share your advanced PureBasic knowledge/code with the community.
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

TagLib

Post by Inner »

TagLib is a library for reading and editing the meta-data of several popular audio formats. Currently it supports both ID3v1 and ID3v2 for MP3 files, Ogg Vorbis comments and ID3 tags and Vorbis comments in FLAC, MPC, Speex, WavPack and TrueAudio files.

http://developer.kde.org/~wheeler/taglib.html

As promoted by id3.org and apparently fast than id3lib.

Code: Select all

; /***************************************************************************
;     copyright            : (C) 2003 by Scott Wheeler
;     email                : wheeler@kde.org
;  ***************************************************************************/
; 
; /***************************************************************************
;  *   This library is free software; you can redistribute it and/or modify  *
;  *   it  under the terms of the GNU Lesser General Public License version  *
;  *   2.1 As published by the Free Software Foundation.                     *
;  *                                                                         *
;  *   This library is distributed in the hope that it will be useful, but   *
;  *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
;  *   MERCHANTABILITY Or FITNESS For A PARTICULAR PURPOSE.  See the GNU     *
;  *   Lesser General Public License For more details.                       *
;  *                                                                         *
;  *   You should have received a copy of the GNU Lesser General Public      *
;  *   License along With this library; if not, write to the Free Software   *
;  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
;  *   USA                                                                   *
;  ***************************************************************************/

; /*******************************************************************************
;  * Special convenience ID3v2 functions
;  *******************************************************************************/

Enumeration
  #TagLib_ID3v2_Latin1
  #TagLib_ID3v2_UTF16
  #TagLib_ID3v2_UTF16BE
  #TagLib_ID3v2_UTF8
  #TagLib_ID3v2_Encoding
EndEnumeration

; /*******************************************************************************
;  * File API
;  ******************************************************************************/

Enumeration
  #TagLib_File_MPEG
  #TagLib_File_OggVorbis
  #TagLib_File_FLAC
  #TagLib_File_MPC
  #TagLib_File_OggFlac
  #TagLib_File_WavPack
  #TagLib_File_Speex
  #TagLib_File_TrueAudio
  #TagLib_File_Type
EndEnumeration

; /*******************************************************************************
;  * [ TagLib From C Binding ]
;  *
;  * This is an Interface To TagLib's "simple" API, meaning that you can read and
;  * modify media files in a generic, but Not specialized way.  This is a rough
;  * representation of TagLib::File And TagLib::Tag, For which the documentation
;  * is somewhat more complete And worth consulting.
;  *******************************************************************************/

; /*
;  * These are used For type provide some type safety To the C API (As opposed To
;  * using void *, but pointers To them are simply cast To the corresponding C++
;  * types in the implementation.
;  */

Structure TabLib_File
  dummy.l
EndStructure
Structure TabLib_Tag
  dummy.l
EndStructure
Structure TabLib_AudioProperties
  dummy.l
EndStructure

ImportC "/usr/lib/libtag_c.so"
; /*!
;  * By Default all strings coming into Or out of TagLib's C API are in UTF8.
;  * However, it may be desirable For TagLib To operate on Latin1 (ISO-8859-1)
;  * strings in which Case this should be set To FALSE.
;  */
; void taglib_set_strings_unicode(BOOL unicode);
  taglib_set_strings_unicode(unicode.b) As "taglib_set_strings_unicode"

; /*!
;  * TagLib can keep track of strings that are created when outputting tag values
;  * And clear them using taglib_tag_clear_strings().  This is enabled by Default.
;  * However If you wish To do more fine grained management of strings, you can do
;  * so by setting \a management To FALSE.
;  */
; void taglib_set_string_management_enabled(BOOL management);
  taglib_set_string_management_enabled(management.b) As "taglib_set_string_management_enabled"

; /*!
;  * Creates a TagLib file based on \a filename.  TagLib will try To guess the file
;  * type.
;  * 
;  * \returns NULL If the file type cannot be determined Or the file cannot
;  * be opened.
;  */
; TagLib_File * taglib_file_new(const char *filename);
  taglib_file_new(filename.s) As "taglib_file_new"

; /*!
;  * Creates a TagLib file based on \a filename.  Rather than attempting To guess
;  * the type, it will use the one specified by \a type.
;  */
; TagLib_File *taglib_file_new_type(const char *filename, TagLib_File_Type type)
  taglib_file_new_type(filename.s,type.l) As "taglib_file_new_type"

; /*!
;  * Frees And closes the file.
;  */
; void taglib_file_free(TagLib_File *file) 
  taglib_file_free(file.l) As "taglib_file_free"

; /*!
;  * Returns true If the file is open And readble And valid information For
;  * the Tag And / Or AudioProperties was found.
;  */
; BOOL taglib_file_is_valid(const TagLib_File *file) 
  taglib_file_is_valid(file.l) As "taglib_file_is_valid"

; /*!
;  * Returns a pointer To the tag associated With this file.  This will be freed
;  * automatically when the file is freed.
;  */
; TagLib_Tag *taglib_file_tag(const TagLib_File *file) 
  taglib_file_tag(file.l) As "taglib_file_tag"

; /*!
;  * Returns a pointer To the the audio properties associated With this file.  This
;  * will be freed automatically when the file is freed.
;  */
; const TagLib_AudioProperties *taglib_file_audioproperties(const TagLib_File *file) 
  taglib_file_audioproperties(file.l) As "taglib_file_audioproperties"

; /*!
;  * Saves the \a file To disk.
;  */
; BOOL taglib_file_save(TagLib_File *file)  
  taglib_file_save(file.l) As "taglib_file_save" 

; /******************************************************************************
;  * Tag API
;  ******************************************************************************/
 
; /*!
;  * Returns a string With this tag's title.
;  *
;  * \note By Default this string should be UTF8 encoded And its memory should be
;  * freed using taglib_tag_free_strings().
;  */
; char *taglib_tag_title(const TagLib_Tag *tag)  
  taglib_tag_title(tag.l) As "taglib_tag_title" 

; /*!
;  * Returns a string With this tag's artist.
;  *
;  * \note By Default this string should be UTF8 encoded And its memory should be
;  * freed using taglib_tag_free_strings().
;  */
; char *taglib_tag_artist(const TagLib_Tag *tag)  
  taglib_tag_artist(tag.l) As "taglib_tag_artist" 

; /*!
;  * Returns a string With this tag's album name.
;  *
;  * \note By Default this string should be UTF8 encoded And its memory should be
;  * freed using taglib_tag_free_strings().
;  */
; char *taglib_tag_album(const TagLib_Tag *tag)  
  taglib_tag_album(tag.l) As "taglib_tag_album" 

; /*!
;  * Returns a string With this tag's comment.
;  *
;  * \note By Default this string should be UTF8 encoded And its memory should be
;  * freed using taglib_tag_free_strings().
;  */
; char *taglib_tag_comment(const TagLib_Tag *tag)  
  taglib_tag_comment(tag.l) As "taglib_tag_comment" 

; /*!
;  * Returns a string With this tag's genre.
;  *
;  * \note By Default this string should be UTF8 encoded And its memory should be
;  * freed using taglib_tag_free_strings().
;  */
; char *taglib_tag_genre(const TagLib_Tag *tag)  
  taglib_tag_genre(tag.l) As "taglib_tag_genre" 

; /*!
;  * Returns the tag's year or 0 if year is not set.
;  */
; unsigned int taglib_tag_year(const TagLib_Tag *tag)  
  taglib_tag_year(tag.l) As "taglib_tag_year" 

; /*!
;  * Returns the tag's track number or 0 if track number is not set.
;  */
; unsigned int taglib_tag_track(const TagLib_Tag *tag)  
  taglib_tag_track(tag.l) As "taglib_tag_track" 

; /*!
;  * Sets the tag's title.
;  *
;  * \note By Default this string should be UTF8 encoded.
;  */
; void taglib_tag_set_title(TagLib_Tag *tag, const char *title)  
  taglib_tag_set_title(tag.l,title.s) As "taglib_tag_set_title" 

; /*!
;  * Sets the tag's artist.
;  *
;  * \note By Default this string should be UTF8 encoded.
;  */
; void taglib_tag_set_artist(TagLib_Tag *tag, const char *artist)  
  taglib_tag_set_artist(tag.l,artist.s) As "taglib_tag_set_artist" 

; /*!
;  * Sets the tag's album.
;  *
;  * \note By Default this string should be UTF8 encoded.
;  */
; void taglib_tag_set_album(TagLib_Tag *tag, const char *album)  
  taglib_tag_set_album(tag.l,album.s) As "taglib_tag_set_album" 

; /*!
;  * Sets the tag's comment.
;  *
;  * \note By Default this string should be UTF8 encoded.
;  */
; void taglib_tag_set_comment(TagLib_Tag *tag, const char *comment)  
  taglib_tag_set_comment(tag.l,comment.s) As "taglib_tag_set_comment" 

; /*!
;  * Sets the tag's genre.
;  *
;  * \note By Default this string should be UTF8 encoded.
;  */
; void taglib_tag_set_genre(TagLib_Tag *tag, const char *genre)  
  taglib_tag_set_genre(tag.l,genre.s) As "taglib_tag_set_genre" 

; /*!
;  * Sets the tag's year.  0 indicates that this field should be cleared.
;  */
; void taglib_tag_set_year(TagLib_Tag *tag, unsigned int year)  
  taglib_tag_set_year(tag.l,year.l) As "taglib_tag_set_year" 

; /*!
;  * Sets the tag's track number.  0 indicates that this field should be cleared.
;  */
; void taglib_tag_set_track(TagLib_Tag *tag, unsigned int track)  
  taglib_tag_set_track(tag.l,track.l) As "taglib_tag_set_track" 

; /*!
;  * Frees all of the strings that have been created by the tag.
;  */
; void taglib_tag_free_strings(void)  
  taglib_tag_free_strings() As "taglib_tag_free_strings" 

; /******************************************************************************
;  * Audio Properties APIs
;  ******************************************************************************/

; /*!
;  * Returns the length of the file in seconds.
;  */
; int taglib_audioproperties_length(const TagLib_AudioProperties *audioProperties)  
  taglib_audioproperties_length(audioProperties.l) As "taglib_audioproperties_length" 

; /*!
;  * Returns the bitrate of the file in kb/s.
;  */
; int taglib_audioproperties_bitrate(const TagLib_AudioProperties *audioProperties)  
  taglib_audioproperties_bitrate(audioProperties.l) As "taglib_audioproperties_bitrate" 

; /*!
;  * Returns the sample rate of the file in Hz.
;  */
; int taglib_audioproperties_samplerate(const TagLib_AudioProperties *audioProperties)  
  taglib_audioproperties_samplerate(audioProperties.l) As "taglib_audioproperties_samplerate" 

; /*!
;  * Returns the number of channels in the audio stream.
;  */
; int taglib_audioproperties_channels(const TagLib_AudioProperties *audioProperties)  
  taglib_audioproperties_channels(audioProperties.l) As "taglib_audioproperties_channels" 

; /*!
;  * This sets the Default encoding For ID3v2 frames that are written To tags.
;  */

; void taglib_id3v2_set_default_text_encoding(TagLib_ID3v2_Encoding encoding)  
  taglib_id3v2_set_default_text_encoding(encoding.l) As "taglib_id3v2_set_default_text_encoding" 
EndImport

; /******************************************************************************
;  * Test Code
;  ******************************************************************************/


file=taglib_file_new("test.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)
CloseConsole()
EndIf
User avatar
idle
Always Here
Always Here
Posts: 5836
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Post by idle »

sweet, I just hope I remember to search for it. :D
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

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 ;)
SPAMINATOR NR.1
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

@Rings, the functions inside the Windows lib seem to have an underscore appended in front of the function name. So try to replace for example:

Code: Select all

taglib_set_strings_unicode(unicode.b) As "taglib_set_strings_unicode"
with:

Code: Select all

taglib_set_strings_unicode(unicode.b) As "_taglib_set_strings_unicode"
I haven't tested it yet but it might work.

[Edit]
Here's the updated code to work on windows as well:

Code: Select all


; /***************************************************************************
;     copyright            : (C) 2003 by Scott Wheeler
;     email                : wheeler@kde.org
;  ***************************************************************************/
;
; /***************************************************************************
;  *   This library is free software; you can redistribute it and/or modify  *
;  *   it  under the terms of the GNU Lesser General Public License version  *
;  *   2.1 As published by the Free Software Foundation.                     *
;  *                                                                         *
;  *   This library is distributed in the hope that it will be useful, but   *
;  *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
;  *   MERCHANTABILITY Or FITNESS For A PARTICULAR PURPOSE.  See the GNU     *
;  *   Lesser General Public License For more details.                       *
;  *                                                                         *
;  *   You should have received a copy of the GNU Lesser General Public      *
;  *   License along With this library; if not, write to the Free Software   *
;  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
;  *   USA                                                                   *
;  ***************************************************************************/

; /*******************************************************************************
;  * Special convenience ID3v2 functions
;  *******************************************************************************/

Enumeration
  #TagLib_ID3v2_Latin1
  #TagLib_ID3v2_UTF16
  #TagLib_ID3v2_UTF16BE
  #TagLib_ID3v2_UTF8
  #TagLib_ID3v2_Encoding
EndEnumeration

; /*******************************************************************************
;  * File API
;  ******************************************************************************/

Enumeration
  #TagLib_File_MPEG
  #TagLib_File_OggVorbis
  #TagLib_File_FLAC
  #TagLib_File_MPC
  #TagLib_File_OggFlac
  #TagLib_File_WavPack
  #TagLib_File_Speex
  #TagLib_File_TrueAudio
  #TagLib_File_Type
EndEnumeration

; /*******************************************************************************
;  * [ TagLib From C Binding ]
;  *
;  * This is an Interface To TagLib's "simple" API, meaning that you can read and
;  * modify media files in a generic, but Not specialized way.  This is a rough
;  * representation of TagLib::File And TagLib::Tag, For which the documentation
;  * is somewhat more complete And worth consulting.
;  *******************************************************************************/

; /*
;  * These are used For type provide some type safety To the C API (As opposed To
;  * using void *, but pointers To them are simply cast To the corresponding C++
;  * types in the implementation.
;  */

Structure TabLib_File
  dummy.l
EndStructure
Structure TabLib_Tag
  dummy.l
EndStructure
Structure TabLib_AudioProperties
  dummy.l
EndStructure

CompilerSelect #PB_Compiler_OS
 CompilerCase #PB_Compiler_OS = #PB_OS_Linux
  ImportC "/usr/lib/libtag_c.so"
   taglib_set_strings_unicode(unicode.b) As "taglib_set_strings_unicode"
   taglib_set_string_management_enabled(management.b) As "taglib_set_string_management_enabled"
   taglib_file_new(filename.s) As "taglib_file_new"
   taglib_file_new_type(filename.s,type.l) As "taglib_file_new_type"
   taglib_file_free(file.l) As "taglib_file_free"
   taglib_file_is_valid(file.l) As "taglib_file_is_valid"
   taglib_file_tag(file.l) As "taglib_file_tag"
   taglib_file_audioproperties(file.l) As "taglib_file_audioproperties"
   taglib_file_save(file.l) As "taglib_file_save"
   taglib_tag_title(tag.l) As "taglib_tag_title"
   taglib_tag_artist(tag.l) As "taglib_tag_artist"
   taglib_tag_album(tag.l) As "taglib_tag_album"
   taglib_tag_comment(tag.l) As "taglib_tag_comment"
   taglib_tag_genre(tag.l) As "taglib_tag_genre"
   taglib_tag_year(tag.l) As "taglib_tag_year"
   taglib_tag_track(tag.l) As "taglib_tag_track"
   taglib_tag_set_title(tag.l,title.s) As "taglib_tag_set_title"
   taglib_tag_set_artist(tag.l,artist.s) As "taglib_tag_set_artist"
   taglib_tag_set_album(tag.l,album.s) As "taglib_tag_set_album"
   taglib_tag_set_comment(tag.l,comment.s) As "taglib_tag_set_comment"
   taglib_tag_set_genre(tag.l,genre.s) As "taglib_tag_set_genre"
   taglib_tag_set_year(tag.l,year.l) As "taglib_tag_set_year"
   taglib_tag_set_track(tag.l,track.l) As "taglib_tag_set_track"
   taglib_tag_free_strings() As "taglib_tag_free_strings"
   taglib_audioproperties_length(audioProperties.l) As "taglib_audioproperties_length"
   taglib_audioproperties_bitrate(audioProperties.l) As "taglib_audioproperties_bitrate"
   taglib_audioproperties_samplerate(audioProperties.l) As "taglib_audioproperties_samplerate"
   taglib_audioproperties_channels(audioProperties.l) As "taglib_audioproperties_channels"
   taglib_id3v2_set_default_text_encoding(encoding.l) As "taglib_id3v2_set_default_text_encoding" 
 CompilerCase #PB_OS_Windows
  ImportC "tag_c.lib"
    taglib_set_strings_unicode(unicode.b) As "_taglib_set_strings_unicode"
    taglib_set_string_management_enabled(management.b) As "_taglib_set_string_management_enabled"
    taglib_file_new(filename.s) As "_taglib_file_new"
    taglib_file_new_type(filename.s,type.l) As "_taglib_file_new_type"
    taglib_file_free(file.l) As "_taglib_file_free"
    taglib_file_is_valid(file.l) As "_taglib_file_is_valid"
    taglib_file_tag(file.l) As "_taglib_file_tag"
    taglib_file_audioproperties(file.l) As "_taglib_file_audioproperties"
    taglib_file_save(file.l) As "_taglib_file_save"
    taglib_tag_title(tag.l) As "_taglib_tag_title"
    taglib_tag_artist(tag.l) As "_taglib_tag_artist"
    taglib_tag_album(tag.l) As "_taglib_tag_album"
    taglib_tag_comment(tag.l) As "_taglib_tag_comment"
    taglib_tag_genre(tag.l) As "_taglib_tag_genre"
    taglib_tag_year(tag.l) As "_taglib_tag_year"
    taglib_tag_track(tag.l) As "_taglib_tag_track"
    taglib_tag_set_title(tag.l,title.s) As "_taglib_tag_set_title"
    taglib_tag_set_artist(tag.l,artist.s) As "_taglib_tag_set_artist"
    taglib_tag_set_album(tag.l,album.s) As "_taglib_tag_set_album"
    taglib_tag_set_comment(tag.l,comment.s) As "_taglib_tag_set_comment"
    taglib_tag_set_genre(tag.l,genre.s) As "_taglib_tag_set_genre"
    taglib_tag_set_year(tag.l,year.l) As "_taglib_tag_set_year"
    taglib_tag_set_track(tag.l,track.l) As "_taglib_tag_set_track"
    taglib_tag_free_strings() As "_taglib_tag_free_strings"
    taglib_audioproperties_length(audioProperties.l) As "_taglib_audioproperties_length"
    taglib_audioproperties_bitrate(audioProperties.l) As "_taglib_audioproperties_bitrate"
    taglib_audioproperties_samplerate(audioProperties.l) As "_taglib_audioproperties_samplerate"
    taglib_audioproperties_channels(audioProperties.l) As "_taglib_audioproperties_channels"
    taglib_id3v2_set_default_text_encoding(encoding.l) As "_taglib_id3v2_set_default_text_encoding" 
CompilerEndSelect
 
EndImport

; /******************************************************************************
;  * Test Code
;  ******************************************************************************/

file=taglib_file_new("test.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)
  Input()
CloseConsole()
EndIf 
Make sure to choose a valid file as "test.mp3" otherwise it'll crash.
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

@InfoByt3: thx, works now.

still you have to put the tag.dll inside your executable path.
SPAMINATOR NR.1
lexvictory
Addict
Addict
Posts: 1027
Joined: Sun May 15, 2005 5:15 am
Location: Australia
Contact:

Post by lexvictory »

Inf0Byt3 wrote:@Rings, the functions inside the Windows lib seem to have an underscore appended in front of the function name.
I never had this problem when i started using the lib... :? my code: (does not implement all functions)

Code: Select all

CompilerIf #PB_Compiler_OS = #PB_OS_Linux
  ImportC "/usr/lib/libtag_c.so"
CompilerElse
  ImportC "tag_c.lib"
CompilerEndIf
taglib_file_new(filename.p-utf8)
taglib_file_free(file)
taglib_file_tag(file)
taglib_tag_free_strings();must be called
taglib_tag_title(*tag);returns pointer to utf8 string
taglib_tag_artist(*tag)
taglib_tag_album(*tag)
taglib_tag_comment(*tag)
taglib_tag_genre(*tag)
taglib_tag_year(*tag);returns int
taglib_tag_track(*tag);ret int

EndImport
Demonio Ardente

Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Post by Inner »

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" ; << remove this
 CompilerEndSelect
any help would be fine Inner, to make this piece of code
cross-compatible ;)
You don't need that there, that's for C++ coders we need the tag_c.lib
Seymour Clufley
Addict
Addict
Posts: 1264
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Post by Seymour Clufley »

I've been trying to change an mp3's tags with this, unsuccessfully.

Inner, is there any chance of some demo code?
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

Try this:

Code: Select all

file=taglib_file_new("C:\test.mp3")
If file
  Debug "Open"
  tag = taglib_file_tag(file);
  
  Debug taglib_tag_set_artist(tag,"muhahahaha")
  Debug taglib_file_save(file)

  taglib_tag_free_strings()
  taglib_file_free(file)
EndIf 
Seems to work here :).
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Post by Inner »

Inf0Byt3 wrote:Try this:

Code: Select all

file=taglib_file_new("C:\test.mp3")
If file
  Debug "Open"
  tag = taglib_file_tag(file);
  
  Debug taglib_tag_set_artist(tag,"muhahahaha")
  Debug taglib_file_save(file)

  taglib_tag_free_strings()
  taglib_file_free(file)
EndIf 
Seems to work here :).
Yep that's the one. :)
Seymour Clufley
Addict
Addict
Posts: 1264
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Post by Seymour Clufley »

Yes, thanks. I hadn't used the taglib_file_save command.
Peyman
Enthusiast
Enthusiast
Posts: 203
Joined: Mon Dec 24, 2007 4:15 pm
Location: Iran

Post by Peyman »

Thanks for find this library :-)
Peyman
Enthusiast
Enthusiast
Posts: 203
Joined: Mon Dec 24, 2007 4:15 pm
Location: Iran

Post by Peyman »

Hi to all,
i can use this with loadlibrarym() and load/call it from memory.
Thanks.
Peyman
Enthusiast
Enthusiast
Posts: 203
Joined: Mon Dec 24, 2007 4:15 pm
Location: Iran

Re: TagLib

Post by Peyman »

how we can use new version of TagLib 1.6 ?
how can compile this new version
Sorry for my bad english.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Re: TagLib

Post by Karbon »

Does anyone know of a working download of the Windows binaries for the latest version?

http://ftp.musicbrainz.org/pub/musicbra ... ks/taglib/ lists version 1.5 and I can't get 1.6 to build here.
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Post Reply