hosc-0.17: Haskell Open Sound Control

Safe Haskell | None
Language | Haskell98

Sound.OSC.Coding.Byte

Contents

- Encode
- Decode
- IO

Description

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

Synopsis

- encode_i8 :: Int -> ByteString
- encode_u8 :: Int -> ByteString
- encode_w16 :: Word16 -> ByteString
- encode_w16_le :: Word16 -> ByteString
- encode_u16 :: Int -> ByteString
- encode_u16_le :: Int -> ByteString
- encode_i16 :: Int -> ByteString
- encode_i32 :: Int -> ByteString
- encode_w32 :: Word32 -> ByteString
- encode_u32 :: Int -> ByteString
- encode_w32_le :: Word32 -> ByteString
- encode_u32_le :: Int -> ByteString
- encode_i64 :: Int64 -> ByteString
- encode_u64 :: Word64 -> ByteString
- encode_f32 :: Float -> ByteString
- encode_f32_le :: Float -> ByteString
- encode_f64 :: Double -> ByteString
- encode_str :: ByteString -> ByteString
- decode_u8 :: ByteString -> Int
- decode_i8 :: ByteString -> Int
- decode_word16 :: ByteString -> Word16
- decode_u16 :: ByteString -> Int
- decode_word16_le :: ByteString -> Word16
- decode_u16_le :: ByteString -> Int
- decode_int16 :: ByteString -> Int16
- decode_i16 :: ByteString -> Int
- decode_i16_le :: ByteString -> Int
- decode_i32 :: ByteString -> Int
- decode_word32 :: ByteString -> Word32
- decode_u32 :: ByteString -> Int
- decode_word32_le :: ByteString -> Word32
- decode_u32_le :: ByteString -> Int
- decode_i64 :: ByteString -> Int64
- decode_u64 :: ByteString -> Word64
- decode_f32 :: ByteString -> Float
- decode_f32_le :: ByteString -> Float
- decode_f64 :: ByteString -> Double
- decode_str :: ByteString -> ByteString
- read_i8 :: Handle -> IO Int
- read_i16 :: Handle -> IO Int
- read_i32 :: Handle -> IO Int
- read_u32 :: Handle -> IO Int
- read_u32_le :: Handle -> IO Int
- read_f32 :: Handle -> IO Float
- read_pstr :: Handle -> IO ByteString
- write_u32 :: Handle -> Int -> IO ()
- write_u32_le :: Handle -> Int -> IO ()
- bundleHeader_strict :: ByteString
- bundleHeader :: ByteString
- align :: (Num i, Bits i) => i -> i

# 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_i8 :: Handle -> IO Int Source #

`decode_i8` of `hGet`.

read_i16 :: Handle -> IO Int Source #

`decode_i16` of `hGet`.

read_i32 :: Handle -> IO Int Source #

`decode_i32` of `hGet`.

read_u32 :: Handle -> IO Int Source #

`decode_u32` of `hGet`.

read_u32_le :: Handle -> IO Int Source #

`decode_u32_le` of `hGet`.

read_f32 :: Handle -> IO Float Source #

`decode_f32` of `hGet`.

read_pstr :: Handle -> IO ByteString Source #

Read u8 length prefixed ASCII string (pascal string).

write_u32 :: Handle -> Int -> IO () Source #

`hPut` of `encode_u32`.

write_u32_le :: Handle -> Int -> IO () Source #

`hPut` of `encode_u32_le`.

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]