packages feed

zoom-cache-sndfile 0.2.0.2 → 0.3.0.0

raw patch · 2 files changed

+25/−14 lines, 2 filesdep ~zoom-cache

Dependency ranges changed: zoom-cache

Files

tools/zoom-cache-sndfile.hs view
@@ -18,6 +18,7 @@ import qualified Data.Vector.Storable as SV import Data.ZoomCache import Data.ZoomCache.Dump+import Data.ZoomCache.Multichannel import Data.ZoomCache.PCM import qualified Sound.File.Sndfile as SF import qualified Sound.File.Sndfile.Buffer.Vector as SFV@@ -86,7 +87,7 @@              "Set track label"     , Option ['r'] ["rate"] (ReqArg Rate "data-rate")              "Set track rate"-    , Option ['w'] ["watermark"] (ReqArg Rate "watermark")+    , Option ['w'] ["watermark"] (ReqArg Watermark "watermark")              "Set high-watermark level"     , Option ['t'] ["track"] (ReqArg Track "trackNo")              "Set or select track number"@@ -144,13 +145,13 @@     | intData   = w pcmInts path     | otherwise = w pcmDoubles path     where-    w :: (ZoomReadable a, ZoomWrite a, ZoomWrite (TimeStamp, a))+    w :: (ZoomReadable a, ZoomWrite a, ZoomWrite (SampleOffset, a))       => [a] -> FilePath -> IO ()     w d-        | variable  = withFileWrite (oneTrack (head d) delta zlib VariableDR rate' label)+        | variable  = withFileWrite (oneTrack (head d) delta zlib VariableSR rate' label)                           (not noRaw)-                          (sW >> mapM_ (write track) (zip (map TS [1,3..]) d))-        | otherwise = withFileWrite (oneTrack (head d) delta zlib ConstantDR rate' label)+                          (sW >> mapM_ (write track) (zip (map SO [1,3..]) d))+        | otherwise = withFileWrite (oneTrack (head d) delta zlib ConstantSR rate' label)                           (not noRaw)                           (sW >> mapM_ (write track) d)     rate' = fromInteger rate@@ -237,23 +238,33 @@ encodeFile :: FilePath -> IO () encodeFile path = do     h <- SF.openFile path SF.ReadMode info-    let sfRate = fromIntegral (SF.samplerate . SF.hInfo $ h)+    let sfInfo = SF.hInfo h+        sfRate = fromIntegral . SF.samplerate $ sfInfo+        sfChannels = fromIntegral . SF.channels $ sfInfo -    z <- openWrite (oneTrack (undefined :: PCM Double)+    z <- openWrite (oneTrackMultichannel+             sfChannels+             (undefined :: PCM Double)              False -- delta              False -- zlib-             ConstantDR sfRate "pcm")+             ConstantSR sfRate "pcm")              True -- doRaw              (path ++ ".zoom")-    z' <- foldFrames encodeBuffer z h 1024+    z' <- foldFrames (encodeBuffer sfChannels) z h 1024     closeWrite z'      SF.hClose h     where         info = SF.Info 0 0 0 SF.defaultFormat 0 True -encodeBuffer :: ZoomWHandle -> SFV.Buffer Double -> IO ZoomWHandle-encodeBuffer z buf = execStateT (SV.mapM_ (write 1) . SFV.fromBuffer $ buf) z+encodeBuffer :: Int -> ZoomWHandle -> SFV.Buffer Double -> IO ZoomWHandle+encodeBuffer channels z buf = execStateT (encV . SFV.fromBuffer $ buf) z+    where+        encV :: SV.Vector Double -> ZoomW ()+        encV v | SV.null v = return ()+               | otherwise = do+                   write 1 (map PCM . SV.toList . SV.take channels $ v)+                   encV (SV.drop channels v)  ------------------------------------------------------------ @@ -320,7 +331,7 @@  zoom :: Application () () zoom = def {-          appName = "zoom"+          appName = "zoom-cache-sndfile"         , appVersion = "0.1"         , appAuthors = ["Conrad Parker"]         , appBugEmail = "conrad@metadecks.org"
zoom-cache-sndfile.cabal view
@@ -3,7 +3,7 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version:             0.2.0.2+Version:             0.3.0.0  Synopsis:            Tools for generating zoom-cache-pcm files @@ -46,7 +46,7 @@     mtl                       >= 2.0.0.0 && < 3,     ui-command,     vector,-    zoom-cache                >= 0.8.0.0 && < 0.9,+    zoom-cache                >= 0.9.0.0 && < 0.10,     zoom-cache-pcm            >= 0.2.0.0 && < 0.3      -- Other-modules: