From 65ba46a10d72eef4e7312488bd7695aa665a0405 Mon Sep 17 00:00:00 2001 From: Nils Brederlow <62596379+dingodoppelt@users.noreply.github.com> Date: Mon, 6 Jul 2026 18:58:16 +0200 Subject: [PATCH 1/2] add jamulusclient/setInstrumentCode JSONRPC method --- docs/JSON-RPC.md | 17 +++++++++++++++++ src/clientrpc.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/docs/JSON-RPC.md b/docs/JSON-RPC.md index e9111187f4..48e2398e3f 100644 --- a/docs/JSON-RPC.md +++ b/docs/JSON-RPC.md @@ -274,6 +274,23 @@ Results: | result | string | Always "ok". | +### jamulusclient/setInstrumentCode + +Sets your instrument code. + +Parameters: + +| Name | Type | Description | +| --- | --- | --- | +| params.instrCode | number | The new instrument code. | + +Results: + +| Name | Type | Description | +| --- | --- | --- | +| result | string | Always "ok". | + + ### jamulusclient/setMidiSettings Sets one or more MIDI controller settings. diff --git a/src/clientrpc.cpp b/src/clientrpc.cpp index 9ba7060a1d..3d8865f138 100644 --- a/src/clientrpc.cpp +++ b/src/clientrpc.cpp @@ -331,6 +331,32 @@ CClientRpc::CClientRpc ( CClient* pClient, CClientSettings* pSettings, CRpcServe response["result"] = "ok"; } ); + /// @rpc_method jamulusclient/setInstrumentCode + /// @brief Sets your instrument code. + /// @param {number} params.instrCode - The new instrument code. + /// @result {string} result - Always "ok". + pRpcServer->HandleMethod ( "jamulusclient/setInstrumentCode", [=] ( const QJsonObject& params, QJsonObject& response ) { + auto jsonInstrCode = params["instrCode"]; + + if ( !jsonInstrCode.isDouble() ) + { + response["error"] = CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams, "Invalid params: instrCode is not a number" ); + return; + } + + const int _iInstrument = jsonInstrCode.toInt(); + + if ( CInstPictures::GetName ( _iInstrument ).isEmpty() ) + { + response["error"] = CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams, "Invalid params: unknown instrCode" ); + return; + } + + pClient->ChannelInfo.iInstrument = _iInstrument; + pClient->SetRemoteInfo(); + response["result"] = "ok"; + } ); + /// @rpc_method jamulusclient/sendChatText /// @brief Sends a chat text message. /// @param {string} params.chatText - The chat text message. From 141f6c2b5599adc6ad383fb2c314a12be77c3674 Mon Sep 17 00:00:00 2001 From: Nils Brederlow <62596379+dingodoppelt@users.noreply.github.com> Date: Tue, 21 Jul 2026 18:28:23 +0200 Subject: [PATCH 2/2] Fix style --- src/clientrpc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/clientrpc.cpp b/src/clientrpc.cpp index 3d8865f138..ebab2f3532 100644 --- a/src/clientrpc.cpp +++ b/src/clientrpc.cpp @@ -344,15 +344,15 @@ CClientRpc::CClientRpc ( CClient* pClient, CClientSettings* pSettings, CRpcServe return; } - const int _iInstrument = jsonInstrCode.toInt(); + const int iNInstrument = jsonInstrCode.toInt(); - if ( CInstPictures::GetName ( _iInstrument ).isEmpty() ) + if ( CInstPictures::GetName ( iNInstrument ).isEmpty() ) { response["error"] = CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams, "Invalid params: unknown instrCode" ); return; } - pClient->ChannelInfo.iInstrument = _iInstrument; + pClient->ChannelInfo.iInstrument = iNInstrument; pClient->SetRemoteInfo(); response["result"] = "ok"; } );