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

Copyright© 2015–2018 Mark Karpov
LicenseBSD 3 clause
MaintainerMark Karpov <[email protected]>
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 Source #

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' Source #

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 Source #

Getter to retrieve track title.

artistGetter :: TagGetter Artist Source #

Getter to retrieve track artist.

albumGetter :: TagGetter Album Source #

Getter to retrieve track album.

commentGetter :: TagGetter Comment Source #

Getter to retrieve track comment.

genreGetter :: TagGetter Genre Source #

Getter to retrieve genre of the track.

yearGetter :: TagGetter (Maybe Year) Source #

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

trackNumberGetter :: TagGetter (Maybe TrackNumber) Source #

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

durationGetter :: TagGetter Duration Source #

Getter to retrieve duration in seconds.

bitRateGetter :: TagGetter BitRate Source #

Getter to retrieve bit rate.

sampleRateGetter :: TagGetter SampleRate Source #

Getter to retrieve sample rate.

channelsGetter :: TagGetter Channels Source #

Getter to retrieve number of channels in audio data.

Setters

setTags Source #

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' Source #

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 Source #

Setter for track title.

artistSetter :: Artist -> TagSetter Source #

Setter for track artist.

albumSetter :: Album -> TagSetter Source #

Setter for track album.

commentSetter :: Comment -> TagSetter Source #

Setter for track comment.

genreSetter :: Genre -> TagSetter Source #

Setter for track genre.

yearSetter :: Maybe Year -> TagSetter Source #

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

trackNumberSetter :: Maybe TrackNumber -> TagSetter Source #

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

Data types

data Title Source #

Title tag.

Instances
Eq Title Source # 
Instance details

Defined in Sound.HTagLib.Type

Methods

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

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

Ord Title Source # 
Instance details

Defined in Sound.HTagLib.Type

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 Source # 
Instance details

Defined in Sound.HTagLib.Type

Methods

showsPrec :: Int -> Title -> ShowS #

show :: Title -> String #

showList :: [Title] -> ShowS #

IsString Title Source # 
Instance details

Defined in Sound.HTagLib.Type

Methods

fromString :: String -> Title #

mkTitle :: Text -> Title Source #

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

unTitle :: Title -> Text Source #

Convert Title to Text.

data Artist Source #

Artist tag.

Instances
Eq Artist Source # 
Instance details

Defined in Sound.HTagLib.Type

Methods

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

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

Ord Artist Source # 
Instance details

Defined in Sound.HTagLib.Type

Show Artist Source # 
Instance details

Defined in Sound.HTagLib.Type

IsString Artist Source # 
Instance details

Defined in Sound.HTagLib.Type

Methods

fromString :: String -> Artist #

mkArtist :: Text -> Artist Source #

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

data Album Source #

Album tag.

Instances
Eq Album Source # 
Instance details

Defined in Sound.HTagLib.Type

Methods

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

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

Ord Album Source # 
Instance details

Defined in Sound.HTagLib.Type

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 Source # 
Instance details

Defined in Sound.HTagLib.Type

Methods

showsPrec :: Int -> Album -> ShowS #

show :: Album -> String #

showList :: [Album] -> ShowS #

IsString Album Source # 
Instance details

Defined in Sound.HTagLib.Type

Methods

fromString :: String -> Album #

mkAlbum :: Text -> Album Source #

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

unAlbum :: Album -> Text Source #

Convert Album to Text.

data Comment Source #

Comment tag.

Instances
Eq Comment Source # 
Instance details

Defined in Sound.HTagLib.Type

Methods

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

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

Ord Comment Source # 
Instance details

Defined in Sound.HTagLib.Type

Show Comment Source # 
Instance details

Defined in Sound.HTagLib.Type

IsString Comment Source # 
Instance details

Defined in Sound.HTagLib.Type

Methods

fromString :: String -> Comment #

mkComment :: Text -> Comment Source #

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

data Genre Source #

Genre tag.

Instances
Eq Genre Source # 
Instance details

Defined in Sound.HTagLib.Type

Methods

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

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

Ord Genre Source # 
Instance details

Defined in Sound.HTagLib.Type

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 Source # 
Instance details

Defined in Sound.HTagLib.Type

Methods

showsPrec :: Int -> Genre -> ShowS #

show :: Genre -> String #

showList :: [Genre] -> ShowS #

IsString Genre Source # 
Instance details

Defined in Sound.HTagLib.Type

Methods

fromString :: String -> Genre #

mkGenre :: Text -> Genre Source #

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

unGenre :: Genre -> Text Source #

Convert Genre to Text.

data Year Source #

Year tag.

Instances
Eq Year Source # 
Instance details

Defined in Sound.HTagLib.Type

Methods

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

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

Ord Year Source # 
Instance details

Defined in Sound.HTagLib.Type

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 Source # 
Instance details

Defined in Sound.HTagLib.Type

Methods

showsPrec :: Int -> Year -> ShowS #

show :: Year -> String #

showList :: [Year] -> ShowS #

mkYear :: Int -> Maybe Year Source #

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

unYear :: Year -> Int Source #

Convert Year to Int.

mkTrackNumber :: Int -> Maybe TrackNumber Source #

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

data Duration Source #

Duration in seconds.

Instances
Eq Duration Source # 
Instance details

Defined in Sound.HTagLib.Type

Ord Duration Source # 
Instance details

Defined in Sound.HTagLib.Type

Show Duration Source # 
Instance details

Defined in Sound.HTagLib.Type

mkDuration :: Int -> Maybe Duration Source #

Construction of Duration values, negative values result in Nothing.

data BitRate Source #

Bit rate in kb/s.

Instances
Eq BitRate Source # 
Instance details

Defined in Sound.HTagLib.Type

Methods

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

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

Ord BitRate Source # 
Instance details

Defined in Sound.HTagLib.Type

Show BitRate Source # 
Instance details

Defined in Sound.HTagLib.Type

mkBitRate :: Int -> Maybe BitRate Source #

Construction of BitRate values, negative values result in Nothing.

mkSampleRate :: Int -> Maybe SampleRate Source #

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

data Channels Source #

Number of channels in the audio stream.

Instances
Eq Channels Source # 
Instance details

Defined in Sound.HTagLib.Type

Ord Channels Source # 
Instance details

Defined in Sound.HTagLib.Type

Show Channels Source # 
Instance details

Defined in Sound.HTagLib.Type

mkChannels :: Int -> Maybe Channels Source #

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

data FileType Source #

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 Source #

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

Instances
Functor TagGetter Source # 
Instance details

Defined in Sound.HTagLib.Getter

Methods

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

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

Applicative TagGetter Source # 
Instance details

Defined in Sound.HTagLib.Getter

Methods

pure :: a -> TagGetter a #

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

liftA2 :: (a -> b -> c) -> TagGetter a -> TagGetter b -> TagGetter c #

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

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

data TagSetter Source #

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 Source #

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