It is currently September 14th, 2024, 10:20 pm

Volume Slider [Solved!]

Get help with creating, editing & fixing problems with skins
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Volume Slider [Solved!]

Post by JpsCrazy »

I'm working on a volume slider skin and it's nearly done!
The slider is based completely on smurfier's RSS Scrolling Feed.

Here's the next-semi-final code for all to see:

Code: Select all

[Rainmeter]
Author=JpsCrazy, original scroll bar code by Smurfier from RSS Scroller
Update=250
BackgroundMode=0
SolidColor=50,50,50,100

;--Variables----------------------------------------------
[Variables]
;Path to NirCmd (unnecessary to change if in \Windows directory)
NirCmdPath=NirCmd.exe

;Variable for volume
Vol=0

;The amount of clicks wanted to reach the top
Clicks=15
;How many pixels the bar moves by each click
LineAmount=9

;These two change the size of the skin - It's all guess and check
;Starting Y value for bar
StartValue=143
;Used for calculating the height and width of things
M=10

;Don't change this one
Num=1

;--Calculate the change in Volume-------------
[msVolume]
Measure=Calc
Formula=(65535/#Clicks#)
DynamicVariables=1

;--Background Image--------------------------------
[mtBackground]
Meter=Image
ImageName=SliderBackgroundRound.png
Antialias=1
H=((#M#*15)+5)
X=6
Y=3

;--Scrollbar-----------------------------------------------
[msBarPlace]
Measure=Calc
Formula=(#StartValue#+((-#Vol#)*#LineAmount#) > 8) ? #StartValue#+((-#Vol#)*#LineAmount#) : 8
DynamicVariables=1

[mtBar]
Meter=Image
ImageName=Circle.png
X=4
Y=[msBarPlace]
W=10
H=10
DynamicVariables=1

;--Buttons------------------------------------------------
[msVolUp]
Measure=Calc
Formula=((#Vol#+1) > 15) ? 15 : #Vol#+1
DynamicVariables=1

[mtUp]
Meter=Image
ImageName=Arrow.png
AntiAlias=1
X=2
Y=0
LeftMouseUpAction=!Execute ["#NirCmdPath#" changesysvolume [MsVolume]][!RainmeterSetVariable Vol [msVolUp]]

[msVolDown]
Measure=Calc
Formula=((#Vol#-1) <0) ? 0 : #Vol#-1
DynamicVariables=1

[mtDown]
Meter=Image
ImageName=Arrow.png
ImageFlip=Vertical
X=2
Y=((#M#*15)+5)
LeftMouseUpAction=!Execute ["#NirCmdPath#" changesysvolume -[MsVolume]][!RainmeterSetVariable Vol [msVolDown]]
AntiAlias=1
DynamicVariables=1

[mtUnmute]
Meter=Image
ImageName=VolumeUnmute.png
Antialias=
X=2
Y=((#M#*15)+15)
W=15
H=15
LeftMouseUpAction=!Execute ["#NirCmdPath#" mutesysvolume 2][!RainmeterHideMeter mtUnmute][!RainmeterShowMeter mtMute]
Hidden=0

[mtMute]
Meter=Image
ImageName=VolumeMute.png
Antialias=
X=2
Y=((#M#*15)+15)
W=15
H=15
LeftMouseUpAction=!Execute ["#NirCmdPath#" mutesysvolume 2][!RainmeterHideMeter mtMute][!RainmeterShowMeter mtUnmute]
Hidden=1
Images are not completely finished, but at least they're not somebody else's now.
To Do:
-Make the code cleaner, more convenient, and work better
-Finish the images

Also: For the skin to appear correctly it's assumed you have 0 volume and you're not muted. It may work with the Win7 Audio Plugin, although has not been tested by my knowledge.
Last edited by JpsCrazy on June 9th, 2010, 7:44 pm, edited 7 times in total.
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Volume Slider

Post by smurfier »

Well...you messed it up a little. The msNumUp and msNumDown need to be set to advance and decline by one, but never go above 10 or below 1. This is the rule for the movement of the circle you want to use. For the volume, just take the number you want to decrease (or increase) by and multiply it by #CurrentValue#. It's gets a bit more complicated but I know you want to figure out as much on your own as possible.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: Volume Slider

Post by JpsCrazy »

Thankss.
That makes sense now.
But question: Shouldn't I add the amount I want to increase/decrease to #CurrentValue# rather than multiply? 'Cause if there was no volume, the value would be 0 and I wouldn't be able to change it.
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Volume Slider

Post by smurfier »

You need to take the maximum volume that you want, divide it by ten since that is the max that you it set to. Then take that number and multiply it by the value of the variable controlling the position of the slider, which is a number between 1 and the max you have set. Let's say you want to make the volume increase by 10 every time you click the down arrow. 1*10=10, 2*10=20.....


Hmm....to make this appear right, it would require an almost complete rework of the code so that up is increase and down is decrease. Right now it's up is decrease and down is increase.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: Volume Slider

Post by JpsCrazy »

...crap.
Ya know, I was wondering why the down was near the up arrow and up was near the down arrow and I realized you want the opposite for how the RSS Feed worked.
Well.
I'm going to redo the code eventually.
I'm going to try to just swap the codes/variables for similar measures.
I'll actually try getting it working after it's oriented correctly.
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: Volume Slider

Post by JpsCrazy »

Question:
For [msBarPlace]
Measure=Calc
Formula=(((((#Max#*15)+(#S.H#-20))/#Tot#)*(#Num#-1))+20)

S.H is the starting Y value for strings.
Could I scrap that for this code?
or just change it to (#Max#*15)-20?
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Volume Slider

Post by smurfier »

switch #S.H#-20 for the upper starting point of the sliding part of the bar.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: Volume Slider

Post by JpsCrazy »

I give up. x.x
Not for that, but for the idea in general.

...at least until the 12th when I actually have a laptop with volume control.
If you had any held back insight on this, now would be a wonderful time to share it. :)
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Volume Slider

Post by smurfier »

I'll see what I can do in the next few days. Gotta attend a graduation tomorrow and some housework after that.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Volume Slider

Post by smurfier »

Believe it or not, I dreamt this up.

1) Set the top button to the measure to increase the variable.
2) Set the bottom to decrease, with a minimum of 0 (mute).
3) Set the bar place measure to do something like this:
#start.value#+((-#var#)*#line.amount#)

set the start value to the bottom starting point.
line.amount is the amount of space you want it to move with each button press.
var is of course the variable that is being changed.

for the volume change, you can then just take the var and multiply it by whatever the amount you want it to increase each time.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .