hsc3-sf 0.9 → 0.11
raw patch · 5 files changed
+44/−20 lines, 5 filesdep ~hoscPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: hosc
API changes (from Hackage documentation)
- Sound.File.NeXT: Double :: Encoding
- Sound.File.NeXT: Float :: Encoding
- Sound.File.NeXT: Linear16 :: Encoding
- Sound.File.NeXT: Linear32 :: Encoding
- Sound.File.NeXT: Linear8 :: Encoding
- Sound.File.NeXT: data Encoding
- Sound.File.NeXT: sizeOf :: Encoding -> Int
+ Sound.File.Encode: encode :: Encoding -> [[Double]] -> ByteString
+ Sound.File.Encode: interleave :: [[a]] -> [a]
+ Sound.File.Encoding: Double :: Encoding
+ Sound.File.Encoding: Float :: Encoding
+ Sound.File.Encoding: Linear16 :: Encoding
+ Sound.File.Encoding: Linear32 :: Encoding
+ Sound.File.Encoding: Linear8 :: Encoding
+ Sound.File.Encoding: data Encoding
+ Sound.File.Encoding: instance Eq Encoding
+ Sound.File.Encoding: instance Show Encoding
+ Sound.File.Encoding: sizeOf :: Encoding -> Int
+ Sound.File.NeXT: type ChannelCount = Int
+ Sound.File.NeXT: type FrameCount = Int
+ Sound.File.NeXT: type SampleRate = Int
Files
- Sound/File/Decode.hs +8/−2
- Sound/File/Encode.hs +8/−2
- Sound/File/Encoding.hs +10/−6
- Sound/File/NeXT.hs +8/−2
- hsc3-sf.cabal +10/−8
Sound/File/Decode.hs view
@@ -1,20 +1,24 @@+-- | Decoder for audio data. module Sound.File.Decode ( decode , deinterleave ) where import Data.Int import qualified Data.ByteString.Lazy as B-import Sound.OpenSoundControl.Byte+import Sound.OpenSoundControl.Coding.Byte import Sound.File.Encoding setsOf :: Int -> [a] -> [[a]] setsOf _ [] = [] setsOf n l = let (x, y) = splitAt n l- in x : setsOf n y + in x : setsOf n y channel :: [[a]] -> Int -> [a] channel l n = map (!!n) l +-- | Given channel count, deinterleave list to set of channels.+--+-- > deinterleave 2 [0..9] == [[0,2,4,6,8],[1,3,5,7,9]] deinterleave :: Int -> [a] -> [[a]] deinterleave n l = map (channel (setsOf n l)) [0..n-1] @@ -39,6 +43,8 @@ i16_f :: [Int] -> [Double] i16_f = map ((/ 32768.0) . fromIntegral) +-- | Given an 'Encoding' and the number of channels, decode+-- a 'B.ByteString' to set of 'deinterleave'd channels. decode :: Encoding -> Int -> B.ByteString -> [[Double]] decode enc nc b = case enc of
Sound/File/Encode.hs view
@@ -1,16 +1,22 @@-module Sound.File.Encode ( encode ) where+-- | Encode audio data.+module Sound.File.Encode (interleave,encode) where import qualified Data.ByteString.Lazy as B import Data.List-import Sound.OpenSoundControl.Byte+import Sound.OpenSoundControl.Coding.Byte import Sound.File.Encoding +-- | Interleave channel data, ie. 'concat' '.' 'transpose'.+--+-- > interleave [[0,2..8],[1,3..9]] == [0,1,2,3,4,5,6,7,8,9] interleave :: [[a]] -> [a] interleave = concat . transpose encodef32 :: [[Double]] -> B.ByteString encodef32 = B.concat . map encode_f32 . interleave +-- | Given 'Encoding' and a set of channels, 'interleave' and encode+-- as 'B.ByteString'. encode :: Encoding -> [[Double]] -> B.ByteString encode enc d = case enc of
Sound/File/Encoding.hs view
@@ -1,5 +1,7 @@+-- | Audio data encodings. module Sound.File.Encoding where +-- | Enemeration of valid audio data encodings. data Encoding = Linear8 | Linear16 | Linear32@@ -7,11 +9,13 @@ | Double deriving (Eq, Show) --- | Bytes per sample at specified encoding.+-- | Bytes per sample at 'Encoding'. sizeOf :: Encoding -> Int-sizeOf Linear8 = 1-sizeOf Linear16 = 2-sizeOf Linear32 = 4-sizeOf Float = 4-sizeOf Double = 8+sizeOf e =+ case e of+ Linear8 -> 1+ Linear16 -> 2+ Linear32 -> 4+ Float -> 4+ Double -> 8
Sound/File/NeXT.hs view
@@ -1,5 +1,5 @@ -- | Read and write NeXT/Sun format sound files.-module Sound.File.NeXT ( Header(..)+module Sound.File.NeXT ( FrameCount,SampleRate,ChannelCount,Header(..) , header , read , write@@ -9,14 +9,20 @@ import qualified Data.ByteString.Lazy as B import Data.Int import Data.Maybe-import Sound.OpenSoundControl.Byte+import Sound.OpenSoundControl.Coding.Byte import Sound.File.Decode import Sound.File.Encode import Sound.File.Encoding type Offset = Int64++-- | Sample rate at 'Header'. type SampleRate = Int++-- | Number of frames at 'Header'. type FrameCount = Int++-- | Number of channels at 'Header'. type ChannelCount = Int -- | Data type encapsulating sound file meta data.
hsc3-sf.cabal view
@@ -1,9 +1,11 @@ Name: hsc3-sf-Version: 0.9+Version: 0.11 Synopsis: Haskell SuperCollider SoundFile-Description: Trivial NeXT sound file input and output.- For almost all use cases please see Stefan - Kersten's hsndfile package.+Description: Trivial @NeXT@ sound file input and output.+ The main module is "Sound.File.NeXT".+ For almost all use cases please see Stefan+ Kersten's @hsndfile@ package,+ <http://hackage.haskell.org/package/hsndfile>. License: GPL Category: Sound Copyright: (c) Rohan Drape, 2006-2011@@ -11,9 +13,9 @@ Maintainer: rd@slavepianos.org Stability: Experimental Homepage: http://slavepianos.org/rd/?t=hsc3-sf-Tested-With: GHC == 6.12.1+Tested-With: GHC == 7.2.2 Build-Type: Simple-Cabal-Version: >= 1.6+Cabal-Version: >= 1.8 Data-files: README Help/rescale.help.hs@@ -22,11 +24,11 @@ Library Build-Depends: base == 4.*, bytestring,- hosc == 0.9+ hosc == 0.11.* GHC-Options: -Wall -fwarn-tabs Exposed-modules: Sound.File.NeXT Sound.File.Decode- Other-modules: Sound.File.Encoding+ Sound.File.Encoding Sound.File.Encode Source-Repository head