Copyright | © 2016–2017 Mark Karpov |
---|---|
License | BSD 3 clause |
Maintainer | Mark Karpov <markkarpov92@gmail.com> |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
The module allows to construct, read, and write CUE sheets. The data
types are defined in such a way that incorrect CUE sheets are impossible
to represent. See parseCueSheet
for parsing of plain text CUE sheet
files and renderCueSheet
for rendering.
- data CueSheet = CueSheet {
- cueCatalog :: !(Maybe Mcn)
- cueCdTextFile :: !(Maybe FilePath)
- cuePerformer :: !(Maybe CueText)
- cueTitle :: !(Maybe CueText)
- cueSongwriter :: !(Maybe CueText)
- cueFirstTrackNumber :: !Natural
- cueFiles :: !(NonEmpty CueFile)
- data CueFile = CueFile {
- cueFileName :: !FilePath
- cueFileType :: !CueFileType
- cueFileTracks :: !(NonEmpty CueTrack)
- data CueFileType
- data CueTrack = CueTrack {
- cueTrackDigitalCopyPermitted :: !Bool
- cueTrackFourChannelAudio :: !Bool
- cueTrackPreemphasisEnabled :: !Bool
- cueTrackSerialCopyManagement :: !Bool
- cueTrackType :: !CueTrackType
- cueTrackIsrc :: !(Maybe Isrc)
- cueTrackTitle :: !(Maybe CueText)
- cueTrackPerformer :: !(Maybe CueText)
- cueTrackSongwriter :: !(Maybe CueText)
- cueTrackPregap :: !(Maybe CueTime)
- cueTrackPregapIndex :: !(Maybe CueTime)
- cueTrackIndices :: !(NonEmpty CueTime)
- cueTrackPostgap :: !(Maybe CueTime)
- data CueTrackType
- newtype CueTime = CueTime Natural
- fromMmSsFf :: MonadThrow m => Natural -> Natural -> Natural -> m CueTime
- toMmSsFf :: CueTime -> (Natural, Natural, Natural)
- showMmSsFf :: CueTime -> Text
- data Mcn
- mkMcn :: MonadThrow m => Text -> m Mcn
- unMcn :: Mcn -> Text
- data CueText
- mkCueText :: MonadThrow m => Text -> m CueText
- unCueText :: CueText -> Text
- data Isrc
- mkIsrc :: MonadThrow m => Text -> m Isrc
- unIsrc :: Isrc -> Text
- data CueSheetException
- parseCueSheet :: String -> ByteString -> Either (ParseError Char Eec) CueSheet
- data CueParserFailure
- data Eec = Eec (Maybe Natural) (Maybe CueParserFailure)
- renderCueSheet :: Bool -> CueSheet -> ByteString
Types
Entire CUE sheet, contains one or more files (see CueFile
).
CueSheet | |
|
A file to be written. Single file can be divided into one or more
tracks (see CueTrack
).
CueFile | |
|
data CueFileType Source #
Enumeration of audio or file's data types.
A track. Single track can have one or more indices.
CueTrack | |
|
data CueTrackType Source #
Track datatype.
CueTrackAudio | Audio/Music (2352). |
CueTrackCdg | Karaoke CD+G (2448). |
CueTrackMode1_2048 | CD-ROM Mode1 data (cooked). |
CueTrackMode1_2352 | CD-ROM Mode1 data (raw). |
CueTrackMode2_2336 | CD-ROM XA Mode2 data. |
CueTrackMode2_2352 | CD-ROM XA Mode2 data. |
CueTrackCdi2336 | CD-I Mode2 data. |
CueTrackCdi2352 | CD-I Mode2 data. |
This datatype is used to indicate duration and position in time. It contains number of frames. There are 75 frames in one second.
:: MonadThrow m | |
=> Natural | Number of minutes, no limit here |
-> Natural | Number of seconds, 0–59 inclusive |
-> Natural | Number of frames, 0–74 inclusive |
-> m CueTime | The result |
Construct CueTime
from minutes, seconds, and frames. There are 75
frames per second. If number of seconds or frames is invalid,
InvalidSeconds
or InvalidFrames
will be thrown.
toMmSsFf :: CueTime -> (Natural, Natural, Natural) Source #
Get minutes, seconds, and frames from a CueTime
value.
Disc's Media Catalog Number (MCN), must be 13 characters long, all the characters must be numeric.
A type for things like title or performer that should have length
between 1 and 80 characters as per spec. We also demand that it does not
contain "
and newline characters, as it's not clear from the spec how
to escape them properly.
mkCueText :: MonadThrow m => Text -> m CueText Source #
Make a CueText
. If the provided Text
value is not a valid CUE text,
throw the InvalidCueText
exception.
The track's International Standard Recording Code (ISRC). It must be 12 characters in length. The first five characters are alphanumeric, the last seven are numeric only.
mkIsrc :: MonadThrow m => Text -> m Isrc Source #
Make an Isrc
, if the provided Text
value is not a valid ISRC, throw
the InvalidIsrc
exception.
data CueSheetException Source #
Exception type for the bad things that may happen while you use the library.
InvalidSeconds Natural | The value is greater than 59 and thus is invalid for |
InvalidFrames Natural | The value is greater than 74 and thus is invalid for |
InvalidMcn Text | Provided text wasn't a correct media catalog number (MCN). |
InvalidCueText Text | Provided text wasn't a valid CUE text. |
InvalidIsrc Text | Provided text wasn't a valid ISRC. |
Parsing
:: String | File name to include in error messages |
-> ByteString | CUE sheet to parse as a lazy |
-> Either (ParseError Char Eec) CueSheet |
|
Parse a CUE sheet from a lazy ByteString
.
data CueParserFailure Source #
The enumeration of all failures that may happen during running of
parseCueSheet
.
CueParserFail String |
|
CueParserIndentation Ordering Pos Pos | Incorrect indentation (should not happen) |
CueParserInvalidCatalog Text | We ran into an invalid media catalog number |
CueParserInvalidCueText Text | We ran into an invalid text literal |
CueParserTrackOutOfOrder | We spotted a track out of order |
CueParserInvalidTrackIsrc Text | We ran into an invalid ISRC |
CueParserInvalidSeconds Natural | We ran into an invalid number of seconds |
CueParserInvalidFrames Natural | We ran into an invalid number of frames |
CueParserTrackIndexOutOfOrder | We spotted a track index out of order |
Extended error component with support for storing number of track declaration in which a parsing error has occurred.
Rendering
:: Bool | Use CRLF sequence as “end of line” separator |
-> CueSheet | The |
-> ByteString | The result |
Render a CUE sheet as a lazy ByteString
. All Text
values in the
CueSheet
will be UTF-8 encoded.