|
Sound.TagLib | Portability | only tested with GHC | Stability | experimental | Maintainer | Brandon Bickford <bickfordb@gmail.com> |
|
|
|
|
|
Description |
High level interface to read and write ID3 tag fields (album, artist,
comment, genre, title, track number, year) and get audio properties (length,
bit rate, sample rate, channels)
|
|
Synopsis |
|
|
|
|
Data Types
|
|
|
|
|
|
|
|
TagFile operations
|
|
|
Open a filename and possibly get a TagFile
|
|
|
Save changes to a tag
|
|
Tag Operations
|
|
|
Get a Tag from a TagFile, if it has one
|
|
|
Get an album string from a Tag
|
|
|
Get an artist string from a Tag
|
|
|
Get the comment string from a Tag
|
|
|
Get the comment string from a Tag
|
|
|
Set the album of a tag
|
|
|
Set the artist of a tag
|
|
|
Set the comment of a tag
|
|
|
Set the genre of a tag
|
|
|
Set the track of a tag
|
|
|
Set the year of a tag
|
|
|
Get a title string from a Tag
|
|
|
Get the track number from a Tag. Empty values will be 0
|
|
|
Get the year from a Tag. Empty values will be 0
|
|
AudioProperties Operations
|
|
|
Get the AudioProperties from a TagFile
|
|
|
Get the bitRate from AudioProperties
|
|
|
Get the number of channels from AudioProperties
|
|
|
Get the duration (in seconds) from AudioProperties
In TagLib, this is named length. This is renamed so that it doesn't conflict with the Prelude length
|
|
|
Get the sampleRate from AudioProperties
|
|
Example
|
|
module Main where
import qualified Sound.TagLib as TagLib
import Data.Maybe
import Control.Monad
import System
main = do
args <- getArgs
mapM showFile args
withMaybe :: (Maybe j) -> (j -> IO ()) -> IO ()
withMaybe mebbe action = do
case mebbe of
Just x -> do action x
return ()
Nothing -> return ()
showFile filename = do
t <- TagLib.open filename
withMaybe t showTagFile
showTagFile :: TagLib.TagFile -> IO ()
showTagFile tagFile = do
t <- TagLib.tag tagFile
withMaybe t showTag
p <- TagLib.audioProperties tagFile
withMaybe p showAudioProperties
showTag :: TagLib.Tag -> IO ()
showTag tag = do
artist <- TagLib.artist tag
album <- TagLib.album tag
title <- TagLib.title tag
comment <- TagLib.comment tag
year <- TagLib.year tag
track <- TagLib.track tag
print (artist, album, title, year, track)
showAudioProperties :: TagLib.AudioProperties -> IO ()
showAudioProperties props = do
bitrate <- TagLib.bitRate props
length <- TagLib.duration props
samplerate <- TagLib.sampleRate props
channels <- TagLib.channels props
print (bitrate, length, channels, samplerate)
|
|
Produced by Haddock version 2.4.2 |