hosc-0.17: Haskell Open Sound Control

Safe Haskell | Safe
Language | Haskell98

Sound.OSC.Packet

Contents

- Message
- Bundle
- Packet
- Address Query
- Pretty printing

Description

Data types for OSC messages, bundles and packets.

Synopsis

- type Address_Pattern = String
- data Message = Message {
  - messageAddress :: Address_Pattern
  - messageDatum :: [Datum]
  }
- message :: Address_Pattern -> [Datum] -> Message
- data Bundle = Bundle {
  - bundleTime :: Time
  - bundleMessages :: [Message]
  }
- bundle :: Time -> [Message] -> Bundle
- data Packet
  - = Packet_Message {
    - packetMessage :: Message
    }
  - | Packet_Bundle {
    - packetBundle :: Bundle
    }
- p_bundle :: Time -> [Message] -> Packet
- p_message :: Address_Pattern -> [Datum] -> Packet
- packetTime :: Packet -> Time
- packetMessages :: Packet -> [Message]
- packet_to_bundle :: Packet -> Bundle
- packet_to_message :: Packet -> Maybe Message
- packet_is_immediate :: Packet -> Bool
- at_packet :: (Message -> a) -> (Bundle -> a) -> Packet -> a
- message_has_address :: Address_Pattern -> Message -> Bool
- bundle_has_address :: Address_Pattern -> Bundle -> Bool
- packet_has_address :: Address_Pattern -> Packet -> Bool
- messagePP :: FP_Precision -> Message -> String
- bundlePP :: FP_Precision -> Bundle -> String
- packetPP :: FP_Precision -> Packet -> String

# Message

type Address_Pattern = String Source #

OSC address pattern. This is strictly an ASCII value, however it is very common to pattern match on addresses and matching on `ByteString` requires `OverloadedStrings`.

data Message Source #

An OSC message, an `Address_Pattern` and a sequence of `Datum`.

Constructors

Message |

Fields

- messageAddress :: Address_Pattern
- messageDatum :: [Datum]

Instances

Eq Message Source # |
Instance details Defined in Sound.OSC.Packet Methods (==) :: Message -> Message -> Bool Source # (/=) :: Message -> Message -> Bool Source #
Read Message Source # |
Instance details Defined in Sound.OSC.Packet Methods readsPrec :: Int -> ReadS Message Source # readList :: ReadS [Message] Source # readPrec :: ReadPrec Message Source # readListPrec :: ReadPrec [Message] Source #
Show Message Source # |
Instance details Defined in Sound.OSC.Packet Methods showsPrec :: Int -> Message -> ShowS Source # show :: Message -> String Source # showList :: [Message] -> ShowS Source #

message :: Address_Pattern -> [Datum] -> Message Source #

`Message` constructor. It is an `error` if the `Address_Pattern` doesn't conform to the OSC specification.

# Bundle

data Bundle Source #

An OSC bundle, a `Time` and a sequence of `Message`s.

Constructors

Bundle |

Fields

- bundleTime :: Time
- bundleMessages :: [Message]

Instances

Eq Bundle Source # |
Instance details Defined in Sound.OSC.Packet Methods (==) :: Bundle -> Bundle -> Bool Source # (/=) :: Bundle -> Bundle -> Bool Source #
Ord Bundle Source # | OSC `Bundle`s can be ordered (time ascending).
Instance details Defined in Sound.OSC.Packet Methods compare :: Bundle -> Bundle -> Ordering Source # (<) :: Bundle -> Bundle -> Bool Source # (<=) :: Bundle -> Bundle -> Bool Source # (>) :: Bundle -> Bundle -> Bool Source # (>=) :: Bundle -> Bundle -> Bool Source # max :: Bundle -> Bundle -> Bundle Source # min :: Bundle -> Bundle -> Bundle Source #
Read Bundle Source # |
Instance details Defined in Sound.OSC.Packet Methods readsPrec :: Int -> ReadS Bundle Source # readList :: ReadS [Bundle] Source # readPrec :: ReadPrec Bundle Source # readListPrec :: ReadPrec [Bundle] Source #
Show Bundle Source # |
Instance details Defined in Sound.OSC.Packet Methods showsPrec :: Int -> Bundle -> ShowS Source # show :: Bundle -> String Source # showList :: [Bundle] -> ShowS Source #

bundle :: Time -> [Message] -> Bundle Source #

`Bundle` constructor. It is an `error` if the `Message` list is empty.

# Packet

data Packet Source #

An OSC `Packet` is either a `Message` or a `Bundle`.

Constructors

Packet_Message |

Fields

- packetMessage :: Message

Packet_Bundle |

Fields

- packetBundle :: Bundle

Instances

Eq Packet Source # |
Instance details Defined in Sound.OSC.Packet Methods (==) :: Packet -> Packet -> Bool Source # (/=) :: Packet -> Packet -> Bool Source #
Read Packet Source # |
Instance details Defined in Sound.OSC.Packet Methods readsPrec :: Int -> ReadS Packet Source # readList :: ReadS [Packet] Source # readPrec :: ReadPrec Packet Source # readListPrec :: ReadPrec [Packet] Source #
Show Packet Source # |
Instance details Defined in Sound.OSC.Packet Methods showsPrec :: Int -> Packet -> ShowS Source # show :: Packet -> String Source # showList :: [Packet] -> ShowS Source #

p_bundle :: Time -> [Message] -> Packet Source #

`Packet_Bundle` of `bundle`.

p_message :: Address_Pattern -> [Datum] -> Packet Source #

`Packet_Message` of `message`.

packetTime :: Packet -> Time Source #

The `Time` of `Packet`, if the `Packet` is a `Message` this is `immediately`.

packetMessages :: Packet -> [Message] Source #

Retrieve the set of `Message`s from a `Packet`.

packet_to_bundle :: Packet -> Bundle Source #

If `Packet` is a `Message` add `immediately` timestamp, else `id`.

packet_to_message :: Packet -> Maybe Message Source #

If `Packet` is a `Message` or a `Bundle` with an immediate time tag and with one element, return the `Message`, else `Nothing`.

packet_is_immediate :: Packet -> Bool Source #

Is `Packet` immediate, ie. a `Bundle` with timestamp `immediately`, or a plain Message.

at_packet :: (Message -> a) -> (Bundle -> a) -> Packet -> a Source #

Variant of `either` for `Packet`.

# Address Query

message_has_address :: Address_Pattern -> Message -> Bool Source #

Does `Message` have the specified `Address_Pattern`.

bundle_has_address :: Address_Pattern -> Bundle -> Bool Source #

Do any of the `Message`s at `Bundle` have the specified `Address_Pattern`.

packet_has_address :: Address_Pattern -> Packet -> Bool Source #

Does `Packet` have the specified `Address_Pattern`, ie. `message_has_address` or `bundle_has_address`.

# Pretty printing

messagePP :: FP_Precision -> Message -> String Source #

Pretty printer for `Message`.

bundlePP :: FP_Precision -> Bundle -> String Source #

Pretty printer for `Bundle`.

packetPP :: FP_Precision -> Packet -> String Source #

Pretty printer for `Packet`.