hosc 0.8 → 0.9
raw patch · 7 files changed
+51/−29 lines, 7 filessetup-changedPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Sound.OpenSoundControl.OSC: Midi :: (Word8, Word8, Word8, Word8) -> Datum
+ Sound.OpenSoundControl.OSC: bundle :: Time -> [OSC] -> OSC
+ Sound.OpenSoundControl.OSC: message :: String -> [Datum] -> OSC
Files
- README +3/−1
- Setup.hs +3/−0
- Setup.lhs +0/−3
- Sound/OpenSoundControl/Byte.hs +2/−1
- Sound/OpenSoundControl/OSC.hs +19/−2
- Sound/OpenSoundControl/Transport/UDP.hs +20/−18
- hosc.cabal +4/−4
README view
@@ -8,7 +8,9 @@ http://haskell.org/ http://opensoundcontrol.org/ -(c) rohan drape and others, 2006-2010+(c) rohan drape and others, 2006-2011 gpl, http://gnu.org/copyleft/ with contributions by alex mclean+ & stefan kersten+ & henning thielemann see darcs history for details
+ Setup.hs view
@@ -0,0 +1,3 @@+#!/usr/bin/env runhaskell+import Distribution.Simple+main = defaultMain
− Setup.lhs
@@ -1,3 +0,0 @@-#!/usr/bin/env runhaskell-> import Distribution.Simple-> main = defaultMain
Sound/OpenSoundControl/Byte.hs view
@@ -3,6 +3,7 @@ import Data.Binary import qualified Data.ByteString.Lazy as B+import qualified Data.ByteString.Lazy.Char8 as BC import Data.Char import Data.Int import Sound.OpenSoundControl.Cast@@ -77,4 +78,4 @@ -- | Decode an ASCII string. decode_str :: B.ByteString -> String-decode_str = map (chr . fromIntegral) . B.unpack+decode_str = BC.unpack
Sound/OpenSoundControl/OSC.hs view
@@ -2,6 +2,8 @@ -- functions. module Sound.OpenSoundControl.OSC ( OSC(..) , Datum(..)+ , message+ , bundle , encodeOSC , decodeOSC ) where @@ -20,6 +22,7 @@ | String String | Blob [Word8] | TimeStamp Time+ | Midi (Word8,Word8,Word8,Word8) deriving (Eq, Show) -- | An OSC packet.@@ -27,7 +30,8 @@ | Bundle Time [OSC] deriving (Eq, Show) --- | OSC bundles can be ordered (time ascending).+-- | OSC bundles can be ordered (time ascending). Bundles and+-- messages compare EQ. instance Ord OSC where compare (Bundle a _) (Bundle b _) = compare a b compare _ _ = EQ@@ -40,6 +44,7 @@ tag (String _) = 's' tag (Blob _) = 'b' tag (TimeStamp _) = 't'+tag (Midi _) = 'm' -- Command argument types are given by a descriptor. descriptor :: [Datum] -> Datum@@ -60,6 +65,7 @@ encode_datum (Double d) = encode_f64 d encode_datum (TimeStamp t) = encode_u64 $ as_ntpi t encode_datum (String s) = B.pack (extend 0 (str_cstr s))+encode_datum (Midi (b0,b1,b2,b3)) = B.pack [b0,b1,b2,b3] encode_datum (Blob b) = B.concat [encode_i32 (length b), B.pack (extend 0 b)] -- Encode an OSC message.@@ -150,6 +156,18 @@ decodeOSC b | bundle_header `B.isPrefixOf` b = decode_bundle b | otherwise = decode_message b +bundle :: Time -> [OSC] -> OSC+bundle t xs =+ case xs of+ [] -> error "bundle: empty?"+ _ -> Bundle t xs++message :: String -> [Datum] -> OSC+message a xs =+ case a of+ ('/':_) -> Message a xs+ _ -> error "message: ill-formed address"+ b_take :: Int -> B.ByteString -> B.ByteString b_take = B.take . fromIntegral @@ -158,4 +176,3 @@ bundle_header :: B.ByteString bundle_header = encode_datum (String "#bundle")-
Sound/OpenSoundControl/Transport/UDP.hs view
@@ -22,31 +22,33 @@ -- | Make a UDP connection. openUDP :: String -> Int -> IO UDP-openUDP host port = do fd <- N.socket N.AF_INET N.Datagram 0- a <- N.inet_addr host- let sa = N.SockAddrInet (fromIntegral port) a- N.connect fd sa- -- N.setSocketOption fd N.RecvTimeOut 1000- return (UDP fd)+openUDP host port = do+ fd <- N.socket N.AF_INET N.Datagram 0+ a <- N.inet_addr host+ let sa = N.SockAddrInet (fromIntegral port) a+ N.connect fd sa+ -- N.setSocketOption fd N.RecvTimeOut 1000+ return (UDP fd) -- | Trivial udp server. udpServer :: String -> Int -> IO UDP-udpServer host port = do fd <- N.socket N.AF_INET N.Datagram 0- a <- N.inet_addr host- let sa = N.SockAddrInet (fromIntegral port) a- N.bindSocket fd sa- return (UDP fd)+udpServer host port = do+ fd <- N.socket N.AF_INET N.Datagram 0+ a <- N.inet_addr host+ let sa = N.SockAddrInet (fromIntegral port) a+ N.bindSocket fd sa+ return (UDP fd) sendTo :: UDP -> OSC -> N.SockAddr -> IO ()-sendTo (UDP fd) o a =- do N.sendTo fd (decode_str (encodeOSC o)) a- return ()+sendTo (UDP fd) o a = do+ _ <- N.sendTo fd (decode_str (encodeOSC o)) a+ return () recvFrom :: UDP -> IO (OSC, N.SockAddr)-recvFrom (UDP fd) = - do (s, _, a) <- N.recvFrom fd 8192- let o = (decodeOSC . encode_str) s- return (o, a)+recvFrom (UDP fd) = do+ (s, _, a) <- N.recvFrom fd 8192+ let o = (decodeOSC . encode_str) s+ return (o, a) udpPort :: Integral n => UDP -> IO n udpPort (UDP fd) = fmap fromIntegral (N.socketPort fd)
hosc.cabal view
@@ -1,17 +1,17 @@ Name: hosc-Version: 0.8+Version: 0.9 Synopsis: Haskell Open Sound Control Description: hosc provides Sound.OpenSoundControl, a haskell module implementing a subset of the Open Sound Control byte protocol. License: GPL Category: Sound-Copyright: (c) Rohan Drape, 2006-2010+Copyright: (c) Rohan Drape and others, 2006-2011 Author: Rohan Drape Maintainer: rd@slavepianos.org Stability: Experimental Homepage: http://slavepianos.org/rd/?t=hosc-Tested-With: GHC == 6.10.3+Tested-With: GHC == 6.12.1 Build-Type: Simple Cabal-Version: >= 1.6 Data-Files: README@@ -37,4 +37,4 @@ Source-Repository head Type: darcs- Location: http://slavepianos.org/~rd/sw/hosc/+ Location: http://slavepianos.org/rd/sw/hosc/