--- /dev/null
+{-# LANGUAGE
+ UnicodeSyntax
+ #-}
+module Codec.Audio.WavPack.Types
+ ( BlockHeader(..)
+ )
+ where
+import Data.Binary
+import Data.Binary.Get
+import Data.Binary.Put
+
+data BlockHeader
+ = BlockHeader {
+ bhSize ∷ !Word32
+ , bhVersion ∷ !Word16
+ , bhTrackNo ∷ !Word8
+ , bhIndexNo ∷ !Word8
+ , bhTotalSamples ∷ !Word32
+ , bhBlockIndex ∷ !Word32
+ , bhBlockSamples ∷ !Word32
+ , bhFlags ∷ !Word32
+ , bhCRC ∷ !Word32
+ }
+ deriving (Show, Eq)
+
+instance Binary BlockHeader where
+ put bh
+ = do putWord8 119 -- 'w'
+ putWord8 118 -- 'v'
+ putWord8 112 -- 'p'
+ putWord8 107 -- 'k'
+ putWord32le $ bhSize bh
+ putWord16le $ bhVersion bh
+ putWord8 $ bhTrackNo bh
+ putWord8 $ bhIndexNo bh
+ putWord32le $ bhTotalSamples bh
+ putWord32le $ bhBlockIndex bh
+ putWord32le $ bhBlockSamples bh
+ putWord32le $ bhFlags bh
+ putWord32le $ bhCRC bh
+
+ get = do skip 4 -- "wvpk"
+ size ← getWord32le
+ version ← getWord16le
+ trackNo ← getWord8
+ indexNo ← getWord8
+ totalSamples ← getWord32le
+ blockIndex ← getWord32le
+ blockSamples ← getWord32le
+ flags ← getWord32le
+ crc ← getWord32le
+ return BlockHeader {
+ bhSize = size
+ , bhVersion = version
+ , bhTrackNo = trackNo
+ , bhIndexNo = indexNo
+ , bhTotalSamples = totalSamples
+ , bhBlockIndex = blockIndex
+ , bhBlockSamples = blockSamples
+ , bhFlags = flags
+ , bhCRC = crc
+ }
+
+{-
+typedef struct {
+ char ckID [4]; // "wvpk"
+ uint32_t ckSize; // size of entire block (minus 8, of course)
+ uint16_t version; // 0x402 to 0x410 are currently valid for decode
+ uchar track_no; // track number (0 if not used, like now)
+ uchar index_no; // track sub-index (0 if not used, like now)
+ uint32_t total_samples; // total samples for entire file, but this is
+ // only valid if block_index == 0 and a value of
+ // -1 indicates unknown length
+ uint32_t block_index; // index of first sample in block relative to
+ // beginning of file (normally this would start
+ // at 0 for the first block)
+ uint32_t block_samples; // number of samples in this block (0 = no audio)
+ uint32_t flags; // various flags for id and decoding
+ uint32_t crc; // crc for actual decoded data
+} WavpackHeader;
+-}