It is currently April 19th, 2024, 10:59 am

Help needed on volume control skin...

Get help with creating, editing & fixing problems with skins
User avatar
brax64
Posts: 172
Joined: July 8th, 2018, 8:05 pm

Help needed on volume control skin...

Post by brax64 »

Hi there,
just started using Rainmeter, for self training purpose, wanna write a simple skin that change system volume with mouse wheel scrolling; it is actually working.
My problem arise trying to replace the volume value with the text "Mute" when the volume is zero or muted with the toggle...
Below the solutions was trying but neither one work... is there any good man that wanna help me please?
I do apologize in advance if there's already an answer to this question somewhere, but I didn't find it...

Code: Select all

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

[MeasureVolume]
Measure=Plugin
Plugin=Win7AudioPlugin

;Solution 1
;IfAboveValue=1
;IfAboveAction= [!SetOption  VolumeLevel Text "[MeasureVolume:]%"][!Redraw]
;IfBelowValue=0
;IfBelowAction=[!SetOption  VolumeLevel Text "Mute"][!Redraw]

;Solution 2
;IfCondition=MeasureVolume < 1
;IfTrueAction=[!SetOption  VolumeLevel Text "Mute"]
;IfCondition2=MeasureVolume >= 1 
;IfTrueAction2=[!SetOption  VolumeLevel Text "[MeasureVolume:]%"]
;OnUpdateAction=[!UpdateMeter VolumeLevel][!Redraw]

[VolumeLevel]
Meter= String
MeasureName=MeasureVolume
X=30
Y=15
W=60
H=35
FontColor=1,178,87,255
FontFace=Roboto
FontSize=13
StringAlign=Center
Text =[MeasureVolume:]%
MouseScrollUpAction=[!CommandMeasure MeasureVolume "ChangeVolume +1"][!Update]
MouseScrollDownAction=[!CommandMeasure MeasureVolume "ChangeVolume -1"][!Update]
MiddleMouseUpAction=[!CommandMeasure MeasureVolume "ToggleMute"][!Update]
AntiAlias=1
DynamicVariables=1
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5391
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Help needed on volume control skin...

Post by eclectic-tech »

I prefer using the more versatile 'IfCondition' instead of 'IfAbove/Equal/Below' due to their limitations.

I simplified the [MeasureVolume] code. The key is "IfConditionMode=1" which forces the condition test on every update. Rather than a second condition, you can use "IfFalseAction=" since you are only going to have 2 possible conditions.

Code: Select all

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

[MeasureVolume]
Measure=Plugin
Plugin=Win7AudioPlugin

IfCondition=MeasureVolume<1
IfTrueAction=[!SetOption VolumeLevel Text "Mute"]]
IfFalseAction=[!SetOption VolumeLevel Text "[MeasureVolume:]%"]
IfConditionMode=1

[VolumeLevel]
Meter= String
MeasureName=MeasureVolume
X=30
Y=15
W=60
H=35
FontColor=1,178,87,255
FontFace=Roboto
FontSize=13
StringAlign=Center
Text =[MeasureVolume:]%
MouseScrollUpAction=[!CommandMeasure MeasureVolume "ChangeVolume +1"][!Update]
MouseScrollDownAction=[!CommandMeasure MeasureVolume "ChangeVolume -1"][!Update]
MiddleMouseUpAction=[!CommandMeasure MeasureVolume "ToggleMute"][!Update]
AntiAlias=1
DynamicVariables=1
Keep tinkering, things get easier the more you experiment! :17nodding
User avatar
brax64
Posts: 172
Joined: July 8th, 2018, 8:05 pm

Re: Help needed on volume control skin...

Post by brax64 »

eclectic-tech wrote:I prefer using the more versatile 'IfCondition' instead of 'IfAbove/Equal/Below' due to their limitations.

I simplified the [MeasureVolume] code. The key is "IfConditionMode=1" which forces the condition test on every update. Rather than a second condition, you can use "IfFalseAction=" since you are only going to have 2 possible conditions.

Code: Select all

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

[MeasureVolume]
Measure=Plugin
Plugin=Win7AudioPlugin

IfCondition=MeasureVolume<1
IfTrueAction=[!SetOption VolumeLevel Text "Mute"]]
IfFalseAction=[!SetOption VolumeLevel Text "[MeasureVolume:]%"]
IfConditionMode=1

[VolumeLevel]
Meter= String
MeasureName=MeasureVolume
X=30
Y=15
W=60
H=35
FontColor=1,178,87,255
FontFace=Roboto
FontSize=13
StringAlign=Center
Text =[MeasureVolume:]%
MouseScrollUpAction=[!CommandMeasure MeasureVolume "ChangeVolume +1"][!Update]
MouseScrollDownAction=[!CommandMeasure MeasureVolume "ChangeVolume -1"][!Update]
MiddleMouseUpAction=[!CommandMeasure MeasureVolume "ToggleMute"][!Update]
AntiAlias=1
DynamicVariables=1
Keep tinkering, things get easier the more you experiment! :17nodding
Thank you very much sir! It's working perfectly. :17group
yep, I'll keep tinkering quite a bit in the future and I'll almost surely bother you guys again with possibly silly questions!! :D
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help needed on volume control skin...

Post by balala »

eclectic-tech's solution, as usually, is perfect, but I want to show another one, too.

For this, you'll need a Calc measure, which gets the numeric value returned by the [MeasureVolume] measure (take care that this measure is returning both, a numeric and a string value and these two are different) and makes a substitution, adding a percent character if the system isn't muted and returning Mute, if it is.
If you want to try this out, first remove the IfCondition / IfTrueAction / IfFalseAction / IfConditionMode options from the [MeasureVolume] measure, then add the following measure:

Code: Select all

[MeasureVolumeMute]
Measure=Calc
Formula=[MeasureVolume:]
DynamicVariables=1
RegExpSubstitute=1
Substitute="^(\d{1,3})$":"\1%","^-1$":"Mute"
Now add the MeasureName=MeasureVolumeMute option to the [VolumeLevel] meter and modify the Text option of the same meter to Text=%1.
As I said, the [MeasureVolumeMute] measure is returning either the volume level (adding a percent character after it) if the system isn't muted (the first substitution), or, if it is (in this case the numeric value returned by the Win7AudioPlugin plugin measure is -1), its value will be substituted with the Mute text (done by the second substitution).
This (substituted) value returned by the [MeasureVolumeMute] measure, is taken literally by the String meter and shown.

Again, eclectic-tech's solution is perfect, there is nothing to comment about it. Plus it is much more simpler then my solution. I just wanted to show another approach of the same question.
User avatar
brax64
Posts: 172
Joined: July 8th, 2018, 8:05 pm

Re: Help needed on volume control skin...

Post by brax64 »

balala wrote:eclectic-tech's solution, as usually, is perfect, but I want to show another one, too.

For this, you'll need a Calc measure, which gets the numeric value returned by the [MeasureVolume] measure (take care that this measure is returning both, a numeric and a string value and these two are different) and makes a substitution, adding a percent character if the system isn't muted and returning Mute, if it is.
If you want to try this out, first remove the IfCondition / IfTrueAction / IfFalseAction / IfConditionMode options from the [MeasureVolume] measure, then add the following measure:

Code: Select all

[MeasureVolumeMute]
Measure=Calc
Formula=[MeasureVolume:]
DynamicVariables=1
RegExpSubstitute=1
Substitute="^(\d{1,3})$":"\1%","^-1$":"Mute"
Now add the MeasureName=MeasureVolumeMute option to the [VolumeLevel] meter and modify the Text option of the same meter to Text=%1.
As I said, the [MeasureVolumeMute] measure is returning either the volume level (adding a percent character after it) if the system isn't muted (the first substitution), or, if it is (in this case the numeric value returned by the Win7AudioPlugin plugin measure is -1), its value will be substituted with the Mute text (done by the second substitution).
This (substituted) value returned by the [MeasureVolumeMute] measure, is taken literally by the String meter and shown.

Again, eclectic-tech's solution is perfect, there is nothing to comment about it. Plus it is much more simpler then my solution. I just wanted to show another approach of the same question.
Thank you very much balala! What you're proposing here I've to admit it's really clever; as I said in the original post, I'm just wetting my feet with Rainmeter but already noticed thought how powerful the RegExpSubstitute function can be... gotta work my way to get familiar with the sintax tho... it's quite "not friendly" for a newbe... :17what, also if you may suggest any documentation I may study about this argument will be greatly appreciated.
Thanks again for your help and indeed really interesting approach to the argument.
Have a nice day! :welcome:
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help needed on volume control skin...

Post by balala »

brax64 wrote:but already noticed thought how powerful the RegExpSubstitute function can be... gotta work my way to get familiar with the sintax tho... it's quite "not friendly" for a newbe... :17what
Yes, it is powerful. But not too easy, indeed.
brax64 wrote: also if you may suggest any documentation I may study about this argument will be greatly appreciated.
Probably the appropriate first step would be the help: https://docs.rainmeter.net/manual/skins/option-types/#RegExp
Then you can browse the forum, many times here are posted questions about this feature.

I'm happy to help.
User avatar
brax64
Posts: 172
Joined: July 8th, 2018, 8:05 pm

Re: Help needed on volume control skin...

Post by brax64 »

below the full code for the skin I made with the help of both eclectic-tech and balala, in case anybody want to look at the proposed solution and/or use it somewhere...

Code: Select all

[Rainmeter]
Author=brax64
Update=-1
BackgroundMode=2
SolidColor=0,0,0,1
DynamicWindowSize=1
AccurateText=1

[Variables]
@include=#@#Variables.inc

[MeasureVolume]
Measure=Plugin
Plugin=Win7AudioPlugin

;IfCondition=MeasureVolume < 1
;IfTrueAction=[!SetOption  VolumeLevel Text "Muted"]
;IfFalseAction=[!SetOption  VolumeLevel Text "[MeasureVolume:]%"]
;IfConditionMode=1

[MeasureVolumeMute]
Measure=Calc
Formula=[MeasureVolume:]
DynamicVariables=1
RegExpSubstitute=1
Substitute="^(\d{1,3})$":"\1%","^-1$":"Mute"

[VolumeLevel]
Meter= String
MeasureName=MeasureVolumeMute
X=30
Y=15
W=60
H=35
FontColor=#Color2#
FontFace=Roboto
FontSize=13
StringAlign=Center
Text=%1
MouseScrollUpAction=[!CommandMeasure MeasureVolume "ChangeVolume +1"][!Update]
MouseScrollDownAction=[!CommandMeasure MeasureVolume "ChangeVolume -1"][!Update]
MiddleMouseUpAction=[!CommandMeasure MeasureVolume "ToggleMute"][!Update]
AntiAlias=1
ToolTipText="Mouse wheel scroll up + down -#CRLF#Middle Click: Mute"
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help needed on volume control skin...

Post by balala »

brax64 wrote:below the full code for the skin I made with the help of both eclectic-tech and balala, in case anybody want to look at the proposed solution and/or use it somewhere...
It seems you got the idea. Well done. Congratulations. :thumbup:
User avatar
brax64
Posts: 172
Joined: July 8th, 2018, 8:05 pm

Re: Help needed on volume control skin...

Post by brax64 »

Good morning all,
I'm here again seeking help...made this simple visualizer with integrated volume control as per the instructions above. it's kinda working but I'm experiencing a "focus" issue...
I mean when you hover the pointer on the volume text, the tooltip appears, so you actually "focusing" it but as soon as start rotating the wheel the changing volume command stops, you need to move again the pointer just a little bit and it works again... It's like you need to find a very tiny "magic spot" where the scrolling work continuously... also my mouse is brand new, so I don't think it's an hardware issue...
Hope to have express myself...
Any help about this? :17flag

Code: Select all

[Rainmeter]
Update=16
Author=Connect-R
;edited by brax64 7/14/18

[Variables]
@include=#@#Variables.inc
@include2=#@#Language\#Language#.inc

;-------------------------------------------------------------

[MeasureVolume]
Measure=Plugin
Plugin=Win7AudioPlugin

[MeasureVolumeMute]
Measure=Calc
Formula=[MeasureVolume:]
DynamicVariables=1
RegExpSubstitute=1
Substitute="^(\d{1,3})$":"\1%","^-1$":"Mute"

;-------------------------------------------------------------

[MeasureAudio]
Measure=Plugin
Plugin=AudioLevel
Port=Output
RMSAttack=0
RMSDecay=0
RMSGain=1
PeakAttack=0
PeakDecay=0
PeakGain=1
FFTSize=512
FFTAttack=50
FFTDecay=150
Bands=2
FreqMin=30
FreqMax=22000
Sensitivity=55

;-------------------------------------------------------------
;EX=!Execute
;CM=!CommandMeasure
;RD=!Redraw

[VolumeLevel]
Meter= String
MeasureName=MeasureVolumeMute
X=350
Y=90
FontColor=#Color1#
FontFace=space age
FontSize=16
StringAlign=left
Text =%1
MouseScrollUpAction=#EX#[#CM# MeasureVolume "ChangeVolume +1"][#RD#]
MouseScrollDownAction=#EX#[#CM# MeasureVolume "ChangeVolume -1"][#RD#]
MiddleMouseUpAction=#EX#[#CM# MeasureVolume "ToggleMute"][#RD#]
AntiAlias=1
ToolTipText="Mouse wheel scroll up + down -#CRLF#Middle Click: Mute"

[MeterLineBeat]
Meter=Line
MeasureName=MeasureAudio
LineColor= 90,170,170,80
X=0
Y=0
W=340
H=100
AutoScale=1
AntiAlias=1

[MeterLineBeat2]
Meter=Line
MeasureName=MeasureAudio
LineColor=170,250,250,120
X=r
Y=R
W=340
H=100
Flip=1
AutoScale=1
AntiAlias=1


User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help needed on volume control skin...

Post by balala »

brax64 wrote:I mean when you hover the pointer on the volume text, the tooltip appears, so you actually "focusing" it but as soon as start rotating the wheel the changing volume command stops, you need to move again the pointer just a little bit and it works again... It's like you need to find a very tiny "magic spot" where the scrolling work continuously... also my mouse is brand new, so I don't think it's an hardware issue...
No, it's not a hardware issue at all.
The problem is caused by the fact that the string meters (and not just those) are ignoring the mouse actions which are going on their transparent parts. In your case when you go to the [VolumeLevel] String meter and start to scroll at the first scroll there are great chances the mouse to be on a point where previously was a line of a number, but when the volume percentage changed, to be on a transparent region. In this case you have to move the mouse a bit, to have it again on a non-transparent part of the number.
There is a very simple solution: add a SolidColor=0,0,0,1 option to the [VolumeLevel] meter. This creates a practically invisible background to the volume level indicator, which this way registers the scroll no matter where the mouse is (above the volume indicator).