X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=wavpack.git;a=blobdiff_plain;f=examples%2FWvInfo.hs;fp=examples%2FWvInfo.hs;h=75c13ab3076510fefdb241e96c152d6fb3be79ab;hp=5e0b86fbe62bdbd020e6dc76bbbbcf78752808a3;hb=fda0a74785ab6da03f98be513de5cd3bada1359d;hpb=fc5bbbe214bd5b31684fd54f9e7e70557bf872ef diff --git a/examples/WvInfo.hs b/examples/WvInfo.hs index 5e0b86f..75c13ab 100644 --- a/examples/WvInfo.hs +++ b/examples/WvInfo.hs @@ -4,21 +4,41 @@ #-} module Main where import Codec.Audio.WavPack.Block +import Codec.Audio.WavPack.Metadata import qualified Data.ByteString.Lazy as L import qualified Data.Strict as S +import Data.Maybe +import Prelude.Unicode import System.Environment import System.IO main ∷ IO () main = do [wvFile] ← getArgs - wvStream ← L.readFile wvFile + wvData ← L.readFile wvFile hSetBuffering stdout NoBuffering - showWvInfo wvStream + showWvInfo wvData showWvInfo ∷ L.ByteString → IO () showWvInfo stream = case findNextBlock stream of (# S.Just block, _ #) - → print block + → printBlock block (# S.Nothing , _ #) → fail "Can't find any WavPack block headers." + +printBlock ∷ Block → IO () +printBlock b + = do putStrLn "- Block header:" + print $ blockHeader b + putStrLn "- Block metadata sub-blocks:" + mapM_ printSub $ blockMetadata b + where + printSub ∷ SubBlock → IO () + printSub sub + | isJust (fromSubBlock sub ∷ Maybe WVBitstream) + = putStrLn ( "(WV Bitstream omitted: " ⧺ + show (metaSize sub) ⧺ + " bytes)" + ) + | otherwise + = print sub