From: PHO Date: Tue, 4 Jan 2011 15:03:55 +0000 (+0900) Subject: sampling rate table X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=wavpack.git;a=commitdiff_plain;h=f88b290bd0007530011da6741fdbaccfcc6577d9 sampling rate table --- diff --git a/Codec/Audio/WavPack/Block.hs b/Codec/Audio/WavPack/Block.hs index 8e46be8..0ca454a 100644 --- a/Codec/Audio/WavPack/Block.hs +++ b/Codec/Audio/WavPack/Block.hs @@ -121,7 +121,7 @@ data BlockFlags -- require minus 1) , bfMaxMagnitude ∷ !Word8 -- | sampling rate (0x1111 = unknown/custom) (THINKME) - , bfSamplingRate ∷ !Word8 + , bfSamplingRate ∷ !(Maybe Int) -- | 'True' = use IIR for negative hybrid noise shaping , bfIIRShaping ∷ !Bool -- | 'True' = false stereo (data is mono but output is stereo) @@ -136,7 +136,7 @@ instance Binary BlockFlags where putBit $ bfFalseStereo bf putBit $ bfIIRShaping bf putNBits 2 (0 ∷ Word8) -- reserved - putNBits 4 $ bfSamplingRate bf + putNBits 4 $ encodeSamplingRate $ bfSamplingRate bf putNBits 5 $ bfMaxMagnitude bf putNBits 5 $ bfLeftShift bf putBit $ bfFinalBlock bf @@ -192,12 +192,48 @@ instance Binary BlockFlags where , bfFinalBlock = finalBlock , bfLeftShift = leftShift , bfMaxMagnitude = maxMagnitude - , bfSamplingRate = samplingRate + , bfSamplingRate = decodeSamplingRate samplingRate , bfIIRShaping = iirShaping , bfFalseStereo = falseStereo } return bf +encodeSamplingRate ∷ Maybe Int → Word8 +encodeSamplingRate (Just 6000) = 0x00 +encodeSamplingRate (Just 8000) = 0x01 +encodeSamplingRate (Just 9600) = 0x02 +encodeSamplingRate (Just 11025) = 0x03 +encodeSamplingRate (Just 12000) = 0x04 +encodeSamplingRate (Just 16000) = 0x05 +encodeSamplingRate (Just 22050) = 0x06 +encodeSamplingRate (Just 24000) = 0x07 +encodeSamplingRate (Just 32000) = 0x08 +encodeSamplingRate (Just 44100) = 0x09 +encodeSamplingRate (Just 48000) = 0x0A +encodeSamplingRate (Just 64000) = 0x0B +encodeSamplingRate (Just 88200) = 0x0C +encodeSamplingRate (Just 96000) = 0x0D +encodeSamplingRate (Just 192000) = 0x0E +encodeSamplingRate _ = 0x0F + +decodeSamplingRate ∷ Word8 → Maybe Int +decodeSamplingRate 0x00 = Just 6000 +decodeSamplingRate 0x01 = Just 8000 +decodeSamplingRate 0x02 = Just 9600 +decodeSamplingRate 0x03 = Just 11025 +decodeSamplingRate 0x04 = Just 12000 +decodeSamplingRate 0x05 = Just 16000 +decodeSamplingRate 0x06 = Just 22025 +decodeSamplingRate 0x07 = Just 24000 +decodeSamplingRate 0x08 = Just 32000 +decodeSamplingRate 0x09 = Just 44100 +decodeSamplingRate 0x0A = Just 48000 +decodeSamplingRate 0x0B = Just 64000 +decodeSamplingRate 0x0C = Just 88200 +decodeSamplingRate 0x0D = Just 96000 +decodeSamplingRate 0x0E = Just 192000 +decodeSamplingRate _ = Nothing + findNextHeader ∷ L.ByteString → (Maybe BlockHeader, L.ByteString) findNextHeader src = case L.uncons src of diff --git a/GNUmakefile b/GNUmakefile index 8ec5f1e..436771c 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,5 +1,5 @@ RUN_COMMAND = ./dist/build/hs-wvinfo/hs-wvinfo 01.wv -CONFIGURE_ARGS = -O -fbuild-examples +CONFIGURE_ARGS = -O0 -fbuild-examples include cabal-package.mk