sample-frame 0.0.2 → 0.0.3
raw patch · 3 files changed
+59/−6 lines, 3 files
Files
- sample-frame.cabal +12/−4
- src/Sound/Frame/Stereo.hs +32/−2
- src/SpeedTest.hs +15/−0
sample-frame.cabal view
@@ -1,11 +1,10 @@ Name: sample-frame-Version: 0.0.2+Version: 0.0.3 License: BSD3 License-File: LICENSE Author: Henning Thielemann <haskell@henning-thielemann.de> Maintainer: Henning Thielemann <haskell@henning-thielemann.de> Homepage: http://www.haskell.org/haskellwiki/Synthesizer-Package-URL: http://code.haskell.org/~thielema/sample-frame/core/ Category: Sound Synopsis: Handling of samples in an (audio) signal Description:@@ -21,9 +20,18 @@ Maybe we add 5+1 channels or so in future. . This is used by packages @sox@, @alsa@, @synthesizer@.-Tested-With: GHC==6.10.4-Cabal-Version: >=1.2+Tested-With: GHC==7.4.2+Cabal-Version: >=1.6 Build-Type: Simple++Source-Repository this+ Tag: 0.0.3+ Type: darcs+ Location: http://code.haskell.org/~thielema/sample-frame/core/++Source-Repository head+ Type: darcs+ Location: http://code.haskell.org/~thielema/sample-frame/core/ Flag buildBenchmarks description: Build benchmark executables
src/Sound/Frame/Stereo.hs view
@@ -1,7 +1,11 @@ {- This data type can be used as sample type for stereo signals. -}-module Sound.Frame.Stereo (T, left, right, cons, map, ) where+module Sound.Frame.Stereo (+ T, left, right, cons, map,+ Channel(..), select,+ interleave, sequence, liftApplicative,+ ) where import qualified Sound.Frame as Frame @@ -16,7 +20,7 @@ import Test.QuickCheck (Arbitrary(arbitrary), ) -import Prelude hiding (map, )+import Prelude hiding (Either(Left, Right), map, sequence, ) data T a = Cons {left, right :: !a}@@ -40,6 +44,32 @@ {-# INLINE map #-} map :: (a -> b) -> T a -> T b map f (Cons l r) = Cons (f l) (f r)+++data Channel = Left | Right++{-# INLINE select #-}+select :: T a -> Channel -> a+select x c =+ case c of+ Left -> left x+ Right -> right x++{-# INLINE interleave #-}+interleave :: (T a, T b) -> T (a,b)+interleave = uncurry (liftA2 (,))++{-# INLINE sequence #-}+sequence :: (Functor f) => f (T a) -> T (f a)+sequence x = cons (fmap left x) (fmap right x)++{-# INLINE liftApplicative #-}+liftApplicative ::+ (Applicative f) =>+ (f a -> f b) -> f (T a) -> f (T b)+liftApplicative proc =+ Trav.sequenceA . fmap proc . sequence+ instance Functor T where {-# INLINE fmap #-}
src/SpeedTest.hs view
@@ -37,6 +37,14 @@ real 0m3.017s user 0m2.844s sys 0m0.168s+++GHC-7.2.1:++Storable.Traversable instance:+real 0m3.794s+user 0m3.564s+sys 0m0.196s -} stereo :: SV.Vector (Stereo.T Int16) stereo =@@ -76,6 +84,13 @@ real 0m47.021s user 0m46.827s sys 0m0.108s++GHC-7.2.1:++Storable.Traversable instance:+real 0m3.933s+user 0m3.864s+sys 0m0.068s -} stereoSum :: SV.Vector (Stereo.T Int16) -> Stereo.T Int16 stereoSum =