logarithmic volume control
parent
31e95e7125
commit
4933dd62cb
|
@ -79,6 +79,7 @@
|
|||
playlistView = PlaylistView;
|
||||
positionSlider = TrackingSlider;
|
||||
timeField = NSTextField;
|
||||
volumeSlider = NSSlider;
|
||||
};
|
||||
SUPERCLASS = NSObject;
|
||||
},
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IBDocumentLocation</key>
|
||||
<string>19 350 617 240 0 0 1024 746 </string>
|
||||
<string>-18 96 617 240 0 0 1024 746 </string>
|
||||
<key>IBEditorPositions</key>
|
||||
<dict>
|
||||
<key>29</key>
|
||||
|
@ -28,11 +28,11 @@
|
|||
<integer>3</integer>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>21</integer>
|
||||
<integer>823</integer>
|
||||
<integer>463</integer>
|
||||
<integer>513</integer>
|
||||
<integer>463</integer>
|
||||
<integer>823</integer>
|
||||
<integer>29</integer>
|
||||
<integer>21</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>8I127</string>
|
||||
|
|
Binary file not shown.
|
@ -14,6 +14,7 @@
|
|||
IBOutlet PlaylistView *playlistView;
|
||||
|
||||
IBOutlet TrackingSlider *positionSlider;
|
||||
IBOutlet NSSlider *volumeSlider;
|
||||
IBOutlet NSTextField *timeField;
|
||||
IBOutlet NSTextField *lengthField;
|
||||
IBOutlet NSTextField *bitrateField;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
- (void)awakeFromNib
|
||||
{
|
||||
currentVolume = 100.0;
|
||||
[volumeSlider setDoubleValue:pow(10.0, log10(0.5)/4.0)*[volumeSlider maxValue]];
|
||||
}
|
||||
|
||||
|
||||
|
@ -157,16 +158,23 @@
|
|||
|
||||
- (IBAction)changeVolume:(id)sender
|
||||
{
|
||||
currentVolume = (float)[sender doubleValue];
|
||||
float percent;
|
||||
|
||||
//gravitates at the halfway mark
|
||||
float v = ([sender frame].size.width/[sender maxValue])*(currentVolume-([sender maxValue]/2.0));
|
||||
//Approximated log
|
||||
percent = (float)[sender doubleValue]/[sender maxValue];
|
||||
percent = percent * percent * percent * percent;
|
||||
|
||||
//gravitates at the 100% mark
|
||||
float v = [sender frame].size.width - ([sender frame].size.width*(percent*[sender maxValue])/100.0);
|
||||
if (fabs(v) < 10.0)
|
||||
{
|
||||
currentVolume = [sender maxValue]/2.0;
|
||||
[sender setDoubleValue:currentVolume];
|
||||
percent = 0.5;
|
||||
v = pow(10.0, log10(percent)/4.0);
|
||||
[sender setDoubleValue:v*[sender maxValue]];
|
||||
}
|
||||
|
||||
currentVolume = percent * [sender maxValue];
|
||||
|
||||
[soundController setVolume:currentVolume];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue