From: PHO Date: Mon, 3 Jan 2011 03:25:34 +0000 (+0900) Subject: BlockHeader X-Git-Url: https://git.cielonegro.org/gitweb.cgi?a=commitdiff_plain;h=e1c40f16ebdddf304dd7b96f0d160e512aeaf93f;p=wavpack.git BlockHeader --- diff --git a/.gitignore b/.gitignore index f76a6e2..15068eb 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ Setup dist + +01.wv diff --git a/Codec/Audio/WavPack/Types.hs b/Codec/Audio/WavPack/Types.hs new file mode 100644 index 0000000..2e1446a --- /dev/null +++ b/Codec/Audio/WavPack/Types.hs @@ -0,0 +1,81 @@ +{-# 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; +-} diff --git a/wavpack.cabal b/wavpack.cabal index bd32cfe..239e4e9 100644 --- a/wavpack.cabal +++ b/wavpack.cabal @@ -24,10 +24,12 @@ Library Build-Depends: base == 4.*, base-unicode-symbols == 0.2.*, - binary == 0.5.* + binary == 0.5.*, + bytestring == 0.9.* Exposed-Modules: Codec.Audio.WavPack + Codec.Audio.WavPack.Types GHC-Options: -Wall