MA2 & MA3 plugins

SendOSC

1.0

This MA2 plugin lets you send OSC commands.

SendOSC supports both using the plugin in Macros or running in your own LUA script. It also handles MA variables.

SendOSC currently supports the following data types:

  • i: Int32
  • f: Float
  • s: String
  • T: True
  • F: False
  • N: Null
  • I: Impulse
By default, SendOSC uses UDP (with HOST:PORT syntax). If you want to send packets via TCP, put an extra colon (:) between the HOST and PORT like: HOST::PORT, 127.0.0.1::8000
TCP mode is experimental.

Macro syntax

To send OSC commands from your macros you can use the following syntax: Plugin SendOSC "host_port, /OSC_address, values"

If you do not provide type for a given value, the plugin will try to guess the type.

For example: Plugin SendOSC "127.0.0.1:8000, /this_is_a_float, 5.6"
Plugin SendOSC "127.0.0.1:8000, /this_is_an_integer, 56"
Plugin SendOSC "127.0.0.1:8000, /this_is_a_string,Hello World!"
Plugin SendOSC "127.0.0.1:8000, /this_is_a_bool, true"

You can provide type by using the equal sign in the format of t=value where t is one of i, f, s, T, F, N, I. Plugin SendOSC "127.0.0.1:8000, /this_is_a_float, f=1"
Plugin SendOSC "127.0.0.1:8000, /this_is_an_integer, i=1.0"
Plugin SendOSC "127.0.0.1:8000, /this_is_an_integer, T=999"
Note that value is omitted in case of types T, F, N, I.

You can pass multiple values using comma: Plugin SendOSC "127.0.0.1:8000, /multiple/float/true/string, f=1, true, Hello World!"
Plugin SendOSC "127.0.0.1:8000, /multiple/floats, 0.85, 0.65, 0.0"

LUA syntax

You can use SendOSC in your own script.

If you have SendOSC Plugin in your Plugin Pool it will define a SendOSC function which can be called just as the plugin itself.

SendOSC LUA Function accepts either one or three parameters. If you provide one parameter, you can refer to the command line syntax. If you provide three parameters, they would be: SendOSC(host_port, osc_address, data)

where data can be any of the following, or an array of the following: number, boolean, nil, string, or a table containing type definition in the format of {t=value} where t is one of i, f, s, T, F, N, I.

If you do not provide type for a given value, the plugin will try to guess the type.

Examples of LUA data:

String can be parsed just as if you used one parameter: SendOSC('127.0.0.1:8000', '/this_is_a_string', 'Hello World!')
SendOSC('127.0.0.1:8000', '/this_is_an integer', '1')
SendOSC('127.0.0.1:8000', '/this_is_a_float', '1.0')
SendOSC('127.0.0.1:8000', '/multiple_params', '1,1.0,f=1.0,etc.')

Passed numbers' type interpretation depends on if it is whole or not: SendOSC('127.0.0.1:8000', '/this_is_an_integer', 1.0)
SendOSC('127.0.0.1:8000', '/this_is_a_float', 0.9)

These are all nulls:
SendOSC('127.0.0.1:8000', '/this_is_null', nil)
SendOSC('127.0.0.1:8000', '/this_is_null', 'nil')
SendOSC('127.0.0.1:8000', '/this_is_null', 'Null')

These are all booleans: SendOSC('127.0.0.1:8000', '/this_is_true', true)
SendOSC('127.0.0.1:8000', '/this_is_true', 'TRUE')
SendOSC('127.0.0.1:8000', '/this_is_false', 'false')

You can specify types by passing a table in {t=value} format, where t represents the type: SendOSC('127.0.0.1:8000', '/this_is_a_string', {s=1.0})
SendOSC('127.0.0.1:8000', '/this_is_an_integer', {i='1.0'})
SendOSC('127.0.0.1:8000', '/this_is_a_boolean', {T='1.0'})
Note that value is omitted in case of types T, F, N, I.

You can specify multiple values by passing them in an array: SendOSC('127.0.0.1:8000', '/multiple', {true, 1, '1.0', {f=1}, {s='Hello, '}, 'World!'})

Type auto-recognition

If you do not explicitly provide type for a given value, the plugin will try to guess the type.

Rules for this are:

  • If the string contains "true", "false", "nil" or "null" these will be types "T", "F", "N" respectively. This is case-insensitive.
  • If the string can be parsed as a number, it will be: a Float if it contains a dot, an Int if it does not.
  • Otherwise the string will be sent as a String.
  • If the given LUA parameter is a number, it will be a float, if it is not a whole number or an Int if it is a whole number.
  • If the given LUA parameter is a boolean or a nil, it will be sent as "T", "F", "N" accordingly.
Auto-recognition is done after variable substitution.

Variable substitution

If any of the strings passed contains a dollar sign followed by an alphanumerical string, it will be substitued with the corresponding MA2 variable.

For example, you can use this to store destination IP and PORT in a variable and use the variable in your macros.

Examples:

Use variable in your showfile as a destination IP/PORT setting: LUA "SendOSC('$MEDIASERVER', '/this_is_a_float', {f=1})"
Plugin SendOSC "$MEDIASERVER, /this_is_a_float, f=1"
Plugin SendOSC "$MEDIASERVERIP:8123, /this_is_a_float, f=1"
Plugin SendOSC "$MEDIASERVERIP:$MEDIASERVERPORT, /this_is_a_float, f=1"

Use variable in your showfile as an element in the OSC address: LUA "SendOSC('$MEDIASERVER', '/composition/$MEDIAID/connect', 1)"

Use variable in your showfile as a value: LUA "SendOSC('127.0.0.1:8000', '/selected_fixtures_count', {i='$SELECTEDFIXTURESCOUNT'})"
Plugin SendOSC "127.0.0.1:8000, /selected_exec_cue, $SELECTEDEXECCUE"

€10