- Current state of the bindings
- File management
- Audio properties
- Tag properties
- Raw tag properties
- Version history
This egg provides a usable subset of bindings to the taglib library.
The egg does intentionally not use taglib's C API as is due to incompatibilities with the CHICKEN FFI. For this reason the bindings are modeled after its C API with the following differences:
- Only UTF-8 strings are supported, there is no flag to switch between UTF-8 and Latin-1
- Memory management immediately frees strings, there is no option to defer garbage collection of strings
- The API exclusively operates on TagLib::File instances, represented as taglib-file records
- The raw tag property API is supported in addition to the audio property and tag property API, it permits retrieving and setting more than the standard set of tag properties
Install the taglib library with your operating system's package manager.
Note that due to pervasive use of and-let* all API calls will return #f if the FILE argument's resources have been freed.
- file-open PATHprocedure
Opens an audio file the PATH string points to. If successful, a taglib-file record is returned which is used in all subsequent API calls, otherwise #f.
- file-valid? FILEprocedure
Returns #t if FILE is a taglib-file record and readable, otherwise #f.
- file-save! FILEprocedure
Stores changes made by the setter procedures to the file backing FILE.
- file-free! FILEprocedure
Frees the resources associated with FILE if any. This procedure is used as finalizer for taglib-file records, therefore it's not necessary to call it manually, but can be done anyway.
- audio-property FILE KEYprocedure
Returns an audio property for FILE, either a number or #f if it couldn't be detected. KEY must be one of the following symbols:
- Length in seconds with millisecond precision
- Bit rate in kb/s
- Sample rate in Hz
- Number of channels
- audio-properties FILEprocedure
Returns an alist of all audio properties for FILE. The keys are (length bitrate samplerate channels), the values are the same as if obtained by using audio-property.
- tag-property FILE KEYprocedure
- tag-property-set! FILE KEY VALUEprocedure
- (set! (tag-property FILE KEY) VALUE)setter
Returns or sets a tag property for FILE. KEY must be one of the following symbols:
- Title (string)
- Artist (string)
- Album (string)
- Comment (string)
- Genre (string)
- Year (number)
- Track (number)
A return value of #f indicates an unset property. Likewise #f can be used as VALUE to clear a property.
- tag-properties FILEprocedure
Returns an alist of all tag properties for FILE. The keys are (title artist album comment genre year track), the values the same as if obtained by using tag-property.
- raw-tag-property-exists? FILE KEYprocedure
Returns #t if FILE contains the raw tag property KEY, otherwise #f. KEY must be a string.
- raw-tag-property FILE KEYprocedure
- raw-tag-property-set! FILE KEY VALUESprocedure
- (set! (raw-tag-property FILE KEY) VALUES)setter
Returns or sets a list of string values in FILE for the raw tag property KEY. KEY must be a string. VALUES is a list of strings. An unset property is represented as the empty list.
- raw-tag-property-clear! FILE KEYprocedure
Clears the raw tag property in FILE for KEY. KEY must be a string.
- raw-tag-properties FILEprocedure
- raw-tag-properties-set! FILE PROPERTIESprocedure
- set! (raw-tag-properties FILE) PROPERTIESsetter
Returns or sets an alist of raw tag properties for FILE. PROPERTIES is an alist where each key is a string and each value a non-empty list of strings.
(import scheme) (import (chicken base)) (import (chicken pretty-print)) (import (chicken process-context)) (import (chicken string)) (import (prefix taglib taglib:)) (define (with-unit value unit) (if value (string-append (->string value) unit) "unknown")) (define (inexact arg) (and (number? arg) (exact->inexact arg))) (for-each (lambda (path) (let ((file (taglib:file-open path))) (when (and file (taglib:file-valid? file)) (print "Processing: " path "...") (print "Length: " (with-unit (inexact (taglib:audio-property file 'length)) "s")) (print "Bitrate: " (with-unit (taglib:audio-property file 'bitrate) "kb/s")) (print "Samplerate: " (with-unit (taglib:audio-property file 'samplerate) "Hz")) (print "Channels: " (or (taglib:audio-property file 'channels) "unknown")) (print "Title: " (or (taglib:tag-property file 'title) "unknown")) (print "Artist: " (or (taglib:tag-property file 'artist) "unknown")) (print "Album: " (or (taglib:tag-property file 'album) "unknown")) (print "Comment: " (or (taglib:tag-property file 'comment) "unknown")) (print "Genre: " (or (taglib:tag-property file 'genre) "unknown")) (print "Year: " (or (taglib:tag-property file 'year) "unknown")) (print "Track: " (or (taglib:tag-property file 'track) "unknown")) (for-each (lambda (property) (let ((key (car property)) (values (cdr property))) (print key ": " (string-intersperse values ",")))) (taglib:raw-tag-properties file))))) (command-line-arguments))
Further examples can be found in the repository.
Copyright 2019 Vasilij Schneidermann This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Quote build script variables on Windows
- Initial release