hosc-0.21.1: Haskell Open Sound Control

Safe Haskell | Safe-Inferred
Language | Haskell2010

Sound.Osc.Datum

Contents

- Datum
- Datum types
- Generalised element access
- Constructors
- Descriptor

Description

Osc data types.

Synopsis

- type DatumType = Char
- type Ascii = ByteString
- ascii :: String -> Ascii
- ascii_to_string :: Ascii -> String
- type Blob = ByteString
- blob_pack :: [Word8] -> Blob
- blob_pack_int :: [Int] -> Blob
- blob_unpack :: Blob -> [Word8]
- blob_unpack_int :: Blob -> [Int]
- data MidiData = MidiData !Word8 !Word8 !Word8 !Word8
- midi_pack :: [Word8] -> MidiData
- midi_pack_int :: [Int] -> MidiData
- midi_unpack_int :: MidiData -> [Int]
- type Time = Double
- data Datum
  - = Int32 {
    - d_int32 :: !Int32
    }
  - | Int64 {
    - d_int64 :: !Int64
    }
  - | Float {
    - d_float :: !Float
    }
  - | Double {
    - d_double :: !Double
    }
  - | AsciiString {
    - d_ascii_string :: !Ascii
    }
  - | Blob {
    - d_blob :: !Blob
    }
  - | TimeStamp {
    - d_timestamp :: !Time
    }
  - | Midi {
    - d_midi :: !MidiData
    }
- osc_types_required :: [(DatumType, String)]
- osc_types_optional :: [(DatumType, String)]
- osc_types :: [(DatumType, String)]
- osc_type_name :: DatumType -> Maybe String
- osc_type_name_err :: DatumType -> String
- datum_tag :: Datum -> DatumType
- datum_type_name :: Datum -> (DatumType, String)
- datum_integral :: Integral i => Datum -> Maybe i
- datum_floating :: Floating n => Datum -> Maybe n
- int32 :: Integral n => n -> Datum
- int64 :: Integral n => n -> Datum
- float :: Real n => n -> Datum
- double :: Real n => n -> Datum
- string :: String -> Datum
- midi :: (Word8, Word8, Word8, Word8) -> Datum
- blob :: [Word8] -> Datum
- signatureFor :: [Datum] -> String
- descriptor :: [Datum] -> Ascii
- descriptor_tags :: Ascii -> Ascii

# Datum

type DatumType = Char Source #

Type enumerating Datum categories.

type Ascii = ByteString Source #

Type for Ascii strings (strict Char8 ByteString)

ascii :: String -> Ascii Source #

Type-specialised pack.

ascii_to_string :: Ascii -> String Source #

Type-specialised unpack.

type Blob = ByteString Source #

Type for `Word8` arrays, these are stored with an `Int32` length prefix.

blob_pack :: [Word8] -> Blob Source #

Type-specialised pack.

blob_pack_int :: [Int] -> Blob Source #

Type-specialised pack.

blob_unpack :: Blob -> [Word8] Source #

Type-specialised unpack.

blob_unpack_int :: Blob -> [Int] Source #

Type-specialised unpack.

data MidiData Source #

Four-byte midi message: port-id, status-byte, data, data.

Constructors

MidiData !Word8 !Word8 !Word8 !Word8 |

#### Instances

Instances details

Read MidiData Source # |
Instance details Defined in Sound.Osc.Datum Methods readsPrec :: Int -> ReadS MidiData Source # readList :: ReadS [MidiData] Source # readPrec :: ReadPrec MidiData Source # readListPrec :: ReadPrec [MidiData] Source #
Show MidiData Source # |
Instance details Defined in Sound.Osc.Datum Methods showsPrec :: Int -> MidiData -> ShowS Source # show :: MidiData -> String Source # showList :: [MidiData] -> ShowS Source #
Eq MidiData Source # |
Instance details Defined in Sound.Osc.Datum Methods (==) :: MidiData -> MidiData -> Bool Source # (/=) :: MidiData -> MidiData -> Bool Source #
Ord MidiData Source # |
Instance details Defined in Sound.Osc.Datum Methods compare :: MidiData -> MidiData -> Ordering Source # (<) :: MidiData -> MidiData -> Bool Source # (<=) :: MidiData -> MidiData -> Bool Source # (>) :: MidiData -> MidiData -> Bool Source # (>=) :: MidiData -> MidiData -> Bool Source # max :: MidiData -> MidiData -> MidiData Source # min :: MidiData -> MidiData -> MidiData Source #

midi_pack :: [Word8] -> MidiData Source #

midi_pack_int :: [Int] -> MidiData Source #

Type-specialised pack.

midi_unpack_int :: MidiData -> [Int] Source #

Type-specialised unpack.

type Time = Double Source #

A real-valued time stamp. For Osc proper this is an Ntp64 time in real-valued (fractional) form. For SuperCollider Nrt programs this is elapsed time since the start of the score. This is the primary form of timestamp used by hosc.

data Datum Source #

The basic elements of Osc messages.

Constructors

Int32 |

Fields

- d_int32 :: !Int32

Int64 |

Fields

- d_int64 :: !Int64

Float |

Fields

- d_float :: !Float

Double |

Fields

- d_double :: !Double

AsciiString |

Fields

- d_ascii_string :: !Ascii

Blob |

Fields

- d_blob :: !Blob

TimeStamp |

Fields

- d_timestamp :: !Time

Midi |

Fields

- d_midi :: !MidiData

#### Instances

Instances details

Read Datum Source # |
Instance details Defined in Sound.Osc.Datum Methods readsPrec :: Int -> ReadS Datum Source # readList :: ReadS [Datum] Source # readPrec :: ReadPrec Datum Source # readListPrec :: ReadPrec [Datum] Source #
Show Datum Source # |
Instance details Defined in Sound.Osc.Datum Methods showsPrec :: Int -> Datum -> ShowS Source # show :: Datum -> String Source # showList :: [Datum] -> ShowS Source #
Eq Datum Source # |
Instance details Defined in Sound.Osc.Datum Methods (==) :: Datum -> Datum -> Bool Source # (/=) :: Datum -> Datum -> Bool Source #
Ord Datum Source # |
Instance details Defined in Sound.Osc.Datum Methods compare :: Datum -> Datum -> Ordering Source # (<) :: Datum -> Datum -> Bool Source # (<=) :: Datum -> Datum -> Bool Source # (>) :: Datum -> Datum -> Bool Source # (>=) :: Datum -> Datum -> Bool Source # max :: Datum -> Datum -> Datum Source # min :: Datum -> Datum -> Datum Source #

# Datum types

osc_types_required :: [(DatumType, String)] Source #

List of required data types (tag, name).

osc_types_optional :: [(DatumType, String)] Source #

List of optional data types (tag,name).

osc_types :: [(DatumType, String)] Source #

List of all data types (tag,name).

osc_type_name :: DatumType -> Maybe String Source #

Lookup name of type.

osc_type_name_err :: DatumType -> String Source #

Erroring variant.

datum_tag :: Datum -> DatumType Source #

Single character identifier of an Osc datum.

datum_type_name :: Datum -> (DatumType, String) Source #

Type and name of `Datum`.

# Generalised element access

datum_integral :: Integral i => Datum -> Maybe i Source #

`Datum` as `Integral` if Int32 or Int64.

    >>> let d = [Int32 5,Int64 5,Float 5.5,Double 5.5]
    >>> map datum_integral d == [Just (5::Int),Just 5,Nothing,Nothing]
    True

datum_floating :: Floating n => Datum -> Maybe n Source #

`Datum` as `Floating` if Int32, Int64, Float, Double or TimeStamp.

    >>> let d = [Int32 5,Int64 5,Float 5,Double 5,TimeStamp 5]
    >>> mapMaybe datum_floating d == replicate 5 (5::Double)
    True

# Constructors

int32 :: Integral n => n -> Datum Source #

Type generalised `Int32`.

    >>> int32 (1::Int32) == int32 (1::Integer)
    True

    >>> d_int32 (int32 (maxBound::Int32)) == maxBound
    True

    >>> int32 (((2::Int) ^ (64::Int))::Int) == Int32 0
    True

int64 :: Integral n => n -> Datum Source #

Type generalised Int64.

    >>> int64 (1::Int32) == int64 (1::Integer)
    True

    >>> d_int64 (int64 (maxBound::Int64)) == maxBound
    True

float :: Real n => n -> Datum Source #

Type generalised Float.

    >>> float (1::Int) == float (1::Double)
    True

    >>> floatRange (undefined::Float)
    (-125,128)

    >>> isInfinite (d_float (float (encodeFloat 1 256 :: Double)))
    True

double :: Real n => n -> Datum Source #

Type generalised Double.

    >>> double (1::Int) == double (1::Double)
    True

    >>> double (encodeFloat 1 256 :: Double) == Double 1.157920892373162e77
    True

string :: String -> Datum Source #

`AsciiString` of pack.

    >>> string "string" == AsciiString (ByteString.Char8.pack "string")
    True

midi :: (Word8, Word8, Word8, Word8) -> Datum Source #

Four-tuple variant of `Midi` `.` `MidiData`.

    >>> midi (0,0,0,0) == Midi (MidiData 0 0 0 0)
    True

blob :: [Word8] -> Datum Source #

`Blob` of `blob_pack`.

# Descriptor

signatureFor :: [Datum] -> String Source #

Message argument types are given by a signature.

    >>> signatureFor [Int32 1,Float 1,string "1"]
    ",ifs"

descriptor :: [Datum] -> Ascii Source #

The descriptor is an Ascii encoded signature.

    >>> descriptor [Int32 1,Float 1,string "1"] == ascii ",ifs"
    True

descriptor_tags :: Ascii -> Ascii Source #

Descriptor tags are `comma` prefixed.