It is currently October 6th, 2024, 10:27 am

Windows main audio volume per channel?

Get help with creating, editing & fixing problems with skins
User avatar
Yincognito
Rainmeter Sage
Posts: 8358
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Windows main audio volume per channel?

Post by Yincognito »

ZXCVBOT wrote: November 8th, 2023, 5:47 pmbut the values are wayy toooo off.
Didn't test the code, but it's probably because the nested syntax for variables is not used after setting variables in the mouse actions, e.g. (see the end of the line below):

Code: Select all

LeftMouseDownAction=[!SetVariable dotL $MouseX$][!SetVariable outL (($MouseX$/100)*65535)][!UpdateMeterGroup vis][!Redraw]["#@#Addons\nircmd.exe" setvolume 0 [#outL] [#outR]]
Bottom line, if one sets a variable and wants to use the new value of that variable on the same line of bangs, then he must use the nested syntax, otherwise the old value of that variable will be used instead. Obviously, if the variable is not used on the same line of bangs, normal methods like updating measures / meters and classic syntax are just fine.
ZXCVBOT wrote: November 8th, 2023, 5:47 pmWaiting for the below part to be verified:
Got this limit of Rainmeter brackets while testing a workaround: Formula: Internal error I think, it can't handle more than 256 characters.
I doubt that such a limit exists. I would suspect some wrong or illegal syntax or logic in the formula instead...
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
rbriddickk84
Rainmeter Sage
Posts: 276
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Re: Windows main audio volume per channel?

Post by rbriddickk84 »

Yincognito wrote: November 8th, 2023, 6:38 pm Didn't test the code, but it's probably because the nested syntax for variables is not used after setting variables in the mouse actions, e.g. (see the end of the line below):

Code: Select all

LeftMouseDownAction=[!SetVariable dotL $MouseX$][!SetVariable outL (($MouseX$/100)*65535)][!UpdateMeterGroup vis][!Redraw]["#@#Addons\nircmd.exe" setvolume 0 [#outL] [#outR]]
Bottom line, if one sets a variable and wants to use the new value of that variable on the same line of bangs, then he must use the nested syntax, otherwise the old value of that variable will be used instead. Obviously, if the variable is not used on the same line of bangs, normal methods like updating measures / meters and classic syntax are just fine.


I doubt that such a limit exists. I would suspect some wrong or illegal syntax or logic in the formula instead...
Yeah, i reworked the code right after i posted the previous one and separated in different measures the commands. But still, sometimes NirCMD doesn't registering the command. Yet, basically works, so there can be a solution for this issue.
And thanks everyone for the nice helps! :) :great:
ZXCVBOT

Re: Windows main audio volume per channel?

Post by ZXCVBOT »

rbriddickk84 wrote: November 9th, 2023, 11:33 am Yeah, i reworked the code right after i posted the previous one and separated in different measures the commands. But still, sometimes NirCMD doesn't registering the command. Yet, basically works, so there can be a solution for this issue.
And thanks everyone for the nice helps! :) :great:
👍Glad it works. But, you helped yourself Mr. McClane! I was just - around - yeah - while you were trying to work out a solution. :lol:

However, I think something like <Current>+<FixedValue> would solve any issue of glitches. But, I don't know how to retrieve the L/R Balance values in first place. Do
User avatar
Yincognito
Rainmeter Sage
Posts: 8358
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Windows main audio volume per channel?

Post by Yincognito »

rbriddickk84 wrote: November 9th, 2023, 11:33 am But still, sometimes NirCMD doesn't registering the command.
That can indeed happen - it's been a long time since using it for that purpose, but I believe I've encountered this behavior as well. In any case, you're not limited to NirCmd for this, so maybe other alternatives don't have this slight disadvantage.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
ZXCVBOT

Re: Windows main audio volume per channel?

Post by ZXCVBOT »

Yincognito wrote: November 9th, 2023, 12:28 pm That can indeed happen - it's been a long time since using it for that purpose, but I believe I've encountered this behavior as well. In any case, you're not limited to NirCmd for this, so maybe other alternatives don't have this slight disadvantage.
Some Alternatives:
https://forum.rainmeter.net/viewtopic.php?t=43135#p219252

I tested SetVol & it works (Not through Rainmeter). Try it once.
User avatar
Yincognito
Rainmeter Sage
Posts: 8358
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Windows main audio volume per channel?

Post by Yincognito »

ZXCVBOT wrote: November 9th, 2023, 12:53 pm Some Alternatives:
https://forum.rainmeter.net/viewtopic.php?t=43135#p219252

I tested SetVol & it works (Not through Rainmeter). Try it once.
I believe you, but I'm not the one who has to decide on this - it's up to the OP. :confused:
Yet another alternative would be to try the dedicated NirSoft utility for this, the SoundVolumeView command line tool - it has /GetPercentChannel, /SetVolumeChannels and /ChangeVolumeChannel for per channel audio handling, and who knows, maybe it fares better than the main NirCmd executable in that regard (if the issue is from NirCmd and not the skin code, that is).

P.S. Another particularity of using command line tools instead of built-in solutions is that some reasonable delay between executions is unavoidable for an acceptable outcome.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
rbriddickk84
Rainmeter Sage
Posts: 276
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Re: Windows main audio volume per channel?

Post by rbriddickk84 »

ZXCVBOT wrote: November 9th, 2023, 12:53 pm Some Alternatives:
https://forum.rainmeter.net/viewtopic.php?t=43135#p219252

I tested SetVol & it works (Not through Rainmeter). Try it once.
Well i know that there is a lot of external scripts and small apps are out there for these kinds of needs, but my first thoughts are always originated in Rainmeter. Like "can i achieve a thing like that?" or "are there any plugins or ways to do that in here?"
But i appreciate your suggestion, i believe that would work in those circumstances. :)
Yincognito wrote: November 9th, 2023, 6:00 pm Yet another alternative would be to try the dedicated NirSoft utility for this, the command line tool - it has /GetPercentChannel, /SetVolumeChannels and /ChangeVolumeChannel for per channel audio handling, and who knows, maybe it fares better than the main NirCmd executable in that regard
I probably give that a shot in the feature, looks similar, we will see. :)

The delay between executions is expected and not a problem for me.

Thanks again for everyone! :thumbup:
I will coment on this if i reach any new progress.
User avatar
Yincognito
Rainmeter Sage
Posts: 8358
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Windows main audio volume per channel?

Post by Yincognito »

rbriddickk84 wrote: November 9th, 2023, 9:02 pm I will coment on this if i reach any new progress.
Alright, let us know of the result. Personally I've not yet tested this in your scenario, though I might just do that today. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
ZXCVBOT

Re: Windows main audio volume per channel?

Post by ZXCVBOT »

I have a teeny-tiny-suggestion: unrelated to the main topic, but it works Rainmeter-wise:

Set the Volume up to 100 (Mixed-Volume?) per device.
Set the max fixed ratio in which you want them to increase/decrease. Example: Left 100, Right 80.
Now, the simple volume-meters in Rainmeter and normal-volume sliders of windows would use that ratio to increase/decrease (As long as both are greater than 0). Example (cont.) At 100% : L100,R80 ; At 50% : L50,R45.

I get this is not what you want to achieve, but I wasn't able to wait till Yincognito's answer.
User avatar
Yincognito
Rainmeter Sage
Posts: 8358
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Windows main audio volume per channel?

Post by Yincognito »

rbriddickk84 wrote: November 9th, 2023, 9:02 pm I will coment on this if i reach any new progress.
Yincognito wrote: November 10th, 2023, 9:16 am Personally I've not yet tested this in your scenario, though I might just do that today. ;-)
As promised, here's the (working) outcome:

Code: Select all

[Variables]
@include=sett.inc
dotL=100
dotR=100
outL=65535
outR=65535

[Rainmeter]
Update=15
AccurateText=1
DynamicWindowSize=1
OnRefreshAction=[!CommandMeasure GetVolL "Run"][!CommandMeasure GetVolR "Run"]

---Measures---

[GetVolL]
Measure=Plugin
Plugin=RunCommand
Program=#@#Addons\svcl.exe
Parameter=/Stdout /GetPercentChannel "Speaker" 0
State=Hide
OutputType=ANSI
Timeout=10000
UpdateDivider=-1
RegExpSubstitute=1
Substitute="(?:\s+|[.]\d+)":""
FinishAction=[!SetVariable dotL "[GetVolL]"][!SetVariable outL (([#dotL]/100)*65535)][!UpdateMeterGroup vis][!Redraw]
DynamicVariables=1

[GetVolR]
Measure=Plugin
Plugin=RunCommand
Program=#@#Addons\svcl.exe
Parameter=/Stdout /GetPercentChannel "Speaker" 1
State=Hide
OutputType=ANSI
Timeout=10000
UpdateDivider=-1
RegExpSubstitute=1
Substitute="(?:\s+|[.]\d+)":""
FinishAction=[!SetVariable dotR "[GetVolR]"][!SetVariable outR (([#dotR]/100)*65535)][!UpdateMeterGroup vis][!Redraw]
DynamicVariables=1

---Meters---

[SliderDetectorLeft]
Meter=Image
SolidColor=100,200,200,255
X=4
Y=0
W=100
H=12
LeftMouseUpAction=[!SetVariable dotL $MouseX$][!SetVariable outL (([#dotL]/100)*65535)][!UpdateMeterGroup vis][!Redraw]["#@#Addons\nircmd.exe" setvolume 0 [#outL] [#outR]]
MiddleMouseUpAction=[!SetVariable dotL 100][!SetVariable outL (([#dotL]/100)*65535)][!UpdateMeterGroup vis][!Redraw]["#@#Addons\nircmd.exe" setvolume 0 [#outL] [#outR]]
DynamicVariables=1

[SliderDetectorRight]
Meter=Image
SolidColor=200,100,200,255
X=4
Y=16
W=100
H=12
LeftMouseUpAction=[!SetVariable dotR $MouseX$][!SetVariable outR (([#dotR]/100)*65535)][!UpdateMeterGroup vis][!Redraw]["#@#Addons\nircmd.exe" setvolume 0 [#outL] [#outR]]
MiddleMouseUpAction=[!SetVariable dotR 100][!SetVariable outR (([#dotR]/100)*65535)][!UpdateMeterGroup vis][!Redraw]["#@#Addons\nircmd.exe" setvolume 0 [#outL] [#outR]]
DynamicVariables=1

[BalanceVolShapeLeft]
Meter=Shape
Shape=Ellipse 2,2,4,6
X=#dotL#
Y=4
UpdateDivider=-1
DynamicVariables=1
Group=vis

[BalanceVolShapeRight]
Meter=Shape
Shape=Ellipse 2,2,4,6
X=#dotR#
Y=20
UpdateDivider=-1
DynamicVariables=1
Group=vis
I let most of the code unchanged, except some needed nested syntax for the variables in the mouse action bangs, as already mentioned earlier (I also changed to left mouse up and middle mouse up, it was more comfortable for me during testing). That alone made the code work as it should have (didn't test the original code at all, just went with the proper implementation). In addition to that, I added two RunCommand measures to get the left and right channel volumes, so the skin starts from current values communicated by the system in that regard. Therefore, you'll need:
- NirSoft's Sound Volume Command Line tool, placed in the @Resources\Addons folder of the skin (to get channel volumes)
- NirSoft's NirCmd tool, placed in the @Resources\Addons folder of the skin (to set channel volumes)
to have it all working (I used the 64bit versions, but it's up to you which architecture you prefer to use).

Feel free to adjust whatever thing you need from the code above (e.g. the "Speaker" device, in case you have it differently, something you can see in the SoundVolumeView utility from the same NirSoft).

P.S. In case it's unclear why two such tools have to be used, it's because the first tool couldn't set the left channel volume for me (only the right one), and the second tool doesn't seem to have parameters to get the channel volumes (or any volume, for that matter) at all. :confused:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth