Module losc.message
OSC Message.
An OSC message consists of an OSC Address Pattern followed by an OSC Type Tag String followed by zero or more OSC Arguments.
Info:
- Copyright: David Granström 2021
- License: MIT
- Author: David Granström
High level API
Message.new ([msg]) | Create a new OSC message. |
Message:add (type[, item]) | Add arguments to the message. |
Message:iter () | Message iterator. |
Message:address () | Get the OSC address. |
Message:types () | Get the OSC type string. |
Message:args () | Get the OSC arguments. |
Message.validate (message) | Validate a message. |
Low level API
Message.address_validate (addr) | Validate an OSC message address. |
Message.tbl_validate (tbl) | Validate a table to be used as a message constructor. |
Message.bytes_validate (bytes[, offset]) | Validate a binary string to see if it is a valid OSC message. |
Message.pack (tbl) | Pack a table to a byte string. |
Message.unpack (data, offset) | Unpack OSC message byte string. |
High level API
- Message.new ([msg])
-
Create a new OSC message.
Parameters:
Returns:
-
An OSC message object.
See also:
Usage:
local msg = Message.new()
local msg = Message.new('/some/addr')
local tbl = {address = '/some/addr', types = 'ifs', 1, 2.0, 'hi'} local msg = Message.new(tbl)
- Message:add (type[, item])
-
Add arguments to the message.
Parameters:
- type OSC type string.
- item Item to add. (optional)
See also:
Usage:
message:add('i', 123)
message:add('T')
- Message:iter ()
-
Message iterator.
Iterate over message types and arguments.
Returns:
-
iterator using index, type, argument.
Usage:
for i, type, arg in message:iter() do print(i, type, arg) end
- Message:address ()
-
Get the OSC address.
Returns:
-
The OSC address.
- Message:types ()
-
Get the OSC type string.
Returns:
-
OSC type string or empty string.
- Message:args ()
-
Get the OSC arguments.
Returns:
-
Table with arguments.
- Message.validate (message)
-
Validate a message.
Parameters:
Low level API
- Message.address_validate (addr)
-
Validate an OSC message address.
Parameters:
- addr string The address to validate.
- Message.tbl_validate (tbl)
-
Validate a table to be used as a message constructor.
Parameters:
- tbl table The table to validate.
- Message.bytes_validate (bytes[, offset])
-
Validate a binary string to see if it is a valid OSC message.
Parameters:
- bytes string The byte string to validate.
- offset integer Byte offset. (optional)
- Message.pack (tbl)
-
Pack a table to a byte string.
The returned object is suitable for sending via a transport layer such as UDP or TCP.
Call
Message.validate()
before passing arguments to this function to ensure that the table is suitable for packing.Parameters:
- tbl The content to pack.
Returns:
-
OSC data packet (byte string).
- Message.unpack (data, offset)
-
Unpack OSC message byte string.
Call
Message.validate()
before passing arguments to this function to ensure that the table is suitable for unpacking.Parameters:
- data The data to unpack.
- offset The initial offset into data.
Returns:
-
table with the content of the OSC message.