4 -- | Data types for WavPack codec.
5 module Codec.Audio.WavPack.Types
10 import Data.Binary.Get
11 import Data.Binary.Put
13 -- | The preamble to every block in both the .wv and .wvc files.
16 -- | size of entire block (minus 8, of course)
18 -- | 0x402 to 0x410 are currently valid for decode
20 -- | track number (0 if not used, like now)
22 -- | track sub-index (0 if not used, like now)
24 -- | total samples for entire file, but this is only valid if
25 -- 'bhBlockIndex' == 0 and a value of -1 indicates unknown length
26 , bhTotalSamples ∷ !Word32
27 -- | index of first sample in block relative to beginning of
28 -- file (normally this would start at 0 for the first block)
29 , bhBlockIndex ∷ !Word32
30 -- | number of samples in this block (0 = no audio)
31 , bhBlockSamples ∷ !Word32
32 -- | various flags for id and decoding
34 -- | crc for actual decoded data
39 instance Binary BlockHeader where
41 = do putWord8 119 -- 'w'
45 putWord32le $ bhSize bh
46 putWord16le $ bhVersion bh
47 putWord8 $ bhTrackNo bh
48 putWord8 $ bhIndexNo bh
49 putWord32le $ bhTotalSamples bh
50 putWord32le $ bhBlockIndex bh
51 putWord32le $ bhBlockSamples bh
52 putWord32le $ bhFlags bh
53 putWord32le $ bhCRC bh
55 get = do skip 4 -- "wvpk"
60 totalSamples ← getWord32le
61 blockIndex ← getWord32le
62 blockSamples ← getWord32le
70 , bhTotalSamples = totalSamples
71 , bhBlockIndex = blockIndex
72 , bhBlockSamples = blockSamples