packages feed

hsc3-sf 0.12 → 0.14

raw patch · 4 files changed

+28/−27 lines, 4 filesdep ~hoscPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: hosc

API changes (from Hackage documentation)

- Sound.File.Decode: decode :: Encoding -> Int -> ByteString -> [[Double]]
+ Sound.File.Decode: decode :: (Real n, Floating n) => Encoding -> Int -> ByteString -> [[n]]
- Sound.File.Encode: encode :: Encoding -> [[Double]] -> ByteString
+ Sound.File.Encode: encode :: (Real n, Floating n) => Encoding -> [[n]] -> ByteString
- Sound.File.NeXT: read :: FilePath -> IO (Header, [[Double]])
+ Sound.File.NeXT: read :: (Real n, Floating n) => FilePath -> IO (Header, [[n]])
- Sound.File.NeXT: write :: FilePath -> Header -> [[Double]] -> IO ()
+ Sound.File.NeXT: write :: (Real n, Floating n) => FilePath -> Header -> [[n]] -> IO ()

Files

Sound/File/Decode.hs view
@@ -2,9 +2,10 @@ module Sound.File.Decode ( decode                          , deinterleave ) where -import Data.Int-import qualified Data.ByteString.Lazy as B-import Sound.OpenSoundControl.Coding.Byte+import Data.Int {- base -}+import qualified Data.ByteString.Lazy as B {- bytestring -}+import Sound.OSC.Coding.Byte {- hosc -}+ import Sound.File.Encoding  -- > setsOf 2 [0..5] == [[0,1],[2,3],[4,5]]@@ -32,8 +33,8 @@     else let (x, y) = B.splitAt n b          in x : bSetsOf n y -decodef32 :: Int -> B.ByteString -> [[Double]]-decodef32 n = deinterleave n . map decode_f32 . bSetsOf 4+decodef32 :: (Real n,Floating n) => Int -> B.ByteString -> [[n]]+decodef32 n = deinterleave n . map (realToFrac . decode_f32) . bSetsOf 4  decodei16 :: Int -> B.ByteString -> [[Int]] decodei16 n = deinterleave n . map decode_i16 . bSetsOf 2@@ -41,15 +42,15 @@ decodei8 :: Int -> B.ByteString -> [[Int]] decodei8 n = deinterleave n . map decode_i8 . bSetsOf 1 -i8_f :: [Int] -> [Double]+i8_f :: (Real n,Floating n) => [Int] -> [n] i8_f = map ((/ 128.0) . fromIntegral) -i16_f :: [Int] -> [Double]+i16_f :: (Real n,Floating n) => [Int] -> [n] 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 :: (Real n,Floating n) => Encoding -> Int -> B.ByteString -> [[n]] decode enc nc b =     case enc of       Linear8 -> map i8_f (decodei8 nc b)
Sound/File/Encode.hs view
@@ -1,9 +1,10 @@ -- | Encode audio data. module Sound.File.Encode (interleave,encode) where -import qualified Data.ByteString.Lazy as B-import Data.List-import Sound.OpenSoundControl.Coding.Byte+import qualified Data.ByteString.Lazy as B {- bytestring -}+import Data.List {- base -}+import Sound.OSC.Coding.Byte {- hosc -}+ import Sound.File.Encoding  -- | Interleave channel data, ie. 'concat' '.' 'transpose'.@@ -12,12 +13,12 @@ interleave :: [[a]] -> [a] interleave = concat . transpose -encodef32 :: [[Double]] -> B.ByteString-encodef32 = B.concat . map encode_f32 . interleave+encodef32 :: (Real n,Floating n) => [[n]] -> B.ByteString+encodef32 = B.concat . map (encode_f32 . realToFrac) . interleave  -- | Given 'Encoding' and a set of channels, 'interleave' and encode -- as 'B.ByteString'.-encode :: Encoding -> [[Double]] -> B.ByteString+encode :: (Real n,Floating n) => Encoding -> [[n]] -> B.ByteString encode enc d =     case enc of       Float -> encodef32 d
Sound/File/NeXT.hs view
@@ -5,11 +5,12 @@                        , write                        , module Sound.File.Encoding ) where -import Prelude hiding (read)-import qualified Data.ByteString.Lazy as B-import Data.Int-import Data.Maybe-import Sound.OpenSoundControl.Coding.Byte+import Prelude hiding (read) {- base -}+import qualified Data.ByteString.Lazy as B {- bytestring -}+import Data.Int {- base -}+import Data.Maybe {- base -}+import Sound.OSC.Coding.Byte {- hosc -}+ import Sound.File.Decode import Sound.File.Encode import Sound.File.Encoding@@ -84,7 +85,7 @@     in B.writeFile fn b  -- | Write sound file, data is non-interleaved.-write :: FilePath -> Header -> [[Double]] -> IO ()+write :: (Real n,Floating n) => FilePath -> Header -> [[n]] -> IO () write fn (Header nf enc sr nc) d =     let b = encode enc d     in writeB fn (Header nf enc sr nc) b@@ -97,12 +98,10 @@  -- | Read sound file meta data. header :: FilePath -> IO Header-header fn = do-  (h, _) <- read fn-  return h+header fn = fmap fst (readB fn)  -- | Read sound file, data is interleaved.-read :: FilePath -> IO (Header, [[Double]])+read :: (Real n,Floating n) => FilePath -> IO (Header, [[n]]) read fn = do   (Header nf enc sr nc, b) <- readB fn   let d = decode enc nc b
hsc3-sf.cabal view
@@ -1,5 +1,5 @@ Name:              hsc3-sf-Version:           0.12+Version:           0.14 Synopsis:          Haskell SuperCollider SoundFile Description:       Trivial @NeXT@ sound file input and output.                    The main module is "Sound.File.NeXT".@@ -8,7 +8,7 @@                    <http://hackage.haskell.org/package/hsndfile>. License:           GPL Category:          Sound-Copyright:         (c) Rohan Drape, 2006-2012+Copyright:         (c) Rohan Drape, 2006-2013 Author:            Rohan Drape Maintainer:        rd@slavepianos.org Stability:         Experimental@@ -24,7 +24,7 @@ Library   Build-Depends:   base == 4.*,                    bytestring,-                   hosc == 0.12.*+                   hosc == 0.14.*   GHC-Options:     -Wall -fwarn-tabs   Exposed-modules: Sound.File.NeXT                    Sound.File.Decode