# `Mx.OSC`
[🔗](https://github.com/mx-music/mx/blob/main/lib/mx/osc.ex#L1)

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.

# `bundle`

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`

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`

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
