geekamp and xLabel Thread last updated on 2006-08-04 05:50:21

Posted by member 321598 on 2006-08-03 22:25:53

I'm trying to create a slider for geekamp with the following code (where the label is the slider itself and moveable)
AmpVolumeSliderOnMove !ParseEvars !Execute [!Amp_SetVolume %#(AmpVolumeSliderCurrentX-156)*255/48%#][!LabelUpdate Amp]


To update the position of the slider, I have for the OnEnter event:
AmpVolumeSliderOnEnter !ParseEvars !LabelMove AmpVolumeSlider %#%[before(volume('winamp'),'%')]%*48/100+156%# 4


The slider itself is 16x16 icon in a move area of 64 width. The problem is everytime the slider gets updated, the volume gets set down a little. Is my math incorrect somewhere here or is there a rounding issue I'm not aware of?

Posted by member 5575 on 2006-08-04 00:46:34 link

I imagine it's a roundoff error - try adding 0.5 after those integer divisions and see if you get a more consistent result.

Posted by member 212670 on 2006-08-04 01:59:55 link

Math-wise it looks good... something like:

movearea / 100 * vol%
(movearea = movearea_length - slider_width)

I'm assuming your 156 is accounting for positioning.

I think Brian is dead on about the error. I played with something similar in my RGB theme and ended up scrapping it - it was just too much of a pain in the ass. Instead, I wrote the slider's xpos to a var and saved it so when the theme started/recycled, it'd be where it was left. Of course it can become out of sync if someone changes the volume outside of the slider (that's what I was trying to fix in the first place), but oh well.

Posted by member 321598 on 2006-08-04 05:50:21 link

Wow, adding the 0.5 works flawlessly. So how does litestep round off? I'm guessing it's simply a truncation (floor) since adding the 0.5 seems to fix the problem.

Edit: Hmm, although the problem is fixed, I'm messing around with the Winamp volume controls and comparing the volume display to the [volume], it seems winamp is also flooring output in the display, but it doesn't seem to be flooring the volume change through the !Amp_SetVolume bang?

Eitherway, I found that adding the !Labelmove bang with a 0.5 seems to create a closer correlation between the [volume] and winamp's volume that adding 0.5 to both the !Labelmove and !Amp_SetVolume.