packages feed

sndfile-enumerators 0.9.0 → 0.9.0.1

raw patch · 4 files changed

+46/−60 lines, 4 filesdep ~word24PVP ok

version bump matches the API change (PVP)

Dependency ranges changed: word24

API changes (from Hackage documentation)

Files

sndfile-enumerators.cabal view
@@ -1,5 +1,5 @@ Name:		sndfile-enumerators-Version:        0.9.0+Version:        0.9.0.1 Cabal-Version:  >= 1.2 Description:	encode and decode soundfiles using Iteratees.                 Audio files may be read or written, with classes and @@ -9,7 +9,7 @@ License-file:	LICENSE Author:		John W. Lato, jwlato@gmail.com Maintainer:	John W. Lato, jwlato@gmail.com-homepage:       http://jwlato.webfactional.com/haskell/sndfile-enumerators+homepage:       http://www.tiresiaspress.us/haskell/sndfile-enumerators Stability:	experimental synopsis:       Audio file reading/writing category:       Codec, Sound@@ -43,7 +43,7 @@    MonadCatchIO-transformers >= 0.2   && < 0.3,    transformers              >= 0.2   && < 0.3,    vector                    >= 0.6   && < 0.8,-   word24                    >= 0.1 && < 0.2+   word24                    >= 0.1   && < 2.0  exposed-modules:    Sound.Iteratee    Sound.Iteratee.Base
src/Sound/Iteratee/Codecs/Common.hs view
@@ -8,17 +8,19 @@    where -import Sound.Iteratee.Base+import           Sound.Iteratee.Base import           Data.Iteratee as I import qualified Data.Vector.Storable as V-import Foreign-import Control.Monad (replicateM, liftM)-import Control.Monad.CatchIO-import Data.Char (chr)-import Data.Int.Int24-import Data.Word.Word24-import Data.ListLike.Vector.Storable ()+import           Foreign+import           Control.Applicative+import           Control.Monad (replicateM, liftM)+import           Control.Monad.CatchIO+import           Data.Char (chr)+import           Data.Int.Int24+import           Data.Word.Word24+import           Data.ListLike.Vector.Storable () + -- ===================================================== -- useful type synonyms @@ -30,20 +32,15 @@ stringRead4 :: MonadCatchIO m => Iteratee (V.Vector Word8) m String stringRead4 = (liftM . map) (chr . fromIntegral) $ replicateM 4 I.head -unroll8 :: (MonadCatchIO m) => Iteratee (V.Vector Word8) m (Maybe (V.Vector Word8))-unroll8 = liftI step-  where-  step (I.Chunk buf)-    | V.null buf = liftI step-    | otherwise  = idone (Just buf) (I.Chunk V.empty)-  step stream        = idone Nothing stream+unroll8 :: (MonadCatchIO m) => Iteratee (V.Vector Word8) m (V.Vector Word8)+unroll8 = I.getChunk  -- When unrolling to a Word8, use the specialized unroll8 function -- because we actually don't need to do anything {-# RULES "unroll8" forall n. unroller n = unroll8 #-}-unroller :: (Storable a, MonadCatchIO m) =>+unroller :: (Storable a, MonadCatchIO m, Functor m) =>   Int-  -> Iteratee (V.Vector Word8) m (Maybe (V.Vector a))+  -> Iteratee (V.Vector Word8) m (V.Vector a) unroller wSize = liftI step   where   step (I.Chunk buf)@@ -54,29 +51,23 @@       then liftI $ step' buf       else if len `rem` wSize == 0               then do-                let buf' = convert_vec buf-                idone (Just buf') (I.Chunk V.empty)+                let buf' = hostToLE buf+                idone buf' (I.Chunk V.empty)               else let newLen = (len `div` wSize) * wSize-                       h      = convert_vec $ V.take newLen buf+                       h      = hostToLE $ V.take newLen buf                        t      = V.drop newLen buf-                   in do-                      idone (Just h) (I.Chunk t)-  step stream = idone Nothing stream+                   in idone h (I.Chunk t)+  step stream = idone V.empty stream   step' i (I.Chunk buf)    | V.null buf = liftI (step' i)    | otherwise = do     let l    = V.length buf         iLen = V.length i         newbuf = i V.++ buf-    if l+iLen < wSize then liftI (step' newbuf)-       else do-         let newLen  = V.length newbuf-             newLen' = (newLen `div` wSize) * wSize-             h       = convert_vec $ V.take newLen' newbuf-             t       = V.drop newLen' newbuf-         idone (Just h) (I.Chunk t)-  step' _i stream  = idone Nothing stream-  convert_vec = hostToLE+    if l+iLen < wSize+       then liftI (step' newbuf)+       else step (I.Chunk newbuf)+  step' _i stream  = idone V.empty stream  hostToLE :: forall a. Storable a => V.Vector Word8 -> V.Vector a hostToLE vec = let be' = unsafePerformIO be in if be'@@ -89,8 +80,8 @@ -}     else let (ptr, offset,len) = V.unsafeToForeignPtr vec          in V.unsafeFromForeignPtr (castForeignPtr ptr)-                                 offset-                                 (len `quot` sizeOf (undefined :: a))+                                   offset+                                   (len `quot` sizeOf (undefined :: a))  {- swapBytes :: Int -> ForeignPtr a -> IO ()@@ -128,25 +119,20 @@ w32 = 0  -- |Convert Word8s to Doubles-convFunc :: (MonadCatchIO m) =>+convFunc :: (MonadCatchIO m, Functor m) =>   AudioFormat   -> Iteratee (V.Vector Word8) m (V.Vector Double)-convFunc (AudioFormat _nc _sr 8) = do-  mbuf <- unroll8-  return $ maybe (error "error in convFunc") (V.map-    (normalize 8 . (fromIntegral :: Word8 -> Int8))) mbuf-convFunc (AudioFormat _nc _sr 16) = do-  mbuf <- unroller (sizeOf w16)-  return $ maybe (error "error in convFunc") (V.map-    (normalize 16 . (fromIntegral :: Word16 -> Int16))) mbuf-convFunc (AudioFormat _nc _sr 24) = do-  mbuf <- unroller (sizeOf w24)-  return $ maybe (error "error in convFunc") (V.map-    (normalize 24 . (fromIntegral :: Word24 -> Int24))) mbuf-convFunc (AudioFormat _nc _sr 32) = do-  mbuf <- unroller (sizeOf w32)-  return $ maybe (error "error in convFunc") (V.map-    (normalize 32 . (fromIntegral :: Word32 -> Int32))) mbuf+convFunc (AudioFormat _nc _sr 8) =+  V.map (normalize 8 . (fromIntegral :: Word8 -> Int8)) <$> unroll8+convFunc (AudioFormat _nc _sr 16) =+  V.map (normalize 16 . (fromIntegral :: Word16 -> Int16))+    <$> unroller (sizeOf w16)+convFunc (AudioFormat _nc _sr 24) =+  V.map (normalize 24 . (fromIntegral :: Word24 -> Int24))+    <$> unroller (sizeOf w24)+convFunc (AudioFormat _nc _sr 32) =+  V.map (normalize 32 . (fromIntegral :: Word32 -> Int32))+    <$> unroller (sizeOf w32) convFunc _ = I.throwErr (I.iterStrExc "Invalid wave bit depth")  
src/Sound/Iteratee/Codecs/WaveWriter.hs view
@@ -111,12 +111,12 @@     _                                 -> error "Can't write: not a WAVE file"   where     putVec af h buf' = case bitDepth af of-      8  -> hPut h $ convertVector i8  af buf'-      16 -> hPut h $ convertVector i16 af buf'-      24 -> hPut h $ convertVector i24 af buf'-      32 -> hPut h $ convertVector i32 af buf'+      8  -> hPut h 1 $ convertVector i8  af buf'+      16 -> hPut h 2 $ convertVector i16 af buf'+      24 -> hPut h 3 $ convertVector i24 af buf'+      32 -> hPut h 4 $ convertVector i32 af buf'       x  -> error $ "Cannot write wave file: unsupported bit depth " ++ show x-    hPut h v = V.unsafeWith v (\p -> hPutBuf h p (V.length v))+    hPut h bytes v = V.unsafeWith v (\p -> hPutBuf h p (bytes * V.length v))     getLength af = fromIntegral (bitDepth af `div` 8) * V.length buf  i8 :: Int8
src/Sound/Iteratee/File.hs view
@@ -27,7 +27,7 @@ -- | Default buffer size.  The value from Data.Iteratee.IO is generally too -- small for good performance. defaultBufSize :: Int-defaultBufSize = 2 ^ (15 :: Int)+defaultBufSize = 2 ^ (16 :: Int)  -- | get the format from a file name getFormat :: FilePath -> Maybe SupportedFileFormat