Portability | unknown |
---|---|
Stability | unstable |
Maintainer | Conrad Parker <conrad@metadecks.org> |
This module re-exports the required interfaces and some useful functions for developing zoom-cache codecs.
To implement a codec, specify SummaryData
and SummaryWork
types, and
implement the methods of the ZoomReadable and ZoomWritable classes.
For sample implementations, read the source of the provided instances Data.ZoomCache.Int and Data.ZoomCache.Double.
- class ZoomReadable a where
- data SummaryData a :: *
- readRaw :: (Functor m, MonadIO m) => Iteratee [Word8] m a
- readSummary :: (Functor m, MonadIO m) => Iteratee [Word8] m (SummaryData a)
- prettyRaw :: a -> String
- prettySummaryData :: SummaryData a -> String
- class ZoomWritable a where
- data SummaryWork a :: *
- fromRaw :: a -> Builder
- fromSummaryData :: SummaryData a -> Builder
- initSummaryWork :: TimeStamp -> SummaryWork a
- updateSummaryData :: Int -> TimeStamp -> a -> SummaryWork a -> SummaryWork a
- toSummaryData :: Double -> SummaryWork a -> SummaryData a
- appendSummaryData :: Double -> SummaryData a -> Double -> SummaryData a -> SummaryData a
- class ZoomWrite t where
- readInt16be :: (Functor m, MonadIO m) => Iteratee [Word8] m Int
- readInt32be :: (Functor m, MonadIO m) => Iteratee [Word8] m Int
- readInt64be :: (Functor m, MonadIO m, Integral a) => Iteratee [Word8] m a
- readDouble64be :: (Functor m, MonadIO m) => Iteratee [Word8] m Double
- readRational64be :: (Functor m, MonadIO m) => Iteratee [Word8] m Rational
- writeData :: (Typeable a, ZoomWrite a, ZoomWritable a) => TrackNo -> a -> ZoomW ()
- writeDataVBR :: (Typeable a, ZoomWrite a, ZoomWritable a) => TrackNo -> (TimeStamp, a) -> ZoomW ()
- fromRational64 :: Rational -> Builder
- fromIntegral32be :: forall a. Integral a => a -> Builder
- fromDouble :: Double -> Builder
- data TimeStamp = TS {}
Required interfaces
class ZoomReadable a whereSource
A codec instance must specify a SummaryData
type,
and implement all methods of this class.
data SummaryData a :: *Source
readRaw :: (Functor m, MonadIO m) => Iteratee [Word8] m aSource
An iteratee to read one value of type a
from a stream of '[Word8]'.
readSummary :: (Functor m, MonadIO m) => Iteratee [Word8] m (SummaryData a)Source
An iteratee to read one value of type 'SummaryData a' from a stream of '[Word8]'.
prettyRaw :: a -> StringSource
Pretty printing, used for dumping values of type a
.
prettySummaryData :: SummaryData a -> StringSource
Pretty printing for values of type 'SummaryData a'.
class ZoomWritable a whereSource
A codec instance must additionally specify a SummaryWork
type
data SummaryWork a :: *Source
Intermediate calculations
Serialize a value of type a
fromSummaryData :: SummaryData a -> BuilderSource
Serialize a 'SummaryData a'
initSummaryWork :: TimeStamp -> SummaryWork aSource
Generate a new 'SummaryWork a', given an initial timestamp.
updateSummaryData :: Int -> TimeStamp -> a -> SummaryWork a -> SummaryWork aSource
Update a SummaryData
with the value of a
occuring at the
given TimeStamp
.
toSummaryData :: Double -> SummaryWork a -> SummaryData aSource
Finalize a 'SummaryWork a', generating a 'SummaryData a'.
appendSummaryData :: Double -> SummaryData a -> Double -> SummaryData a -> SummaryData aSource
Append two SummaryData
The ZoomWrite class provides write
, a method to write a
Haskell value to an open ZoomCache file.
Raw data reading iteratees
readInt16be :: (Functor m, MonadIO m) => Iteratee [Word8] m IntSource
Read 2 bytes as a big-endian Int.
readInt32be :: (Functor m, MonadIO m) => Iteratee [Word8] m IntSource
Read 4 bytes as a big-endian Int.
readInt64be :: (Functor m, MonadIO m, Integral a) => Iteratee [Word8] m aSource
Read 8 bytes as a big-endian Integer
readDouble64be :: (Functor m, MonadIO m) => Iteratee [Word8] m DoubleSource
Read 8 bytes as a big-endian Double
readRational64be :: (Functor m, MonadIO m) => Iteratee [Word8] m RationalSource
Read 16 bytes as a big-endian Rational, encoded as an 8 byte big endian numerator followed by an 8 byte big endian denominator.
ZoomWrite instance helpers
writeDataVBR :: (Typeable a, ZoomWrite a, ZoomWritable a) => TrackNo -> (TimeStamp, a) -> ZoomW ()Source
Builders
fromRational64 :: Rational -> BuilderSource
Serialize a Rational
as a sequence of two 64bit big endian format
integers.
fromIntegral32be :: forall a. Integral a => a -> BuilderSource
Serialize an Integral
in 32bit big endian format.
fromDouble :: Double -> BuilderSource
Serialize a Double
in big-endian IEEE 754-2008 binary64 format
(IEEE 754-1985 double format).