It is currently May 14th, 2024, 3:44 am

Adding a "Knob" to volume Bar

Get help with creating, editing & fixing problems with skins
Anamality
Posts: 17
Joined: August 5th, 2012, 7:26 am

Adding a "Knob" to volume Bar

Post by Anamality »

Ok guys, I think this question has a simple answer but I am too noob to get it and am stumped. There was a post here about something similar so I looked at it, but it isn't working in this skin I'm looking at

http://rainmeter.net/forum/viewtopic.php?f=5&t=13152

Here is the code for what I am doing.

Code: Select all

[MeasureWin7Audio]
Measure=Plugin
Plugin=Win7AudioPlugin

[MeasureBar]
Measure=Plugin
Plugin=Win7AudioPlugin
PlayerName=[MeasureWin7Audio]
PlayerType=VOLUME

[MeterBar]
meter=bar
measurename=measurebar
BarOrientation=Vertical
flip=0
x=44
y=55
W=5
H=317
BarColor=F7931E

[MeterPosition]
meter=image
imagename=Position 2.png
X=38
y=(372-317*(([MeasureBar]/100)))
I want the [MeasureBar] in the "y=(372-317*(([MeasureBar]/100)))" value to equal my systems volume and I don't know why it isn't working. The Icon I'm using as the Knob is there, but it isn't moving as I change my computer Volume.
User avatar
jsmorley
Developer
Posts: 22632
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Adding a "Knob" to volume Bar

Post by jsmorley »

Couple of things.

You are mixing up the NowPlaying and Win7Audio plugins, as PlayerName and PlayerType are not options for Win7Audio. You don't need them.

You also don't need two Win7Audio measures. Win7Audio returns the name of the output device (like "speakers") when used in a meter or measure requiring text, and a percentage number (like 50) when using in a meter or measure requiring a number.

So when MeasureWin7Audio is used in the bar meter as MeasureName=MeasureWin7Audio, it will give the current volume percentage to the bar. That part is working fine.

Now for the "knob" image. The issue there is that you are using the value of MeasureWin7Audio in a dynamic way to change the Y value of the meter. That is the right idea, but the problem is that when a measure has both a string and number value, it returns the string value ("speakers" in this case) when used in square brackets and DynamicVariables=1.

So we need a way to get the number value of the measure to use in the Y option of the meter. To do that, we set up a simple Calc measure that just uses the value of MeasureWin7Audio as the Formula=. Now that measure has only a number value we can use in your "knob" meter. P.S. Don't forget to use DynamicVariables=1 if you want the "current" value of a measure to be used in a formula.

Code: Select all

[MeasureWin7Audio]
Measure=Plugin
Plugin=Win7AudioPlugin

[MeasureKnobPos]
Measure=Calc
Formula=MeasureWin7Audio

[MeterBar]
meter=bar
measurename=MeasureWin7Audio
BarOrientation=Vertical
flip=0
x=44
y=55
W=5
H=317
BarColor=F7931E

[MeterPosition]
meter=image
SolidColor=255,0,0,255
W=10
H=10
X=38
y=(372-317*(([MeasureKnobPos]/100)))
DynamicVariables=1
One additional hint. You can open the "About" dialog from the Rainmeter notification area icon, and click on "Skins" to watch the current value of all measures and variables while your skin is running. That can be a big help in spotting a problem.

================================
There is an alternative way to solve this, that I would recommend. We have add a new Section Variables feature that expands how you can use [Measures] and [Meters] in formulas. If you use the new capability for measures:

[MeasureName:] will return the current value of the measure as a number with up to 10 places of decimal precision. In addition, some modifiers can be added to scale the number, show it as a percentage, and define the number of decimal places to use.

Then you can avoid the need for an extra Calc measure. You can in effect "force" the dynamic [Measure] to use the number value instead of the string. Just do this:

Code: Select all

[MeasureWin7Audio]
Measure=Plugin
Plugin=Win7AudioPlugin

[MeterBar]
meter=bar
measurename=MeasureWin7Audio
BarOrientation=Vertical
flip=0
x=44
y=55
W=5
H=317
BarColor=F7931E

[MeterPosition]
meter=image
SolidColor=255,0,0,255
W=10
H=10
X=38
y=(372-317*(([MeasureWin7Audio:]/100)))
DynamicVariables=1
User avatar
MerlinTheRed
Rainmeter Sage
Posts: 889
Joined: September 6th, 2011, 6:34 am

Re: Adding a "Knob" to volume Bar

Post by MerlinTheRed »

Is it only me who finds this whole concept of different string and number values used in different situations really confusing and often inconsistent? Is there a special manual page that explains which is used in what situations?
Have more fun creating skins with Sublime Text 2 and the Rainmeter Package!
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Adding a "Knob" to volume Bar

Post by Kaelri »

MerlinTheRed wrote:Is it only me who finds this whole concept of different string and number values used in different situations really confusing and often inconsistent? Is there a special manual page that explains which is used in what situations?
Most measure pages do at least indicate when different values are returned depending on the context. For example, from Win7Audio:
Win7Audio wrote:Returns the name of the current sound device (when used in a STRING meter) and the percentage (0-100) of current volume level (when used in a measure which requires a number).
Overall, however, the manual is indeed far from clear or consistent on this topic. It's definitely on our list of things to improve.
User avatar
jsmorley
Developer
Posts: 22632
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Adding a "Knob" to volume Bar

Post by jsmorley »

MerlinTheRed wrote:Is it only me who finds this whole concept of different string and number values used in different situations really confusing and often inconsistent? Is there a special manual page that explains which is used in what situations?
It really can be confusing, since as you say it is not laid out anywhere in a clear "here are the rules" kinda way.

My view of it is as much of a "nutshell" as possible:

All measures that return numbers create them as both a "number" and a "string".

Most measures return a number and a string that are the same. Some measures (Win7Audio, Time, NowPlaying for instance) can return a "number" and a "string" that are different.

Substitute acts only on the string value of a measure.

The About dialog in the Rainmeter context menu displays the string value of measures.

When you use the name of a measure in MeasureName= on a meter, the type of meter determines which is used. For instance, Bar meters use the number value, and String meters use the string value. Again, in most cases this is not important, as they are for practical purposes the same thing.

When you use the name of a measure in a Calc measure in a formula (without square brackets), such as Formula=(200 * MeasureName), the number value is used.

When you use the name of a measure in a Calc measure or any other measure or meter in a formula (with square brackets and DynamicVariables=1), then the string value (or Substituted string value) is used.

The Section Variables [MeasureName:] functionality offers some additional control. Used with DynamicVariables=1, it uses the number value of the measure. This is particularly useful where you want to use the value of a measure dynamically in a formula on a meter or measure, while not getting the string or Substituted value.
Anamality
Posts: 17
Joined: August 5th, 2012, 7:26 am

Re: Adding a "Knob" to volume Bar

Post by Anamality »

Thank you for your help, worked like a charm!
User avatar
jsmorley
Developer
Posts: 22632
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Adding a "Knob" to volume Bar

Post by jsmorley »

Anamality wrote:Thank you for your help, worked like a charm!
Great. Sorry for sorta hijacking your thread... ;-)