View Source OSC.Types.Integer (ex_osc v0.1.0)

Encoding and decoding of the OSC integer type.

OSC integers are encoded in 32-bit, signed, big-endian binary format. As such, the lowest possible integer is -2³¹ (min/0 = -2,147,483,648) and the highest is one less than 2³¹ (max/0 = 2,147,483,647).

Link to this section Summary

Types

t()

An OSC integer, represented by a signed 32-bit Elixir integer

Functions

Decodes an OSC integer to an Elixir integer.

Encodes an Elixir integer to an OSC integer type.

Returns the largest possible OSC integer (2**31 - 1).

Returns the smallest possible OSC integer (0 - 2**31).

Returns ?i, the type tag for the OSC integer type

Link to this section Types

@type t() :: -2_147_483_648..2_147_483_647

An OSC integer, represented by a signed 32-bit Elixir integer

Link to this section Functions

Decodes an OSC integer to an Elixir integer.

Returns {int, rest} where int is an integer decoded from the first four bytes of the input, and rest is a binary containing the remaining data.

examples

Examples

iex> <<0, 0, 0, 3>> |> OSC.Types.Integer.decode()
{3, ""}

iex> <<0, 1, 2, 3, 4, 5>> |> OSC.Types.Integer.decode()
{66051, <<4, 5>>}

Encodes an Elixir integer to an OSC integer type.

Returns a 32-bit big-endian-encoded integer.

Will raise an error if the integer is lower than min/0 or higher than max/0.

examples

Examples

iex> OSC.Types.Integer.encode(123)
<<0, 0, 0, 123>>

iex> OSC.Types.Integer.encode(-987)
<<255, 255, 252, 37>>

Returns the largest possible OSC integer (2**31 - 1).

iex> OSC.Types.Integer.max()
2_147_483_647

Returns the smallest possible OSC integer (0 - 2**31).

iex> OSC.Types.Integer.min()
-2_147_483_648

Returns ?i, the type tag for the OSC integer type

iex> <<OSC.Types.Integer.type_tag()>>
"i"