TouchOSC

Next generation modular control surface
TouchOSC Manual

Script · Global Functions


TouchOSC provides the following global functions.



Utililty Functions

getVersion()

Returns a list containing the application's version as major minor patch build number values stored in sequential order.

getMillis()

Returns the number of milliseconds since application start.

getDate()

Returns a list with the current local date's year month day tzd number values stored in sequential order. tzd refers to the timezone differential in seconds.

getTime()

Returns a list with the current local time's hour minute second millisecond number values stored in sequential order.

hasAccelerometer()

Returns true if the host device provides an accelerometer sensor, false otherwise.

getAccelerometer()

Returns a list of three number values that are sampled from the host device's accelerometer sensor. If no accelerometer sensor is available, the values will be all zero.

hasGyroscope()

Returns true if the host device provides a gyroscope sensor, false otherwise.

getGyroscope()

Returns a list of three number values that are sampled from the host device's gyroscope sensor. If no gyroscope sensor is available, the values will be all zero.

getBatteryLevel()

Returns the current battery charge level as a number ranging from 0.0 to 1.0 on mobile devices, 1.0 otherwise.

bytesToInt(number, number, number, number)

Returns a number that is the 32-bit integer representation created from the four byte number parameter values.

bytesToFloat(number, number, number, number)

Returns a number that is the 32-bit floating point representation created from the four byte number parameter values.

 


Message Functions

TouchOSC provides the following functions to send MIDI and OSC messages.

 

MIDI Messages

sendMIDI(table [, table])

Send a MIDI message on one or multiple configured connections.

The first argument table is a list of byte values that make up the MIDI message.

The optional second argument table is a list of boolean values that specify which connections to send the message on. If the argument is omitted, the default is to broadcast the message on all configured connections. If the table has less than five elements, the omitted elements default to false.

See the Sending MIDI Messages example.

 

Simple OSC Messages

sendOSC(string [, ... [, table]])

Send an OSC message on one or multiple configured connections.

string is the path of the OSC message to be sent.

The optional argument values ... will be auto-converted to boolean, float or string OSC types and added to the OSC message as arguments.

Note that argument values are never auto-converted to integer OSC types as scripts do not treat floating point and integer numbers as separate types. Use the complex OSC message send function instead.

The optional last argument table is a list of boolean values that specify which connections to send the message on. If the argument is omitted, the default is to broadcast the message on all configured connections. If the table has less than five elements, the omitted elements default to false.

See the Sending OSC Messages example.

 

Complex OSC Messages

sendOSC(table [, table])

Sends an OSC message on one or multiple configured connections.

The first argument table is a list that represents the OSC message to be sent, where the first element is the path string of the message, and the second element is a list of argument tables with tag and value keys for each argument:

{
    path,
    {
        { tag = 'argumentTypeTag', value = argumentValue },
        { tag = 'argumentTypeTag', value = argumentValue },
        { tag = 'argumentTypeTag', value = argumentValue },
        ...
    }
}

Each argument value will be converted to an OSC type according to the type tag string provided:

Tag OSC Type
T Boolean true
F Boolean false
N Nil
I Infinitum
i int32
h int64
f float32
d double
s string
b blob

If the tag key is omitted, the value will be auto-converted the same way as when sending simple OSC messages.

The T F N and I types do not need a value to be specified.

The b OSC blob type expects the value to be a list of byte values making up the blob data.

The optional second argument table is a list of boolean values that specify which connections to send the message on. If the argument is omitted, the default is to broadcast the message on all configured connections. If the table has less than five elements, the omitted elements default to false.

See the Sending OSC Messages example.


hexler.net uses cookies to deliver website content. By continuing without changing your preferences, you agree to our use of cookies.