Module losc.types

OSC Types.

The size of every atomic data type in OSC is a multiple of 32 bits.

Info:

  • Copyright: David Granström 2021
  • License: MIT
  • Author: David Granström

Functions

Types.get (tbl) Get available types.

Tables

Types.pack Type pack functions.
Types.unpack Type unpack functions.

Atomic types

Types.pack.i (value) 32-bit big-endian two's complement integer.
Types.unpack.i (data[, offset]) 32-bit big-endian two's complement integer.
Types.pack.f (value) 32-bit big-endian IEEE 754 floating point number.
Types.unpack.f (data[, offset]) 32-bit big-endian IEEE 754 floating point number.
Types.pack.s (value) String (null terminated)
Types.unpack.s (data[, offset]) String (null terminated)
Types.pack.b (value) Blob (arbitrary binary data)
Types.unpack.b (data[, offset]) Blob (arbitrary binary data)

Extended types

Types.pack.h (value) 64 bit big-endian two's complement integer.
Types.unpack.h (data[, offset]) 64 bit big-endian two's complement integer.
Types.pack.t (value) Timetag (64-bit integer divided into upper and lower part)
Types.unpack.t (data[, offset]) Timetag (64-bit integer divided into upper and lower part)
Types.pack.d (value) 64-bit big-endian IEEE 754 floating point number.
Types.unpack.d (data[, offset]) 64-bit big-endian IEEE 754 floating point number.
Types.unpack.T (_[, offset]) Boolean true.
Types.unpack.F (_[, offset]) Boolean false.
Types.unpack.N (_[, offset]) Nil.
Types.unpack.I (_[, offset]) Infinitum.


Functions

Types.get (tbl)
Get available types.

Parameters:

Returns:

    Table with available types.

Usage:

  • local types = Types.types(Types.pack)
  • local types = Types.types(Types.unpack)

Tables

Types.pack
Type pack functions.

Custom pack functions can be added to this table and standard functions can be re-assigned if necessary.

This table can be called to pack a value in protected mode (pcall).

Usage:

    local ok, data = Types.pack('s', 'hello')
    if ok then
      -- do something with data.
    end
Types.unpack
Type unpack functions.

Custom unpack functions can be added to this table and standard functions can be re-assigned if necessary.

This table can be called to unpack a value in protected mode (pcall).

Usage:

    local ok, value, index = Types.unpack('s', data, 1)
    if ok then
      -- do something with value/index.
    end

Atomic types

Types.pack.i (value)
32-bit big-endian two's complement integer.

Parameters:

  • value The value to pack.

Returns:

    Binary string buffer.
Types.unpack.i (data[, offset])
32-bit big-endian two's complement integer.

Parameters:

  • data The data to unpack.
  • offset Initial offset into data. (optional)

Returns:

    value, index of the bytes read + 1.
Types.pack.f (value)
32-bit big-endian IEEE 754 floating point number.

Parameters:

  • value The value to pack.

Returns:

    Binary string buffer.
Types.unpack.f (data[, offset])
32-bit big-endian IEEE 754 floating point number.

Parameters:

  • data The data to unpack.
  • offset Initial offset into data. (optional)

Returns:

    value, index of the bytes read + 1.
Types.pack.s (value)
String (null terminated)

Parameters:

  • value The value to pack.

Returns:

    Binary string buffer.
Types.unpack.s (data[, offset])
String (null terminated)

Parameters:

  • data The data to unpack.
  • offset Initial offset into data. (optional)

Returns:

    value, index of the bytes read + 1.
Types.pack.b (value)
Blob (arbitrary binary data)

Parameters:

  • value The value to pack.

Returns:

    Binary string buffer.
Types.unpack.b (data[, offset])
Blob (arbitrary binary data)

Parameters:

  • data The data to unpack.
  • offset Initial offset into data. (optional)

Returns:

    value, index of the bytes read + 1.

Extended types

Types.pack.h (value)
64 bit big-endian two's complement integer.

NOTE This type is only supported for lua >= 5.3.

Parameters:

  • value The value to pack.

Returns:

    Binary string buffer.
Types.unpack.h (data[, offset])
64 bit big-endian two's complement integer.

NOTE This type is only supported for lua >= 5.3.

Parameters:

  • data The data to unpack.
  • offset Initial offset into data. (optional)

Returns:

    value, index of the bytes read + 1.
Types.pack.t (value)
Timetag (64-bit integer divided into upper and lower part)

Parameters:

  • value Table with seconds and fractions.

Returns:

    Binary string buffer.

See also:

Types.unpack.t (data[, offset])
Timetag (64-bit integer divided into upper and lower part)

Parameters:

  • data The data to unpack.
  • offset Initial offset into data. (optional)

Returns:

    value, index of the bytes read + 1.

See also:

Types.pack.d (value)
64-bit big-endian IEEE 754 floating point number.

Parameters:

  • value The value to pack.

Returns:

    Binary string buffer.
Types.unpack.d (data[, offset])
64-bit big-endian IEEE 754 floating point number.

Parameters:

  • data The data to unpack.
  • offset Initial offset into data. (optional)

Returns:

    value, index of the bytes read + 1.
Types.unpack.T (_[, offset])
Boolean true. This type does not have a corresponding pack method.

Parameters:

  • _ Not used.
  • offset Initial offset into data. (optional)

Returns:

    true (boolean) and byte offset (not incremented).
Types.unpack.F (_[, offset])
Boolean false. This type does not have a corresponding pack method.

Parameters:

  • _ Not used.
  • offset Initial offset into data. (optional)

Returns:

    false (boolean) and byte offset (not incremented).
Types.unpack.N (_[, offset])
Nil. This type does not have a corresponding pack method.

Parameters:

  • _ Not used.
  • offset Initial offset into data. (optional)

Returns:

    false (since nil cannot be represented in a lua table) and byte offset (not incremented).
Types.unpack.I (_[, offset])
Infinitum. This type does not have a corresponding pack method.

Parameters:

  • _ Not used.
  • offset Initial offset into data. (optional)

Returns:

    math.huge and byte offset (not incremented).
generated by LDoc 1.4.6 Last updated 2021-02-01 17:13:04