| Copyright | © 2017 Mark Karpov |
|---|---|
| License | BSD 3 clause |
| Maintainer | Mark Karpov <markkarpov92@gmail.com> |
| Stability | experimental |
| Portability | portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Codec.Audio.LAME
Description
The module provides an interface to LAME MP3 encoder. All you need to do
to encode a WAVE (or RF64) file is to call encodeMp3, which see.
Synopsis
- encodeMp3 :: MonadIO m => EncoderSettings -> FilePath -> FilePath -> m ()
- data EncoderSettings = EncoderSettings {
- encoderCompression :: !Compression
- encoderQuality :: !(Maybe Word)
- encoderNoGap :: !(Maybe (Word32, Word32))
- encoderErrorProtection :: !Bool
- encoderStrictISO :: !Bool
- encoderSampleRate :: !(Maybe Word32)
- encoderScale :: !Float
- encoderFreeFormat :: !Bool
- encoderCopyright :: !Bool
- encoderOriginal :: !Bool
- encoderWriteVbrTag :: !Bool
- encoderMetadataPlacement :: !MetadataPlacement
- encoderTagTitle :: !(Maybe Text)
- encoderTagArtist :: !(Maybe Text)
- encoderTagAlbum :: !(Maybe Text)
- encoderTagYear :: !(Maybe Text)
- encoderTagComment :: !(Maybe Text)
- encoderTagTrack :: !(Maybe (Word8, Maybe Word8))
- encoderTagGenre :: !(Maybe Text)
- encoderAlbumArt :: !(Maybe ByteString)
- encoderLowpassFilter :: !FilterSetup
- encoderHighpassFilter :: !FilterSetup
- data Compression
- data VbrMode
- data MetadataPlacement
- data FilterSetup
- data LameException
Documentation
Arguments
| :: MonadIO m | |
| => EncoderSettings | Encoder settings |
| -> FilePath | WAVE file to encode |
| -> FilePath | Where to save the resulting MP3 file |
| -> m () |
Encode a WAVE file or RF64 file to MP3.
If the input file is not a valid WAVE file, WaveException will be
thrown. LameException is thrown when underlying LAME encoder reports
a problem.
Not all sample formats and bit depth are currently supported. Supported sample formats include:
- PCM with samples represented as signed integers > 8 bit and <= 16 bit per mono-sample.
- IEEE floating point (32 bit) samples.
- IEEE floating point (64 bit) samples.
If you feed the encoder with something else, expect
LameUnsupportedSampleFormat to be thrown.
data EncoderSettings #
LAME encoder settings.
Currently some noise-shaping and psycho-acoustic parameters are omitted, but can be added on request.
Constructors
| EncoderSettings | |
Fields
| |
Instances
data Compression #
The data type represents supported options for compression. You can specify either fixed bitrate, compression ratio, or use the VBR mode.
Constructors
| CompressionBitrate Word | Specify compression by setting a fixed bitrate, e.g.
|
| CompressionRatio Float | Specify compression ratio. |
| CompressionVBR VbrMode Word | VBR. Here you can specify which mode to use and the second argument is VBR quality from 0 (highest), to 9 (lowest). Good default is 4. |
Instances
| Eq Compression # | |
Defined in Codec.Audio.LAME | |
| Ord Compression # | |
Defined in Codec.Audio.LAME Methods compare :: Compression -> Compression -> Ordering # (<) :: Compression -> Compression -> Bool # (<=) :: Compression -> Compression -> Bool # (>) :: Compression -> Compression -> Bool # (>=) :: Compression -> Compression -> Bool # max :: Compression -> Compression -> Compression # min :: Compression -> Compression -> Compression # | |
| Read Compression # | |
Defined in Codec.Audio.LAME Methods readsPrec :: Int -> ReadS Compression # readList :: ReadS [Compression] # readPrec :: ReadPrec Compression # readListPrec :: ReadPrec [Compression] # | |
| Show Compression # | |
Defined in Codec.Audio.LAME Methods showsPrec :: Int -> Compression -> ShowS # show :: Compression -> String # showList :: [Compression] -> ShowS # | |
Variable bitrate (VBR) modes with their associated parameters.
Constructors
| VbrRh | VBR RH. |
| VbrAbr (Maybe Word) (Maybe Word) (Maybe Word) Bool | VBR ABR. Parameters of the data constructor in order:
|
| VbrMtrh | VBR MTRH |
data MetadataPlacement #
Which container to use to write tags/metadata.
Constructors
| Id3v1Only | Only write ID3v1 metadata |
| Id3v2Only | Only write ID3v2 metadata |
| Id3Both | Write ID3v1 and ID3v2 |
Instances
| Eq MetadataPlacement # | |
Defined in Codec.Audio.LAME Methods (==) :: MetadataPlacement -> MetadataPlacement -> Bool # (/=) :: MetadataPlacement -> MetadataPlacement -> Bool # | |
| Ord MetadataPlacement # | |
Defined in Codec.Audio.LAME Methods compare :: MetadataPlacement -> MetadataPlacement -> Ordering # (<) :: MetadataPlacement -> MetadataPlacement -> Bool # (<=) :: MetadataPlacement -> MetadataPlacement -> Bool # (>) :: MetadataPlacement -> MetadataPlacement -> Bool # (>=) :: MetadataPlacement -> MetadataPlacement -> Bool # max :: MetadataPlacement -> MetadataPlacement -> MetadataPlacement # min :: MetadataPlacement -> MetadataPlacement -> MetadataPlacement # | |
| Read MetadataPlacement # | |
Defined in Codec.Audio.LAME Methods readsPrec :: Int -> ReadS MetadataPlacement # readList :: ReadS [MetadataPlacement] # | |
| Show MetadataPlacement # | |
Defined in Codec.Audio.LAME Methods showsPrec :: Int -> MetadataPlacement -> ShowS # show :: MetadataPlacement -> String # showList :: [MetadataPlacement] -> ShowS # | |
data FilterSetup #
Settings for a filter.
Constructors
| FilterAuto | Filter settings are chosen automatically |
| FilterDisabled | Filter is disabled |
| FilterManual Word (Maybe Word) | The first parameter is the filter's frequency (cut-off frequency)
in Hz and the second parameter is width of transition band in Hz (if
|
Instances
| Eq FilterSetup # | |
Defined in Codec.Audio.LAME | |
| Ord FilterSetup # | |
Defined in Codec.Audio.LAME Methods compare :: FilterSetup -> FilterSetup -> Ordering # (<) :: FilterSetup -> FilterSetup -> Bool # (<=) :: FilterSetup -> FilterSetup -> Bool # (>) :: FilterSetup -> FilterSetup -> Bool # (>=) :: FilterSetup -> FilterSetup -> Bool # max :: FilterSetup -> FilterSetup -> FilterSetup # min :: FilterSetup -> FilterSetup -> FilterSetup # | |
| Read FilterSetup # | |
Defined in Codec.Audio.LAME Methods readsPrec :: Int -> ReadS FilterSetup # readList :: ReadS [FilterSetup] # readPrec :: ReadPrec FilterSetup # readListPrec :: ReadPrec [FilterSetup] # | |
| Show FilterSetup # | |
Defined in Codec.Audio.LAME Methods showsPrec :: Int -> FilterSetup -> ShowS # show :: FilterSetup -> String # showList :: [FilterSetup] -> ShowS # | |
data LameException #
Enumeration of problems you can have with LAME.
Constructors
| LameGenericError | A “generic error” happened |
| LameNoMemory | Memory allocation issue |
| LameBadBitrate | Unsupported bitrate |
| LameBadSampleFreq | Unsupported sample rate |
| LameInternalError | An “Internal error” happened |
| LameInvalidTrackNumber Word8 (Maybe Word8) | Invalid track number (first argument) or total number of tracks (second argument) was supplied |
| LameUnsupportedSampleFormat SampleFormat | This sample format is not supported at this time |
Instances
| Eq LameException # | |
Defined in Codec.Audio.LAME.Internal Methods (==) :: LameException -> LameException -> Bool # (/=) :: LameException -> LameException -> Bool # | |
| Read LameException # | |
Defined in Codec.Audio.LAME.Internal Methods readsPrec :: Int -> ReadS LameException # readList :: ReadS [LameException] # | |
| Show LameException # | |
Defined in Codec.Audio.LAME.Internal Methods showsPrec :: Int -> LameException -> ShowS # show :: LameException -> String # showList :: [LameException] -> ShowS # | |
| Exception LameException # | |
Defined in Codec.Audio.LAME.Internal Methods toException :: LameException -> SomeException # fromException :: SomeException -> Maybe LameException # displayException :: LameException -> String # | |