Link Search Menu Expand Document

Remote Control

The two main ways to remote control score from the network are:

This page describes the low-level WebSocket API used by score, so that anyone can build their custom remotes similar to the one mentioned above..

Description

Exposes some properties of the score over WebSockets:

  • Transport.
  • Viewing and controlling triggers.
  • Sending & receiving messages through the Device Explorer.
  • Executing JS code in the console.

WebSocket API description

The message format is JSON.

Score -> client

{
    "Message": "DeviceTree"
}

When a trigger starts executing:

{
    "Message": "TriggerAdded",
    "Path": "/path/to/the/trigger"
}

When a trigger has finished executing:

{
    "Message": "TriggerRemoved",
    "Path": "/path/to/the/trigger"
}

When an interval starts executing:

{
    "Message": "IntervalAdded",
    "Path": "/path/to/the/interval",
    "Name": "machine_readable.name",
    "Label": "User-readable label",
    "Comment": "User-readable comment",
    "Speed": 1.2345
}

When an interval has finished executing:

{
    "Message": "IntervalRemoved",
    "Path": "/path/to/the/interval"
}

Heartbeat sent every few milliseconds:

{
    "Intervals": [ {
        "Path": "/path/to/the/interval",
        "Progress": 0.5,
        "Speed": 1.,
        "Gain": 0.8
    }, ...
    ]
}

Client -> score

Transport messages:

{ "Message": "Play" }

{ "Message": "Pause" }

{ "Message": "Stop" }

{
    "Message": "Transport",
    "Milliseconds": 40000
}

Console control:

See the Console API for the allowed operations.

{
  "Message": "Console",
  "Code": "someJSCodeToExecute()"
}

To trigger a trigger:

{
    "Message": "Trigger",
    "Path": "/path/to/the/trigger"
}

To slow down or speed up an interval:

{
    "Message": "IntervalSpeed",
    "Path": "/path/to/the/interval",
    "Speed": 0.5
}

To change the gain of an interval:

{
    "Message": "IntervalGain",
    "Path": "/path/to/the/interval",
    "Gain": 0.5
}

To send a control message:

{
    "Message": "Message",
    "Address": "device:/foo/bar@[color.rgb.r]",
    "Value": {
        "Float": 1.23
    }
}

or, to showcase all possible types:

{
    "Message": "Message",
    "Address": "device:/foo/bar",
    "Value": {
        "Tuple": [
            { "Int": 1 },
            { "Bool": true },
            { "Char": c },
            { "Vec2f": [0.0, 1.1] },
            { "Vec3f": [0.0, 1.1, 1.2] },
            { "Vec4f": [0.0, 1.1, 1.3, 1.4] },
            { "Float": 1.23 },
            { "String": "foo" },
            { "Impulse": null },
        ]
    }
}

To enable / disable listening

Listening to an address means that when an address’s value changes, the new value is forwarded to the remote client.

{
    "Message": "EnableListening",
    "Address": "device:/foo/bar"
}

and

{
    "Message": "DisableListening",
    "Address": "device:/foo/bar"
}

Control surface

See Control surface.