LEA-Open-API-Websockets-June-2020
LEA-Open-API-Websockets-June-2020
Websocket Protocol
Rev 1. 06-01-2020
Introduction
Websockets are used as the transport for the LEA WebUI. Websockets are convenient since
they combine the reliability of TCP with the notion of message boundaries. The LEA Connect
Series products utilize JSON-RPC protocol and can be controlled and monitored from any device
that is capable of sending and receiving JSON-RPC messages. The LEA Connect Series products
offer an Open API via websockets, so any parameter that can be controlled and/or monitored
via the WebUI can be controlled and monitored by any other device that communicates via
websockets.
The LEA Connect Amplifiers use port 1234 for websocket communication
Any LEA Connect Firmware version accepts Websocket communication, however new
features will be added in the future and will be included in future firmware versions.
LEA amplifiers typically act in the server role, while UIs and other devices act in the client role. It
is also possible for devices to interact peer-to-peer, either over a single web/tcp socket or a pair
of web/tcp sockets.
1|Page
LEA Open API -
Websocket Protocol
Rev 1. 06-01-2020
An example LEA Websocket API message looks like this. In this case, a request to set an amp's
channel 1’s mute status from mute off (False) to mute on (True)
{
"leaApi": "1.0",
"url": "amp/channels/1/output",
"method": "set",
"params": {"mute":true},
"id": 1
}
{
"leaApi": "1.0",
"url": "amp/channels/1/output",
"result": "OK",
"id": 1
}
{ Opening bracket
"params": "mute":true}, (The parameter and what you want to do with it)
} Closing bracket
2|Page
LEA Open API -
Websocket Protocol
Rev 1. 06-01-2020
Resources are divided into chunks called objects. At the top of the tree diagram above is the
root object, specified by 'url'="/". Objects farthest way from the root on a given branch are
called leaf objects. An example of a leaf object in the diagram is the object with
'url'="/amp/channel1/output" at bottom-right. All of the resources in a server are contained in
the leaf objects. The root and other non-leaf objects are just containers for other objects. In
terms of the API, this means that methods operate on leaves.
Many leaf objects support another level of hierarchy in the form of set of 'elements' that be
accessed via the message parameters. For such objects, there is a one-to-one correspondence
between parameters and elements. Essentially all of the audio processing objects are
constructed this way.
3|Page
LEA Open API -
Websocket Protocol
Rev 1. 06-01-2020
To obtain all parameters of the Connect Series Amplifiers, simply send this websocket request:
{
"leaApi": "1.0",
"url": "/",
"method": "info",
"params": {},
"id": 1
}
To obtain all the parameters for just the “amp” portion, simply send this websocket request:
{
"leaApi": "1.0",
"url": "/amp",
"method": "info",
"params": {},
"id": 1
}
To obtain all the parameters for just the “input” portion of the “amp,” simply send this
websocket request:
{
"leaApi": "1.0",
"url": "/amp/inputs",
"method": "info",
"params": {},
"id": 1
}
4|Page
LEA Open API -
Websocket Protocol
Rev 1. 06-01-2020
After you have received the parameter’s info, it will tell you what each parameter supports
from a Get, Set, Subscribe or Unsubscribe standpoint. Here’s an example from the /amp/inputs
info request:
{
"leaApi": "1.0",
"url": "/amp/inputs",
"result": {
"dante": {
"1": {
"methods": [
"get",
"set",
"subscribe",
"unsubscribe"
],
}
In this case you can Get Channel 1 Dante information, you can Set Channel 1 Dante info, you
can Subscribe to Channel 1 Dante so if this changes, you will be notified, and if you’ve
subscribed to this parameter, you can unsubscribe.
Here’s and example to Get, Set, Subscribe and Unsubscribe to Channel 1 Output Level:
Channel 1 output level is located here /amp/channels/1/output. If we do an info request for
this url, we get the following information back from the amplifier for the output fader:
"fader": {
"type": "Float",
"control": true,
"min": -80.0,
"max": 0.0,
"default": 0.0,
"multipleOf": 0.10000000149011612,
"units": "dB"
5|Page
LEA Open API -
Websocket Protocol
Rev 1. 06-01-2020
This is saying the fader has a max value of 0dB, a min value of -80dB with increments of 0.1dB.
If I want to set the channel 1 output fader to -3.0dB, I send this SET command:
{
"leaApi": "1.0",
"url": "/amp/channels/1/output",
"method": "set",
"params": {"fader":-3.0},
"id": 1
}
The amplifier responds with the following websocket message to let you know channel 1
output fader has been set to -3.0dB:
{
"leaApi": "1.0",
"url": "/amp/channels/1/output",
"result": "OK",
"id": 1
}
To get the value for the channel 1 output to confirm the change was made, type the GET
command for channel 1 output:
{
"leaApi": "1.0",
"url": "/amp/channels/1/output",
"method": "get",
"params": {},
"id": 1
}
6|Page
LEA Open API -
Websocket Protocol
Rev 1. 06-01-2020
Once you send this GET Command, you receive the following information back from the
amplifier and you can confirm the output fader:
{
"leaApi": "1.0",
"url": "/amp/channels/1/output",
"result": {
"name": "OutputName",
"ZoneName": "ZoneName",
"enable": true,
"status": "Ok",
"mute": true,
"fader": -3.0,
"zoneFader": 0.0,
"backpanelPotAttn": 0.0,
"super8": false,
"hiZLoZ": "HiZ-100V",
"hiZHpfEnable": true,
"hiZHpfFrequency": 50.0,
"clipLimiterEnable": false,
"fault": false,
"thermal": false,
"limiting": false,
"clip": false,
"signalDetect": false,
"ready": true,
"autoStandbyActive": false
},
"id": 1
}
The channel 1 output fader object above supports methods 'get', 'set', 'subscribe' and
'unsubscribe'. The 'get' and 'set' messages need little explanation, except to note that the use
of 'get' is strongly discouraged in other than development and test scenarios. In place of 'get',
production clients should use 'subscribe', which is described later. Here are some
representative 'get' and 'set' requests, along with server responses:
7|Page
LEA Open API -
Websocket Protocol
Rev 1. 06-01-2020
• The values of some elements representing measured quantities (aka 'sensors') are
updated asynchronously when new measurement values are obtained (e.g. an audio
level meter). A client uses subscriptions to request server notifications when such
updates occur.
• In a multi-client environment, changes made by one client need to be seen by other
clients. The subscription mechanism is used to propogate such changes.
Server notifications contain the 'notify' method. Here is an example of a client subscribing to a
particular object:
'subscribe' request
{
"leaApi": "1.0",
"url": "/amp/channels/1/rmsLimiter",
"method": "subscribe",
"params": {},
"id": 13
}
{
"leaApi": "1.0",
"url": "/amp/channels/1/rmsLimiter",
"result": {
"enable": false,
"threshold": 151.0,
"attackTime": 0.019999999552965164,
"releaseTime": 0.0010000000474974513,
"gainReduction": -80.0,
"totalGainReduction": -80.0
},
"id": 13
}
8|Page
LEA Open API -
Websocket Protocol
Rev 1. 06-01-2020
9|Page
LEA Open API -
Websocket Protocol
Rev 1. 06-01-2020
A good tool to use to test websockets from your computer is the Simple Websocket Client for
Google Chrome Browsers:
https://chrome.google.com/webstore/detail/simple-websocket-
client/pfdhoblngboilpfeibdedpjgfnlcodoo
10 | P a g e