Volume Control: Fix linear 100% range control
Range is now linear on 100%, like it should be. Signed-off-by: Christopher Snowhill <kode54@gmail.com>CQTexperiment
parent
476c88973b
commit
808710b881
|
@ -17,11 +17,11 @@
|
|||
//Input/Output values are in percents.
|
||||
double logarithmicToLinear(double logarithmic, double MAX_VOLUME)
|
||||
{
|
||||
return pow((logarithmic/MAX_VOLUME), 0.25) * 100.0;
|
||||
return (MAX_VOLUME == 100.0) ? logarithmic : pow((logarithmic/MAX_VOLUME), 0.25) * 100.0;
|
||||
}
|
||||
|
||||
double linearToLogarithmic(double linear, double MAX_VOLUME)
|
||||
{
|
||||
return (linear/100.0) * (linear/100.0) * (linear/100.0) * (linear/100.0) * MAX_VOLUME;
|
||||
return (MAX_VOLUME == 100.0) ? linear : (linear/100.0) * (linear/100.0) * (linear/100.0) * (linear/100.0) * MAX_VOLUME;
|
||||
}
|
||||
//End helper volume function thingies. ONWARDS TO GLORY!
|
||||
|
|
|
@ -2119,7 +2119,7 @@ Gw
|
|||
<slider horizontalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1612" customClass="VolumeSlider">
|
||||
<rect key="frame" x="6" y="2" width="20" height="164"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<sliderCell key="cell" controlSize="small" continuous="YES" alignment="left" minValue="10" maxValue="100" doubleValue="55" tickMarkPosition="left" sliderType="linear" id="1613"/>
|
||||
<sliderCell key="cell" controlSize="small" continuous="YES" alignment="left" maxValue="100" doubleValue="55" tickMarkPosition="left" sliderType="linear" id="1613"/>
|
||||
<connections>
|
||||
<action selector="changeVolume:" target="705" id="1614"/>
|
||||
</connections>
|
||||
|
|
|
@ -59,13 +59,8 @@
|
|||
- (void)updateToolTip
|
||||
{
|
||||
double value = [self doubleValue];
|
||||
BOOL volumeLimit = [[[NSUserDefaultsController sharedUserDefaultsController] defaults] boolForKey:@"volumeLimit"];
|
||||
double volume;
|
||||
if (volumeLimit) {
|
||||
volume = (value - self.minValue) * (MAX_VOLUME / (self.maxValue - self.minValue));
|
||||
} else {
|
||||
volume = linearToLogarithmic(value, MAX_VOLUME);
|
||||
}
|
||||
volume = linearToLogarithmic(value, MAX_VOLUME);
|
||||
|
||||
NSString *text = [NSString stringWithFormat:@"%0.lf%%", volume];
|
||||
|
||||
|
|
Loading…
Reference in New Issue