]> gitweb @ CieloNegro.org - wavpack.git/blobdiff - Codec/Audio/WavPack/Metadata.hs
WVBitstream
[wavpack.git] / Codec / Audio / WavPack / Metadata.hs
index 09bceb873927fdc0c8da3fd7a34cd45d41f2792e..def1cb3c422b14d085af14ed9568d5797117df74 100644 (file)
@@ -13,6 +13,7 @@ module Codec.Audio.WavPack.Metadata
     , DecorrWeights(..)
     , DecorrSamples(..)
     , EntropyVars(..)
+    , WVBitstream(..)
     , RIFFHeader(..)
     , RIFFTrailer(..)
     , ConfigInfo(..)
@@ -105,6 +106,7 @@ instance Binary SubBlock where
           getSubBlock 0x03 = fmap SubBlock (get ∷ Get DecorrWeights)
           getSubBlock 0x04 = fmap SubBlock (get ∷ Get DecorrSamples)
           getSubBlock 0x05 = fmap SubBlock (get ∷ Get EntropyVars  )
+          getSubBlock 0x0A = fmap SubBlock (get ∷ Get WVBitstream  )
           getSubBlock 0x21 = fmap SubBlock (get ∷ Get RIFFHeader   )
           getSubBlock 0x22 = fmap SubBlock (get ∷ Get RIFFTrailer  )
           getSubBlock 0x25 = fmap SubBlock (get ∷ Get ConfigInfo   )
@@ -127,7 +129,7 @@ data Dummy
     = Dummy {
         -- | Must be less than 2^25 bytes long due to the limitation
         -- of WavPack specification.
-        dumSize ∷ Word32
+        dumSize ∷ !Word32
       }
     deriving (Eq, Show, Typeable)
 
@@ -269,15 +271,31 @@ instance Binary EntropyVars where
                    med2 ← fmap exp2 getWord16le
                    return (med0, med1, med2)
 
+-- | WV Bitstream
+data WVBitstream
+    = WVBitstream {
+        wvStream ∷ !L.ByteString
+      }
+    deriving (Eq, Show, Typeable)
+
+instance Metadata WVBitstream where
+    metaID _ = 0x0A
+    metaSize = fromIntegral ∘ L.length ∘ wvStream
+
+instance Binary WVBitstream where
+    put = putLazyByteString ∘ wvStream
+    get = fmap WVBitstream getRemainingLazyByteString
+
 -- | RIFF header for .wav files (before audio)
 data RIFFHeader
     = RIFFHeader {
-        riffHeader ∷ L.ByteString
+        riffHeader ∷ !L.ByteString
       }
     deriving (Eq, Show, Typeable)
 
 instance Metadata RIFFHeader where
     metaID _ = 0x21
+    metaSize = fromIntegral ∘ L.length ∘ riffHeader
 
 instance Binary RIFFHeader where
     put = putLazyByteString ∘ riffHeader
@@ -286,12 +304,13 @@ instance Binary RIFFHeader where
 -- | RIFF trailer for .wav files (after audio)
 data RIFFTrailer
     = RIFFTrailer {
-        riffTrailer ∷ L.ByteString
+        riffTrailer ∷ !L.ByteString
       }
     deriving (Eq, Show, Typeable)
 
 instance Metadata RIFFTrailer where
     metaID _ = 0x22
+    metaSize = fromIntegral ∘ L.length ∘ riffTrailer
 
 instance Binary RIFFTrailer where
     put = putLazyByteString ∘ riffTrailer