, BlockHeader(..)
, BlockFlags(..)
- , findNextBlock
+ , readBlocks
)
where
import Codec.Audio.WavPack.Metadata
decodeSamplingRate 0x0E = S.Just 192000
decodeSamplingRate _ = S.Nothing
--- | Find a WavPack block in a given stream. Returns 'S.Nothing' if no
--- blocks are found.
-findNextBlock ∷ L.ByteString -- ^ the input
- → (# S.Maybe Block, L.ByteString #) -- ^ the rest of input
+-- | Read WavPack blocks in a given stream lazily.
+readBlocks ∷ L.ByteString → [Block]
+readBlocks src
+ = case findNextBlock src of
+ (# S.Just block, src' #)
+ → block : readBlocks src'
+ (# S.Nothing, _ #)
+ → []
+
+findNextBlock ∷ L.ByteString
+ → (# S.Maybe Block, L.ByteString #)
findNextBlock src
= case L.uncons src of
Nothing