X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=wavpack.git;a=blobdiff_plain;f=Codec%2FAudio%2FWavPack%2FMetadata.hs;h=fcd873b5776ef17f7ad1767e1328848a0a978ad6;hp=09bceb873927fdc0c8da3fd7a34cd45d41f2792e;hb=e7d7bed418f63de393b316b2b4246f44752b5743;hpb=fc5bbbe214bd5b31684fd54f9e7e70557bf872ef diff --git a/Codec/Audio/WavPack/Metadata.hs b/Codec/Audio/WavPack/Metadata.hs index 09bceb8..fcd873b 100644 --- a/Codec/Audio/WavPack/Metadata.hs +++ b/Codec/Audio/WavPack/Metadata.hs @@ -13,12 +13,14 @@ module Codec.Audio.WavPack.Metadata , DecorrWeights(..) , DecorrSamples(..) , EntropyVars(..) + , WVBitstream(..) , RIFFHeader(..) , RIFFTrailer(..) , ConfigInfo(..) , Unknown(..) ) where +import qualified Codec.Audio.WavPack.BitString as B import Codec.Audio.WavPack.Internal import Control.Monad import Data.Binary @@ -105,6 +107,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 +130,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 +272,31 @@ instance Binary EntropyVars where med2 ← fmap exp2 getWord16le return (med0, med1, med2) +-- | WV Bitstream +data WVBitstream + = WVBitstream { + wvStream ∷ !B.BitString + } + deriving (Eq, Show, Typeable) + +instance Metadata WVBitstream where + metaID _ = 0x0A + metaSize = (`div` 8) ∘ B.length ∘ wvStream + +instance Binary WVBitstream where + put = putLazyByteString ∘ B.toByteString ∘ wvStream + get = fmap (WVBitstream ∘ B.fromByteString) 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 +305,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