Encodes and decodes the OSC messages and bundles mx exchanges with other programs.

Integers are sent as int32, floats as float32 and strings as OSC strings. Bundle times are Unix microseconds, converted to and from NTP time tags.

Summary

Functions

Encodes encoded messages into a bundle stamped with a Unix time in microseconds.

Decodes a message as {address, args}, or a bundle as {:bundle, unix_us, elements}.

Encodes an OSC message to an address with its arguments.

Functions

bundle(unix_us, messages)

Encodes encoded messages into a bundle stamped with a Unix time in microseconds.

Examples

iex> bundle = bundle(1_000_000_000_250_000, [message("/status", [])])
iex> decode(bundle)
{:bundle, 1_000_000_000_250_000, [{"/status", []}]}

decode(packet)

Decodes a message as {address, args}, or a bundle as {:bundle, unix_us, elements}.

Examples

iex> decode(message("/s_new", ["beep", -1, 0.5]))
{"/s_new", ["beep", -1, 0.5]}

iex> decode(bundle(0, [message("/n_free", [1001])]))
{:bundle, 0, [{"/n_free", [1001]}]}

message(address, args)

Encodes an OSC message to an address with its arguments.

Examples

iex> message("/status", []) == "/status\0,\0\0\0"
true

iex> message("/s_new", ["beep", -1, 0.5]) ==
...>   "/s_new\0\0,sif\0\0\0\0beep\0\0\0\0" <> <<-1::signed-32, 0.5::float-32>>
true