htaglib-1.1.1: Bindings to TagLib, audio meta-data library

Copyright© 2015–2017 Mark Karpov
LicenseBSD 3 clause
MaintainerMark Karpov <markkarpov92@gmail.com>
Stabilityexperimental
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Sound.HTagLib

Contents

Description

This module provides a complete high-level interface to TagLib. This is the module you should import to use in your projects.

Synopsis

Getters

getTags #

Arguments

:: MonadIO m 
=> FilePath

Path to audio file

-> TagGetter a

Getter

-> m a

Extracted data

getTags path g will try to read file located at path and read meta data of the file using getter g. Type of file will be guessed from its extension. If this is not satisfactory and you want to explicitly specify the file type, see getTags' variation of this function.

In the case of trouble HTagLibException will be thrown.

getTags' #

Arguments

:: MonadIO m 
=> FilePath

Path to audio file

-> FileType

Type of audio file

-> TagGetter a

Getter

-> m a

Extracted data

This is essentially the same as getTags, but allows to explicitly choose file type (see FileType).

titleGetter :: TagGetter Title #

Getter to retrieve track title.

artistGetter :: TagGetter Artist #

Getter to retrieve track artist.

albumGetter :: TagGetter Album #

Getter to retrieve track album.

commentGetter :: TagGetter Comment #

Getter to retrieve track comment.

genreGetter :: TagGetter Genre #

Getter to retrieve genre of the track.

yearGetter :: TagGetter (Maybe Year) #

Getter to retrieve year to the track (returns Nothing if the data is missing).

trackNumberGetter :: TagGetter (Maybe TrackNumber) #

Getter to retrieve track number (returns Nothing if the data is missing).

durationGetter :: TagGetter Duration #

Getter to retrieve duration in seconds.

bitRateGetter :: TagGetter BitRate #

Getter to retrieve bit rate.

sampleRateGetter :: TagGetter SampleRate #

Getter to retrieve sample rate.

channelsGetter :: TagGetter Channels #

Getter to retrieve number of channels in audio data.

Setters

setTags #

Arguments

:: MonadIO m 
=> FilePath

Path to audio file

-> Maybe ID3v2Encoding

Encoding for ID3v2 frames

-> TagSetter

Setter

-> m () 

Set tags in specified file using the given setter.

In the case of trouble HTagLibException will be thrown.

setTags' #

Arguments

:: MonadIO m 
=> FilePath

Path to audio file

-> Maybe ID3v2Encoding

Encoding for ID3v2 frames

-> FileType

Type of audio file

-> TagSetter

Setter

-> m () 

Similar to setTags, but you can also specify type of audio file explicitly (otherwise it's guessed from file extension).

titleSetter :: Title -> TagSetter #

Setter for track title.

artistSetter :: Artist -> TagSetter #

Setter for track artist.

albumSetter :: Album -> TagSetter #

Setter for track album.

commentSetter :: Comment -> TagSetter #

Setter for track comment.

genreSetter :: Genre -> TagSetter #

Setter for track genre.

yearSetter :: Maybe Year -> TagSetter #

Setter for year tag, use Nothing to clear the field.

trackNumberSetter :: Maybe TrackNumber -> TagSetter #

Setter for track number, use Nothing to clear the field.

Data types

data Title #

Title tag.

Instances

Eq Title # 

Methods

(==) :: Title -> Title -> Bool #

(/=) :: Title -> Title -> Bool #

Ord Title # 

Methods

compare :: Title -> Title -> Ordering #

(<) :: Title -> Title -> Bool #

(<=) :: Title -> Title -> Bool #

(>) :: Title -> Title -> Bool #

(>=) :: Title -> Title -> Bool #

max :: Title -> Title -> Title #

min :: Title -> Title -> Title #

Show Title # 

Methods

showsPrec :: Int -> Title -> ShowS #

show :: Title -> String #

showList :: [Title] -> ShowS #

IsString Title # 

Methods

fromString :: String -> Title #

mkTitle :: Text -> Title #

Construction of Title type, null bytes are converted to spaces.

unTitle :: Title -> Text #

Convert Title to Text.

data Artist #

Artist tag.

mkArtist :: Text -> Artist #

Construction of Artist type, null bytes are converted to spaces.

unArtist :: Artist -> Text #

Convert Artist to Text.

data Album #

Album tag.

Instances

Eq Album # 

Methods

(==) :: Album -> Album -> Bool #

(/=) :: Album -> Album -> Bool #

Ord Album # 

Methods

compare :: Album -> Album -> Ordering #

(<) :: Album -> Album -> Bool #

(<=) :: Album -> Album -> Bool #

(>) :: Album -> Album -> Bool #

(>=) :: Album -> Album -> Bool #

max :: Album -> Album -> Album #

min :: Album -> Album -> Album #

Show Album # 

Methods

showsPrec :: Int -> Album -> ShowS #

show :: Album -> String #

showList :: [Album] -> ShowS #

IsString Album # 

Methods

fromString :: String -> Album #

mkAlbum :: Text -> Album #

Construction of Album type, null bytes are converted to spaces.

unAlbum :: Album -> Text #

Convert Album to Text.

mkComment :: Text -> Comment #

Construction of Comment type, null bytes are converted to spaces.

unComment :: Comment -> Text #

Convert Comment to Text.

data Genre #

Genre tag.

Instances

Eq Genre # 

Methods

(==) :: Genre -> Genre -> Bool #

(/=) :: Genre -> Genre -> Bool #

Ord Genre # 

Methods

compare :: Genre -> Genre -> Ordering #

(<) :: Genre -> Genre -> Bool #

(<=) :: Genre -> Genre -> Bool #

(>) :: Genre -> Genre -> Bool #

(>=) :: Genre -> Genre -> Bool #

max :: Genre -> Genre -> Genre #

min :: Genre -> Genre -> Genre #

Show Genre # 

Methods

showsPrec :: Int -> Genre -> ShowS #

show :: Genre -> String #

showList :: [Genre] -> ShowS #

IsString Genre # 

Methods

fromString :: String -> Genre #

mkGenre :: Text -> Genre #

Construction of Genre type, null bytes are converted to spaces.

unGenre :: Genre -> Text #

Convert Genre to Text.

data Year #

Year tag.

Instances

Eq Year # 

Methods

(==) :: Year -> Year -> Bool #

(/=) :: Year -> Year -> Bool #

Ord Year # 

Methods

compare :: Year -> Year -> Ordering #

(<) :: Year -> Year -> Bool #

(<=) :: Year -> Year -> Bool #

(>) :: Year -> Year -> Bool #

(>=) :: Year -> Year -> Bool #

max :: Year -> Year -> Year #

min :: Year -> Year -> Year #

Show Year # 

Methods

showsPrec :: Int -> Year -> ShowS #

show :: Year -> String #

showList :: [Year] -> ShowS #

mkYear :: Int -> Maybe Year #

Construction of Year type, non-positive values result in Nothing.

unYear :: Year -> Int #

Convert Year to Int.

mkTrackNumber :: Int -> Maybe TrackNumber #

Construction of TrackNumber type, non-positive values result in Nothing.

mkDuration :: Int -> Maybe Duration #

Construction of Duration values, negative values result in Nothing.

unDuration :: Duration -> Int #

Convert Duration to Int.

data BitRate #

Bit rate in kb/s.

mkBitRate :: Int -> Maybe BitRate #

Construction of BitRate values, negative values result in Nothing.

unBitRate :: BitRate -> Int #

Convert BitRate to Int.

mkSampleRate :: Int -> Maybe SampleRate #

Construction of SampleRate values, non-positive values result in Nothing.

data Channels #

Number of channels in the audio stream.

mkChannels :: Int -> Maybe Channels #

Construction of Channels values, non-positive values result in Nothing.

unChannels :: Channels -> Int #

Convert Channels to Int.

data FileType #

Types of files TagLib can work with. This may be used to explicitly specify type of file instead of relying on the TagLib's ability to guess type of file from its extension.

Constructors

MPEG

MPEG

OggVorbis

Ogg vorbis

FLAC

FLAC

MPC

MPC

OggFlac

Ogg FLAC

WavPack

Wav pack

Speex

Speex

TrueAudio

True audio

MP4

MP4

ASF

ASF

data TagGetter a #

A composable entity that can be used with getTags or getTags' functions to read batch of meta parameters.

Instances

Functor TagGetter # 

Methods

fmap :: (a -> b) -> TagGetter a -> TagGetter b #

(<$) :: a -> TagGetter b -> TagGetter a #

Applicative TagGetter # 

Methods

pure :: a -> TagGetter a #

(<*>) :: TagGetter (a -> b) -> TagGetter a -> TagGetter b #

(*>) :: TagGetter a -> TagGetter b -> TagGetter b #

(<*) :: TagGetter a -> TagGetter b -> TagGetter a #

data TagSetter #

A composable entity that can be used together with the setTags or the setTags' functions to write meta data to an audio file.

Note that in case of (for example):

titleSetter "foo" <> titleSetter "bar"

The first value wins.

data HTagLibException #

The data type represents exceptions specific to the library.

Constructors

OpeningFailed FilePath

Attempt to open audio file to read its tags failed

InvalidFile FilePath

File can be opened, but it doesn't contain any information that can be interpreted by the library

SavingFailed FilePath

Saving failed