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