hosc-0.21.1: Haskell Open Sound Control

Safe Haskell | None
Language | Haskell2010

Sound.Osc.Coding.Decode.Binary

Description

Optimised decode function for Osc packets.

Synopsis

- get_packet :: Get (PacketOf Message)
- decodeMessage :: ByteString -> Message
- decodeBundle :: ByteString -> BundleOf Message
- decodePacket :: ByteString -> PacketOf Message
- decodePacket_strict :: ByteString -> PacketOf Message
- decodeMessageOr :: ByteString -> Either String Message
- decodeBundleOr :: ByteString -> Either String Bundle
- decodePacketOr :: ByteString -> Either String Packet

# Documentation

get_packet :: Get (PacketOf Message) Source #

Get an Osc `Packet`.

decodeMessage :: ByteString -> Message Source #

Decode an Osc `Message` from a lazy ByteString.

    >>> let b = ByteString.Lazy.pack [47,103,95,102,114,101,101,0,44,105,0,0,0,0,0,0]
    >>> decodeMessage b == Message "/g_free" [Int32 0]
    True

decodeBundle :: ByteString -> BundleOf Message Source #

Decode an Osc `Bundle` from a lazy ByteString.

decodePacket :: ByteString -> PacketOf Message Source #

Decode an Osc packet from a lazy ByteString.

    >>> let b = ByteString.Lazy.pack [47,103,95,102,114,101,101,0,44,105,0,0,0,0,0,0]
    >>> decodePacket b == Packet_Message (Message "/g_free" [Int32 0])
    True

decodePacket_strict :: ByteString -> PacketOf Message Source #

Decode an Osc packet from a strict Char8 ByteString.

decodeMessageOr :: ByteString -> Either String Message Source #

Either decode Osc message or return an error message. Prevents application halt for non-valid messagebundlepacket arrives.

    >>> let b = ByteString.Lazy.pack [1,2,3,2,1]
    >>> decodePacketOr b
    Left "not enough bytes"

decodeBundleOr :: ByteString -> Either String Bundle Source #

decodePacketOr :: ByteString -> Either String Packet Source #