It is currently May 3rd, 2024, 7:05 am

Volume Change and ToggleMute Substitute="-1":"0"

Get help with creating, editing & fixing problems with skins
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Volume Change and ToggleMute Substitute="-1":"0"

Post by Mor3bane »

So I have this setup and the way I have it is for some secondary skins for different displays - sort of back ups depending on which screens are occupied by full screen apps, for example.

I have these Measures and Meters to manage Volume and ToggleMute:
This is the primary volume control skin:

Code: Select all

[MeasureVolCalc]
Measure=Calc
Formula=MeasureVolume
MinValue=0
MaxValue=100
Substitute="-1":"0"

[MeterVolumeKnob]
Meter=Rotator
MeasureName=MeasureVolCalc
ImageName=#@#Knob.png
ImageTint=#MySepiaTint#
X=86
Y=86
W=106
H=106
OffsetX=115
OffsetY=115
StartAngle=4.7123895
RotationAngle=4.7123895
Group=hide | buttons
Hidden=1
This one, is my secondary skin:

Code: Select all

[MeterWebDing]
Meter=String
X=33
Y=47
FontFace=Webdings
FontColor=65,86,102,255
FontSize=75
StringEffect=Border
FontEffectColor=210,170,90,180
Text="Y"
AntiAlias=1
LeftMouseDownAction=[!CommandMeasure "MeasureVolume" "ToggleMute"][!ToggleMeterGroup Mute][!Redraw]
RightMouseUpAction=[%windir%\system32\sndvol.exe -T 7200007E]
MouseOverAction=[!ToggleMeterGroup Fade][!Redraw]
MouseLeaveAction=[!ToggleMeterGroup Fade][!Redraw]
So the volume control recognises the substitute for the =1 value to revert to 0.
I would like the ToggleMute to also recognise this preference to not have a negative value for the volume by substitute a zero for a minus 1 value.

Happy to pin up more code or to try any recommendations.
Thx
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Re: Volume Change and ToggleMute Substitute="-1":"0"

Post by Mor3bane »

I looked this up just now:

Code: Select all

!CommandMeasure "MeasureWin7Audio" "SetVolume x"
Set volume to x (between 0 and 100). This disables mute.
My thing would be to capture the pre-existing volume level to 'restore it' prior to using the above to set the volume to Zero instead of mute.

Not sure how i'd do that.

I'll fidget around but recommendations are still welcome.
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
User avatar
deflore08
Posts: 209
Joined: July 12th, 2020, 7:47 am
Location: Ada, Garden City

Re: Volume Change and ToggleMute Substitute="-1":"0"

Post by deflore08 »

If i read it correctly, you don't want to see "-1" number in volume measure. Dunno that my solution is correct for this situation, but you can try next approach:

Add a variable like:

Code: Select all

volume_var = 100
Then use bang, for ex:

Code: Select all

LeftMouseUpAction = [!SetVariable volume_var "(100 - #volume_var#)][!CommandMeasure VOLUME "SetVolume #volume_var#)]
If you need "to remember" value to escape a bugs after refreshing, add one more bang:

Code: Select all

[!WriteKeyValue Variables volume_var "(100 - #volume_var#)]
So, when you call this bangs, #volume_var# will trigger value to 0 if it 100 now and to 100 if now it's 0.
Maybe there is a more nice solutions, but i know only this. Quick and simple. :)
Image * Image * Image * Image
User avatar
balala
Rainmeter Sage
Posts: 16195
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Volume Change and ToggleMute Substitute="-1":"0"

Post by balala »

Mor3bane wrote: August 3rd, 2020, 1:25 pm This is the primary volume control skin:

Code: Select all

[MeasureVolCalc]
Measure=Calc
Formula=MeasureVolume
MinValue=0
MaxValue=100
Substitute="-1":"0"

[MeterVolumeKnob]
Meter=Rotator
MeasureName=MeasureVolCalc
ImageName=#@#Knob.png
ImageTint=#MySepiaTint#
X=86
Y=86
W=106
H=106
OffsetX=115
OffsetY=115
StartAngle=4.7123895
RotationAngle=4.7123895
Group=hide | buttons
Hidden=1
This one, is my secondary skin:

Code: Select all

[MeterWebDing]
Meter=String
X=33
Y=47
FontFace=Webdings
FontColor=65,86,102,255
FontSize=75
StringEffect=Border
FontEffectColor=210,170,90,180
Text="Y"
AntiAlias=1
LeftMouseDownAction=[!CommandMeasure "MeasureVolume" "ToggleMute"][!ToggleMeterGroup Mute][!Redraw]
RightMouseUpAction=[%windir%\system32\sndvol.exe -T 7200007E]
MouseOverAction=[!ToggleMeterGroup Fade][!Redraw]
MouseLeaveAction=[!ToggleMeterGroup Fade][!Redraw]
My first question is if the [MeasureVolCalc] and [MeterVolumeKnob], respectivelly the [MeterWebDing] sections are in different skins (this is what you said)? Because both are using the [MeasureVolume] measure (in first case by the Formula option of the [MeasureVolCalc] measure, while in second code by the !CommandMeasure bang of the LeftMouseDownAction option of the [MeterWebDing] meter). Where the [MeasureVolume] measure is located?
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Re: Volume Change and ToggleMute Substitute="-1":"0"

Post by Mor3bane »

balala wrote: August 3rd, 2020, 5:53 pm My first question is if the [MeasureVolCalc] and [MeterVolumeKnob], respectivelly the [MeterWebDing] sections are in different skins (this is what you said)? Because both are using the [MeasureVolume] measure (in first case by the Formula option of the [MeasureVolCalc] measure, while in second code by the !CommandMeasure bang of the LeftMouseDownAction option of the [MeterWebDing] meter). Where the [MeasureVolume] measure is located?
Hi balala,

Both Skins have this Measure:

Code: Select all


[MeasureVolume]
Measure=Plugin
Plugin=Win7AudioPlugin

My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Re: Volume Change and ToggleMute Substitute="-1":"0"

Post by Mor3bane »

Oooh.

I just realised that with independent [MeasureVolume] Measures, the correlation between the values is NULL.

--continuing to ponder this, as adding the 'second' skin to the group of the 'first' is simple, therefore they could potentially then share the [MeasureVolume] with the unifying inc file the 'first' utilises.
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Re: Volume Change and ToggleMute Substitute="-1":"0"

Post by Mor3bane »

Here is the skin group rmskin for reference:
Music Controls_1.3.xx.rmskin
You do not have the required permissions to view the files attached to this post.
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
User avatar
Yincognito
Rainmeter Sage
Posts: 7190
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Volume Change and ToggleMute Substitute="-1":"0"

Post by Yincognito »

Mor3bane wrote: August 3rd, 2020, 1:25 pmI would like the ToggleMute to also recognise this preference to not have a negative value for the volume by substitute a zero for a minus 1 value.
I didn't check your posted skin, but this does the job:

Code: Select all

[Variables]

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=47,47,47,255

---Measures---

[MeasureVolume]
Measure=Plugin
Plugin=Win7AudioPlugin

[MeasureVolumeLevel]
Measure=Calc
Formula=MeasureVolume
RegExpSubstitute=1
;Substitute="^-1$":"Mute","^(\d+)$":"\1 %"
Substitute="^-1$":"0"

---Meters---

[MeterTest]
Meter=STRING
X=0
Y=0
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=MeasureVolumeLevel
Text="Volume = %1"
LeftMouseUpAction=[!CommandMeasure "MeasureVolume" "ToggleMute"][!UpdateMeasure MeasureVolume][!UpdateMeasure MeasureVolumeLevel][!UpdateMeter *][!Redraw]
DynamicVariables=1
I let the other substitution commented in [MeasureVolumeLevel], as it makes more sense in my view, since one can have a 0 % volume level even without toggling the mute, so technically volume = 0 and volume = mute might not be exactly the same thing. I used an additional measure and didn't perform changes on the [MeasureVolume] measure itself, since while you can modify its string value (which is the name of the device) I don't think you can modify its number value (i.e. the -1) directly.

Also, from what I noticed, a command measure on a Win7Audio plugin measure must be followed up by updating the measure(s) involved, in order to reflect the changes right away instead of on the next update. It isn't what you'd expect, this behavior, but well, it's no big deal - just keep that in mind.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16195
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Volume Change and ToggleMute Substitute="-1":"0"

Post by balala »

Mor3bane wrote: August 4th, 2020, 1:12 am I just realised that with independent [MeasureVolume] Measures, the correlation between the values is NULL.
Disagree. The Win7AudioPlugin measures are returning the same: their string values the name of the current sound device, while the numeric values, the percentage of the current volume level. No mater if the measures are used in different skins.
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Re: Volume Change and ToggleMute Substitute="-1":"0"

Post by Mor3bane »

Yincognito wrote: August 4th, 2020, 9:42 am I didn't check your posted skin, but this does the job:

Code: Select all

[Variables]

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=47,47,47,255

---Measures---

[MeasureVolume]
Measure=Plugin
Plugin=Win7AudioPlugin

[MeasureVolumeLevel]
Measure=Calc
Formula=MeasureVolume
RegExpSubstitute=1
;Substitute="^-1$":"Mute","^(\d+)$":"\1 %"
Substitute="^-1$":"0"

---Meters---

[MeterTest]
Meter=STRING
X=0
Y=0
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=MeasureVolumeLevel
Text="Volume = %1"
LeftMouseUpAction=[!CommandMeasure "MeasureVolume" "ToggleMute"][!UpdateMeasure MeasureVolume][!UpdateMeasure MeasureVolumeLevel][!UpdateMeter *][!Redraw]
DynamicVariables=1
I let the other substitution commented in [MeasureVolumeLevel], as it makes more sense in my view, since one can have a 0 % volume level even without toggling the mute, so technically volume = 0 and volume = mute might not be exactly the same thing. I used an additional measure and didn't perform changes on the [MeasureVolume] measure itself, since while you can modify its string value (which is the name of the device) I don't think you can modify its number value (i.e. the -1) directly.

Also, from what I noticed, a command measure on a Win7Audio plugin measure must be followed up by updating the measure(s) involved, in order to reflect the changes right away instead of on the next update. It isn't what you'd expect, this behavior, but well, it's no big deal - just keep that in mind.
Thanks Yincognito
I tried your suggestion but no success.
These are my Measure and Meter.

Code: Select all

[Percent]
Measure=Calc
Formula=MeasureVolume * 1
DynamicVariables=1
Substitute="^-1$":"Mute","^(\d+)$":"\1 %"
RegExpSubstitute=1

[PercentString]
Meter=String
Text=[Percent:0]%
AntiAlias=1
DynamicVariables=1
FontSize=22
FontColor=232,202,145,200
StringEffect=Border
FontEffectColor=0,0,0,255
StringAlign=CenterCenter
X=145
Y=145
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.