hosc-0.21: Haskell Open Sound Control
Safe HaskellSafe-Inferred
LanguageHaskell2010

Sound.Osc.Datum

Description

Osc data types.

Synopsis

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 Datum 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

Show MidiData Source # 
Instance details

Defined in Sound.Osc.Datum

Eq MidiData Source # 
Instance details

Defined in Sound.Osc.Datum

Ord MidiData Source # 
Instance details

Defined in Sound.Osc.Datum

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

Int64 

Fields

Float 

Fields

Double 

Fields

AsciiString 

Fields

Blob 

Fields

TimeStamp 

Fields

Midi 

Fields

Instances

Instances details
Read Datum Source # 
Instance details

Defined in Sound.Osc.Datum

Show Datum Source # 
Instance details

Defined in Sound.Osc.Datum

Methods

showsPrec :: Int -> Datum -> ShowS #

show :: Datum -> String #

showList :: [Datum] -> ShowS #

Eq Datum Source # 
Instance details

Defined in Sound.Osc.Datum

Methods

(==) :: Datum -> Datum -> Bool #

(/=) :: Datum -> Datum -> Bool #

Ord Datum Source # 
Instance details

Defined in Sound.Osc.Datum

Methods

compare :: Datum -> Datum -> Ordering #

(<) :: Datum -> Datum -> Bool #

(<=) :: Datum -> Datum -> Bool #

(>) :: Datum -> Datum -> Bool #

(>=) :: Datum -> Datum -> Bool #

max :: Datum -> Datum -> Datum #

min :: Datum -> Datum -> Datum #

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 Datum.

>>> 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

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.