Copyright | © 2016–present Mark Karpov |
---|---|
License | BSD 3 clause |
Maintainer | Mark Karpov <markkarpov92@gmail.com> |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
The module allows us to construct, read, and write CUE sheets. The data
types are defined in such a way that incorrect CUE sheets cannot be
represented. See parseCueSheet
for parsing of plain text CUE sheet
files and renderCueSheet
for rendering.
Synopsis
- 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 (ParseErrorBundle ByteString Eec) CueSheet
- data CueParserFailure
- data Eec = Eec (Maybe Natural) CueParserFailure
- renderCueSheet :: Bool -> CueSheet -> ByteString
Types
CUE sheet, contains one or more files (see CueFile
).
CueSheet | |
|
Instances
A file to be written. Single file can be divided into one or more
tracks (see CueTrack
).
CueFile | |
|
Instances
Eq CueFile Source # | |
Ord CueFile Source # | |
Show CueFile Source # | |
Generic CueFile Source # | |
Arbitrary CueFile Source # | |
type Rep CueFile Source # | |
Defined in Text.CueSheet.Types type Rep CueFile = D1 ('MetaData "CueFile" "Text.CueSheet.Types" "cue-sheet-2.0.2-GGixdMe9eW2IdNm87otXvp" 'False) (C1 ('MetaCons "CueFile" 'PrefixI 'True) (S1 ('MetaSel ('Just "cueFileName") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 FilePath) :*: (S1 ('MetaSel ('Just "cueFileType") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 CueFileType) :*: S1 ('MetaSel ('Just "cueFileTracks") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (NonEmpty CueTrack))))) |
data CueFileType Source #
Enumeration of audio or file's data types.
Binary | Intel binary file (least significant byte first). Use for data files. |
Motorola | Motorola binary file (most significant file first). Use for data files. |
Aiff | Audio AIFF file (44.1 kHz, 16 bit stereo). |
Wave | Audio WAVE file (44.1 kHz, 16 bit stereo). |
MP3 | Audio MP3 file (44.1 kHz 16 bit stereo). |
Instances
A track. Single track can have one or more indices.
CueTrack | |
|
Instances
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. |
Instances
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. |
Instances
Parsing
:: String | File name to include in error messages |
-> ByteString | CUE sheet to parse as a lazy |
-> Either (ParseErrorBundle ByteString 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
.
CueParserTrivialError (Maybe (ErrorItem Word8)) (Set (ErrorItem Word8)) | A wrapper for a trivial error |
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 |
Instances
Extended error component with support for storing number of track declaration in which a parsing error has occurred.
Instances
Eq Eec Source # | |
Data Eec Source # | |
Defined in Text.CueSheet.Parser gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Eec -> c Eec # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Eec # dataTypeOf :: Eec -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Eec) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Eec) # gmapT :: (forall b. Data b => b -> b) -> Eec -> Eec # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Eec -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Eec -> r # gmapQ :: (forall d. Data d => d -> u) -> Eec -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Eec -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Eec -> m Eec # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Eec -> m Eec # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Eec -> m Eec # | |
Ord Eec Source # | |
Show Eec Source # | |
Generic Eec Source # | |
ShowErrorComponent Eec Source # | |
Defined in Text.CueSheet.Parser showErrorComponent :: Eec -> String # errorComponentLen :: Eec -> Int # | |
type Rep Eec Source # | |
Defined in Text.CueSheet.Parser type Rep Eec = D1 ('MetaData "Eec" "Text.CueSheet.Parser" "cue-sheet-2.0.2-GGixdMe9eW2IdNm87otXvp" 'False) (C1 ('MetaCons "Eec" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Natural)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CueParserFailure))) |
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.