diff --git a/docs/JSON-RPC.md b/docs/JSON-RPC.md index c5f6aa37d0..84271b66a8 100644 --- a/docs/JSON-RPC.md +++ b/docs/JSON-RPC.md @@ -222,6 +222,24 @@ Results: | result | string | Always "ok". | +### jamulusclient/setFaderLevel + +Sets the fader level. Example: {"id":1,"jsonrpc":"2.0","method":"jamulusclient/setFaderLevel","params":{"channelIndex": 0,"level": 50}}. + +Parameters: + +| Name | Type | Description | +| --- | --- | --- | +| params.channelIndex | number | The channel index of the fader to be set. | +| params.level | number | The fader level in range 0..100. | + +Results: + +| Name | Type | Description | +| --- | --- | --- | +| result | string | Always "ok". | + + ### jamulusclient/setName Sets your name. diff --git a/src/client.h b/src/client.h index 344db5163d..f78ce8aba7 100644 --- a/src/client.h +++ b/src/client.h @@ -260,6 +260,8 @@ class CClient : public QObject void OnTimerRemoteChanGainOrPan(); void StartTimerGainOrPan(); + void SetControllerInFaderLevel ( int iChannelIdx, int iValue ) { OnControllerInFaderLevel ( iChannelIdx, iValue ); } + void SetInputBoost ( const int iNewBoost ) { iInputBoost = iNewBoost; } void SetRemoteInfo() { Channel.SetRemoteInfo ( ChannelInfo ); } diff --git a/src/clientrpc.cpp b/src/clientrpc.cpp index 51c9a9d287..5771f906da 100644 --- a/src/clientrpc.cpp +++ b/src/clientrpc.cpp @@ -326,6 +326,33 @@ CClientRpc::CClientRpc ( CClient* pClient, CRpcServer* pRpcServer, QObject* pare response["result"] = "ok"; } ); + + /// @rpc_method jamulusclient/setFaderLevel + /// @brief Sets the fader level. Example: {"id":1,"jsonrpc":"2.0","method":"jamulusclient/setFaderLevel","params":{"channelIndex": 0,"level": + /// 50}}. + /// @param {number} params.channelIndex - The channel index of the fader to be set. + /// @param {number} params.level - The fader level in range 0..100. + /// @result {string} result - Always "ok". + pRpcServer->HandleMethod ( "jamulusclient/setFaderLevel", [=] ( const QJsonObject& params, QJsonObject& response ) { + auto jsonChannelIndex = params["channelIndex"]; + if ( !jsonChannelIndex.isDouble() || ( jsonChannelIndex.toInt() < 0 ) || ( jsonChannelIndex.toInt() > MAX_NUM_CHANNELS ) ) + { + response["error"] = + CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams, "Invalid params: channelIndex is not a number or out-of-range" ); + return; + } + + auto jsonLevel = params["level"]; + if ( !jsonLevel.isDouble() || ( jsonLevel.toInt() < 0 ) || ( jsonLevel.toInt() > 100 ) ) + { + response["error"] = + CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams, "Invalid params: level is not a number or out-of-range" ); + return; + } + + pClient->SetControllerInFaderLevel ( jsonChannelIndex.toInt(), jsonLevel.toInt() ); + response["result"] = "ok"; + } ); } QJsonValue CClientRpc::SerializeSkillLevel ( ESkillLevel eSkillLevel )