hsc3-sf-hsndfile (empty) → 0.8
raw patch · 5 files changed
+113/−0 lines, 5 filesdep +arraydep +basedep +hsc3-sfsetup-changed
Dependencies added: array, base, hsc3-sf, hsndfile, hsndfile-vector, vector
Files
- Help/stat.help.hs +27/−0
- README +13/−0
- Setup.lhs +3/−0
- Sound/File/HSndFile.hs +38/−0
- hsc3-sf-hsndfile.cabal +32/−0
+ Help/stat.help.hs view
@@ -0,0 +1,27 @@+-- Trivial sound file statistics.++import qualified Sound.File.HSndFile as F+import System.Environment++stat ::FilePath -> IO ()+stat fn = do+ (hdr, d) <- F.read fn+ let nf = F.frameCount hdr+ sr = F.sampleRate hdr+ nc = F.channelCount hdr+ mapM_ print [("nframes", [fromIntegral nf])+ ,("srate", [sr])+ ,("nchan", [fromIntegral nc])+ ,("minimum", map minimum d)+ ,("maximum", map maximum d)]++main :: IO ()+main = do+ a <- getArgs+ case a of+ [fn] -> stat fn+ _ -> putStrLn "stat file-name"++{-+stat "/home/rohan/audio/text.snd"+-}
+ README view
@@ -0,0 +1,13 @@+hsc3-sf-hsndfile - hsc3-sf interface to hsndfile++hsc3-sf-sndfile provides a trivial hsc3-sf equivalent+interface to the hsndfile package. hsndfile has more+extensive dependencies than hsc3-sf, and this allows+the two packages to be used interchangably by modifying+a single import.++ http://slavepianos.org/rd+ http://code.haskell.org/hsndfile++(c) rohan drape, 2010+ gpl, http://gnu.org/copyleft/
+ Setup.lhs view
@@ -0,0 +1,3 @@+#!/usr/bin/env runhaskell+> import Distribution.Simple+> main = defaultMain
+ Sound/File/HSndFile.hs view
@@ -0,0 +1,38 @@+-- | Read and write sound files using hsndfile.+module Sound.File.HSndFile ( Header(..)+ , header+ , read ) where++import qualified Data.Vector.Storable as V+import Prelude hiding (read)+import qualified Sound.File.Decode as D+import qualified Sound.File.Sndfile as F+import qualified Sound.File.Sndfile.Buffer.Vector as F++data Header = Header { channelCount :: Int + , frameCount :: Int+ , sampleRate :: Double }+ deriving (Eq, Show)++-- | file-name -> (channel-count, frame-count, sample-rate)+header :: FilePath -> IO Header+header fn = do+ h <- F.openFile fn F.ReadMode F.defaultInfo+ let i = F.hInfo h+ nc = F.channels i+ nf = F.frames i+ sr = F.samplerate i+ F.hClose h+ return (Header nc (fromIntegral nf) (fromIntegral sr))++read :: FilePath -> IO (Header, [[Double]])+read fn = do+ hd <- header fn+ h <- F.openFile fn F.ReadMode F.defaultInfo+ let Header nc nf _ = hd+ ns = nc * nf+ b <- F.hGetBuffer h ns+ case b of+ Just b' -> let e = V.toList (F.fromBuffer b')+ in return (hd, D.deinterleave nc e)+ Nothing -> return (hd, [])
+ hsc3-sf-hsndfile.cabal view
@@ -0,0 +1,32 @@+Name: hsc3-sf-hsndfile+Version: 0.8+Synopsis: Haskell SuperCollider SoundFile+Description: Provide hsc3-sf interface to Stefan + Kersten's hsndfile package.+License: GPL+Category: Sound+Copyright: (c) Rohan Drape, 2010+Author: Rohan Drape+Maintainer: rd@slavepianos.org+Stability: Experimental+Homepage: http://slavepianos.org/rd/?t=hsc3-sf-hsndfile+Tested-With: GHC == 6.10.3+Build-Type: Simple+Cabal-Version: >= 1.6++Data-files: README+ Help/stat.help.hs++Library+ Build-Depends: array,+ base == 4.*,+ hsc3-sf == 0.8,+ hsndfile == 0.4.*,+ hsndfile-vector == 0.4.*,+ vector >= 0.5+ GHC-Options: -Wall -fwarn-tabs+ Exposed-modules: Sound.File.HSndFile++Source-Repository head+ Type: darcs+ Location: http://slavepianos.org/~rd/sw/hsc3-sf-hsndfile/