[Squeezebox] Add balance controls

Hi there,

I had just discovered that my squeezebox player (SqueezeAmp with squeezelite-esp32) shows balance control in the players audio settings (-25: full on right, 0 full on both, 25 full on left channel):
image

This enables the following use case for me (and maybe others):
I have one player located in the garden. One speaker is in the winter garden, one outside. Having this setting available to openhab would enable me to minimize sound emission to the needed location(s) and thus decreasing energy consumption and impact to my neighbors :wink:

Looking at the code, the change to add this to the binding seems pretty straight forward:

However, this seems to be a custom setting offered by my player as the CLI does not offer any balance setting:

Is there anyone that can point me into the right direction?
Should I go for the http binding to change the setting?

Best,
Sascha

Being faced with this task again and being unsuccessful with the http binding, maybe @maniac103 or @mhilbush could point me in the right direction. I’m really willing to add this to the binding :wink:

Cheers,
Sascha

If balance control is not part of the Server CLI API, I don’t think it is possible/meaningful to support this.
Is there any evidence of squeezelite-esp32 even supporting external control of this value, and how does the http binding relate to this?

Exactly. And I don’t see anything the CLI API that lets you control the balance.

Thank you both for your fast replies - you both helped me a lot to understand.

Indeed, the slimproto does not contain balance controls: SlimProto TCP protocol - SqueezeboxWiki

I’ve found the original thread where the feature has been discussed in this thread: Balance

They’ve used a simple yet effective approach in my opinion:

So, knowing that there is a gainL and gainR in slimproto, shall we add a balance option in audio? I think that could be easy, just a -N…N cursor then I would apply a scale down factor on gainL or gainR depending on that cursor (0 => no change, N => factor=0 on gainL, -N => factor=0 on gainR)

So, my next question is: How to add gain control to the binding? :smiley:

EDIT: I’ve tried to control the balance using the http binding to POST a form using the balance data field and failed greatly :frowning:

I don’t see anything in the CLI docs that let you control L & R gain.

So to allow others to control balance too, here’s the DSL code for controlling it:

val String url	= "http://music:9000/material/settings/player/audio.html"
val String type	= "application/x-www-form-urlencoded"
val int timeout = 5000	// ms
val values = "pref_balance=-25&saveSettings=1"

val result = sendHttpPostRequest (url, type, values, timeout)

You need to replace the url to point to your LMS server. I don’t know if the URL is only valid if using the material theme so use with that piece aware.

I’ll mark this thread solved but I would be eager to know, if the implementation of this in the binding would be easy or difficult, thanks :slight_smile:

The binding uses the command line interface (CLI) for all interactions with the LMS. So, no, the above call directly into the user interface doesn’t fit into the model of how the binding works.