hsdif 0.11 → 0.12
raw patch · 5 files changed
+71/−23 lines, 5 filesdep ~hoscPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: hosc
API changes (from Hackage documentation)
+ Sound.SDIF.Type: U8 :: Word8 -> Datum
Files
- Help/hsdif.hs +33/−4
- README +11/−6
- Sound/SDIF.hs +12/−0
- Sound/SDIF/Type.hs +9/−7
- hsdif.cabal +6/−6
Help/hsdif.hs view
@@ -4,14 +4,39 @@ import Sound.SDIF.Byte.SDIF import Sound.SDIF.Frame import Sound.SDIF.Matrix+import Sound.SDIF.Type import Sound.SDIF -main :: IO ()-main = do- b <- B.readFile "crotale.sdif"+matrix_info :: Matrix -> IO ()+matrix_info m =+ print (matrix_type m+ ,data_type_string (matrix_data_type m)+ ,matrix_rows m+ ,matrix_columns m)++frame_info :: Frame -> IO ()+frame_info f = do+ print (frame_type f+ ,frame_time f+ ,frame_id f+ ,frame_matrices f)+ mapM_ matrix_info (frame_matrix_c f)++-- > hsdif_info "/home/rohan/cvs/uc/uc-53/sdif/i/82.4.sdif"+-- > hsdif_info "/home/rohan/cvs/uc/uc-53/sdif/i/164.8.sdif"+hsdif_info :: FilePath -> IO ()+hsdif_info fn = do+ s <- sdif_read_file fn+ print (sdif_frames s)+ mapM_ frame_info (sdif_frame_c s)++crotale_info :: IO ()+crotale_info = do+ let fn = "crotale.sdif"+ b <- B.readFile fn -- (856,True,2) print (show (B.length b,is_sdif_b b,sdif_b_frames b))- s <- sdif_read_file "crotale.sdif"+ s <- sdif_read_file fn -- (2,[(0,16),(16,856)]) print (sdif_frames s,sdif_frame_i s) let fb = sdif_frame_b s 1@@ -52,3 +77,7 @@ print (matrix_row m 0) -- ~ [F32 35.45,F32 128.59,F32 346.97] print (take 3 (matrix_column m 0))++main :: IO ()+main = hsdif_info "crotale.sdif" >> crotale_info+
README view
@@ -1,8 +1,13 @@-hsdif - haskell sound description interchange format+hsdif+----- - http://slavepianos.org/rd/?t=hsdif- http://haskell.org/- http://sdif.sourceforge.net/+[haskell][hs] sound description interchange format ([sdif][sdif]) -(c) rohan drape, 2010-2011- gpl, http://gnu.org/copyleft/+[hsdif]: http://rd.slavepianos.org/?t=hsdif+[hs]: http://haskell.org/+[sdif]: http://sdif.sourceforge.net/++© [rohan drape][rd], 2010-2012, [gpl]++[rd]: http://rd.slavepianos.org/+[gpl]: http://gnu.org/copyleft/
Sound/SDIF.hs view
@@ -15,6 +15,9 @@ deriving (Eq, Show) -- | Decode 'SDIF' data stream.+--+-- > b <- B.readFile "/home/rohan/sw/hsdif/Help/crotale.sdif"+-- > sdif_frames (decode_sdif b) == 2 decode_sdif :: B.ByteString -> SDIF decode_sdif sdf = let n = sdif_b_frames sdf@@ -29,6 +32,9 @@ else error "decode_sdif" "illegal data" -- | Read and decode 'SDIF' from named file.+--+-- > s <- sdif_read_file "/home/rohan/sw/hsdif/Help/crotale.sdif"+-- > sdif_frame_i s == [(0,16),(16,856)] sdif_read_file :: FilePath -> IO SDIF sdif_read_file file_name = do b <- B.readFile file_name@@ -41,13 +47,19 @@ in (section' (sdif_b sdf) i j) -- | Extract and decode /n/th frame from 'SDIF'.+--+-- > frame_type (sdif_frame s 0) == "SDIF" sdif_frame :: SDIF -> Int -> Frame sdif_frame sdf n = sdif_frame_c sdf !! n -- | Extract and decode /j/th matrix from /i/th frame from 'SDIF'.+--+-- > matrix_type (sdif_matrix s 1 0) == "1RES" sdif_matrix :: SDIF -> Int -> Int -> Matrix sdif_matrix sdf i = frame_matrix (sdif_frame sdf i) -- | Run 'matrix_v' on result of 'sdif_matrix'.+--+-- > length (sdif_matrix_v s 1 0) == 200 sdif_matrix_v :: SDIF -> Int -> Int -> [Datum] sdif_matrix_v sdf i = matrix_v . sdif_matrix sdf i
Sound/SDIF/Type.hs view
@@ -2,10 +2,10 @@ module Sound.SDIF.Type where import Data.Bits-import qualified Data.ByteString.Lazy as B+import qualified Data.ByteString.Lazy as B {- bytestring -} import Data.Int import Data.Word-import Sound.OpenSoundControl.Coding.Byte+import Sound.OpenSoundControl.Coding.Byte {- hosc -} -- | Section of 'B.ByteString' from /i/th to /j/th indices. section :: B.ByteString -> Int64 -> Int64 -> B.ByteString@@ -55,6 +55,7 @@ | U64 Word64 | F32 Double | F64 Double+ | U8 Word8 deriving (Eq, Show) -- | Decoder for indicated data element type to 'Datum'.@@ -67,13 +68,13 @@ 0x102 -> I16 (decode_i16 x) 0x104 -> I32 (decode_i32 x) 0x108 -> I64 (decode_i64 x)- 0x201 -> undefined -- decode_u8- 0x202 -> undefined -- decode_u16+ 0x201 -> U8 (x `B.index` 0)+ 0x202 -> error "data_type_decoder:0x202,u16" -- decode_u16 0x204 -> U32 (decode_u32 x) 0x208 -> U64 (decode_u64 x)- 0x301 -> undefined- 0x401 -> undefined- _ -> undefined+ 0x301 -> U8 (x `B.index` 0)+ 0x401 -> U8 (x `B.index` 0)+ _ -> error "data_type_decoder:_" -- | SDIF encoder for 'Datum'. data_type_encoder :: Datum -> B.ByteString@@ -87,3 +88,4 @@ U64 n -> encode_u64 n F32 n -> encode_f32 n F64 n -> encode_f64 n+ U8 n -> B.singleton n
hsdif.cabal view
@@ -1,17 +1,17 @@ Name: hsdif-Version: 0.11+Version: 0.12 Synopsis: Haskell SDIF Description: hsdif provides Sound.SDIF, a haskell module implementing a subset of Sound Description Interchange Format. License: GPL Category: Sound-Copyright: (c) Rohan Drape, 2011+Copyright: (c) Rohan Drape, 2010-2012 Author: Rohan Drape Maintainer: rd@slavepianos.org Stability: Experimental-Homepage: http://slavepianos.org/rd/?t=hsdif-Tested-With: GHC == 7.2.2+Homepage: http://rd.slavepianos.org/?t=hsdif+Tested-With: GHC == 7.6.1 Build-Type: Simple Cabal-Version: >= 1.8 @@ -22,7 +22,7 @@ Library Build-Depends: base == 4.*, bytestring,- hosc == 0.11.*+ hosc == 0.12.* GHC-Options: -Wall -fwarn-tabs Exposed-modules: Sound.SDIF Sound.SDIF.Frame@@ -34,4 +34,4 @@ Source-Repository head Type: darcs- Location: http://slavepianos.org/rd/sw/hsdif/+ Location: http://rd.slavepianos.org/sw/hsdif/