The handle to receive Open Sound Control (OSC) messages. This handle can be obtained by PlayerScript.oscHandle.

For more information about OSC, refer to the OpenSoundControl Specification 1.0.

Hierarchy

  • OscHandle

Methods

  • Gets whether the user has enabled OSC input.

    You can set it from "Enable OSC Input" in the "Other" tab of "Settings".

    Returns boolean

  • Registers a callback to be called when an OSC message is received. The callback is called with an array of OscMessage received between the previous frame and the current frame. If called multiple times, only the last registration is valid.

    However, the callback is not called if any of the following conditions are met:

    • When isReceiveEnabled is false
    • When the network settings such as a firewall prevent receiving OSC messages
    • When the address of the received OSC message starts with /cluster/ (reserved by the system)

    Example

    // Log the received OSC messages
    _.oscHandle.onReceive(messages => {
    const lines = [];

    messages.forEach((message, i) => {
    const { address, timestamp, values } = message;

    lines.push(`== message [${i + 1}/${messages.length}]`);
    lines.push(`address: ${address}`);
    lines.push(`timestamp: ${new Date(timestamp).toLocaleString()}`);

    values.forEach((value, j) => {
    lines.push(`= value [${j + 1}/${values.length}]`);

    lines.push(`getInt(): ${value.getInt()}`);
    lines.push(`getFloat(): ${value.getFloat()}`);
    lines.push(`getAsciiString(): ${value.getAsciiString()}`);
    lines.push(`getBlobAsUint8Array(): ${value.getBlobAsUint8Array()}`);
    lines.push(`getBlobAsUtf8String(): ${value.getBlobAsUtf8String()}`);
    lines.push(`getBool(): ${value.getBool()}`);
    });
    });

    _.log(lines.join("\n"));
    });

    Parameters

    • callback: ((messages: OscMessage[]) => void)

      messages: The array of received OSC messages.

    Returns void

Generated using TypeDoc