hosc-0.11: Haskell Open Sound Control



An implementation of a subset of the Open Sound Control byte protocol, documented at http://opensoundcontrol.org/.

For the most part this top-level module is the only import required. It provides the Datum and OSC types, encodeOSC and decodeOSC functions, basic UDP and TCP Transport layers, and basic temporal operations utcr to access the current time and pauseThread to delay the current thread.

 let o = Bundle immediately [Message "/g_free" [Int 0]]
 in decodeOSC (encodeOSC o) == o



encodeOSC :: OSC -> ByteStringSource

Encode an OSC packet to a lazy ByteString.

 let b = L.pack [47,103,95,102,114,101,101,0,44,105,0,0,0,0,0,0]
 in encodeOSC (Message "/g_free" [Int 0]) == b

decodeOSC :: ByteString -> OSCSource

Decode an OSC packet from a lazy ByteString.

 let b = L.pack [47,103,95,102,114,101,101,0,44,105,0,0,0,0,0,0]
 in decodeOSC b == Message "/g_free" [Int 0]

openUDP :: String -> Int -> IO UDPSource

Make a UDP connection.

 let t = openUDP "" 57110
 in withTransport t (\fd -> recvT 0.5 fd >>= print)

udpServer :: String -> Int -> IO UDPSource

Trivial udp server.

openTCP :: String -> Int -> IO TCPSource

Make a TCP connection.

tcpServer :: Int -> (TCP -> IO ()) -> IO ()Source

A trivial TCP OSC server.