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

Copyright© 2015 Mark Karpov
LicenseBSD 3 clause
MaintainerMark Karpov <markkarpov@opmbx.org>
Stabilityexperimental
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Sound.HTagLib

Contents

Description

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

Synopsis

Data types

mkTitle :: String -> Title Source

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

mkArtist :: String -> Artist Source

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

mkAlbum :: String -> Album Source

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

mkComment :: String -> Comment Source

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

mkGenre :: String -> Genre Source

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

data Year Source

Year tag.

mkYear :: Int -> Maybe Year Source

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

getYear :: 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.

mkDuration :: Int -> Maybe Duration Source

Construction of Duration values, negative values result in Nothing.

data BitRate Source

Bit rate in kb/s.

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.

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 rather than relying on TagLib ability to guess type of file from its extension.

data ID3v2Encoding Source

Encoding for ID3v2 frames that are written to tags.

data HTagLibException Source

The data type represents exceptions specific to the library. The following constructors are defined:

  • OpeningFailed means that attempt to open audio file to read its tags failed.
  • InvalidFile means that file can be opened, but it doesn't contain any information that can be interpreted by the library.
  • SavingFailed is thrown when well… saving failed.

Getters

data TagGetter a Source

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

getTags Source

Arguments

:: FilePath

Path to audio file

-> TagGetter a

Getter

-> IO 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 file type, see getTags' variation of this function.

In case of trouble HTagLibException will be thrown.

getTags' Source

Arguments

:: FilePath

Path to audio file

-> FileType

Type of audio file

-> TagGetter a

Getter

-> IO 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

data TagSetter Source

Composable entity that can be used together with setTags or setTags' to write meta data to audio file.

setTags Source

Arguments

:: FilePath

Path to audio file

-> Maybe ID3v2Encoding

Encoding for ID3v2 frames

-> TagSetter

Setter

-> IO () 

Set tags in specified file using given setter.

In case of trouble HTagLibException will be thrown.

setTags' Source

Arguments

:: FilePath

Path to audio file

-> Maybe ID3v2Encoding

Encoding for ID3v2 frames

-> FileType

Type of audio file

-> TagSetter

Setter

-> IO () 

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.