hosc-0.17: Haskell Open Sound Control

Safe HaskellNone
LanguageHaskell98

Sound.OSC.Coding.Byte

Contents

Description

Byte-level coding utility functions. Plain forms are big-endian, little-endian forms have _le suffix.

Synopsis

Encode

encode_i8 :: Int -> ByteString Source #

Encode a signed 8-bit integer.

encode_u8 :: Int -> ByteString Source #

Encode an un-signed 8-bit integer.

encode_w16 :: Word16 -> ByteString Source #

Type specialised encode.

encode_w16 0x0102 == L.pack [1,2]

encode_w16_le :: Word16 -> ByteString Source #

Little-endian.

encode_w16_le 0x0102 == L.pack [2,1]

encode_u16 :: Int -> ByteString Source #

Encode an un-signed 16-bit integer.

encode_u16 0x0102 == L.pack [1,2]

encode_u16_le :: Int -> ByteString Source #

Little-endian.

encode_u16_le 0x0102 == L.pack [2,1]

encode_i16 :: Int -> ByteString Source #

Encode a signed 16-bit integer.

encode_i32 :: Int -> ByteString Source #

Encode a signed 32-bit integer.

encode_w32 :: Word32 -> ByteString Source #

Type specialised encode.

encode_u32 :: Int -> ByteString Source #

Encode an unsigned 32-bit integer.

encode_u32 0x01020304 == L.pack [1,2,3,4]

encode_w32_le :: Word32 -> ByteString Source #

Little-endian variant of encode_w32.

encode_u32_le :: Int -> ByteString Source #

Little-endian.

encode_u32_le 0x01020304 == L.pack [4,3,2,1]

encode_i64 :: Int64 -> ByteString Source #

Encode a signed 64-bit integer.

encode_u64 :: Word64 -> ByteString Source #

Encode an unsigned 64-bit integer.

encode_f32 :: Float -> ByteString Source #

Encode a 32-bit IEEE floating point number.

encode_f32_le :: Float -> ByteString Source #

Little-endian variant of encode_f32.

encode_f64 :: Double -> ByteString Source #

Encode a 64-bit IEEE floating point number.

encode_str :: ByteString -> ByteString Source #

Encode an ASCII string (ASCII at Datum is an alias for a Char8 Bytetring).

Decode

decode_u8 :: ByteString -> Int Source #

Decode an un-signed 8-bit integer.

decode_i8 :: ByteString -> Int Source #

Decode a signed 8-bit integer.

decode_word16 :: ByteString -> Word16 Source #

Type specialised decode.

decode_u16 :: ByteString -> Int Source #

Decode an unsigned 8-bit integer.

decode_word16_le :: ByteString -> Word16 Source #

Little-endian variant of decode_word16.

decode_u16_le :: ByteString -> Int Source #

Little-endian variant of decode_u16.

decode_int16 :: ByteString -> Int16 Source #

Type specialised decode.

decode_i16 :: ByteString -> Int Source #

Decode a signed 16-bit integer.

decode_i16_le :: ByteString -> Int Source #

Little-endian variant of decode_i16.

decode_i32 :: ByteString -> Int Source #

Decode a signed 32-bit integer.

decode_word32 :: ByteString -> Word32 Source #

Type specialised decode.

decode_u32 :: ByteString -> Int Source #

Decode an unsigned 32-bit integer.

decode_u32 (L.pack [1,2,3,4]) == 0x01020304

decode_word32_le :: ByteString -> Word32 Source #

Little-endian variant of decode_word32.

decode_u32_le :: ByteString -> Int Source #

Little-endian variant of decode_u32.

decode_u32_le (L.pack [1,2,3,4]) == 0x04030201

decode_i64 :: ByteString -> Int64 Source #

Type specialised decode.

decode_u64 :: ByteString -> Word64 Source #

Type specialised decode.

decode_f32 :: ByteString -> Float Source #

Decode a 32-bit IEEE floating point number.

decode_f32_le :: ByteString -> Float Source #

Little-endian variant of decode_f32.

decode_f64 :: ByteString -> Double Source #

Decode a 64-bit IEEE floating point number.

decode_str :: ByteString -> ByteString Source #

Decode an ASCII string, inverse of encode_str.

IO

read_pstr :: Handle -> IO ByteString Source #

Read u8 length prefixed ASCII string (pascal string).

bundleHeader_strict :: ByteString Source #

Bundle header as a (strict) ByteString.

bundleHeader :: ByteString Source #

Bundle header as a lazy ByteString.

align :: (Num i, Bits i) => i -> i Source #

The number of bytes required to align an OSC value to the next 4-byte boundary.

map align [0::Int .. 7] == [0,3,2,1,0,3,2,1]