Added fade to pause, key shift-cmd-p, changed volume controls around a bit, still needs fixing

CQTexperiment
areff 2008-02-12 22:12:27 +00:00
parent 4f9ac97dfc
commit a39ce34ee9
8 changed files with 236 additions and 118 deletions

View File

@ -58,14 +58,14 @@
- (IBAction)seek:(id)sender;
- (IBAction)seekForward:(id)sender;
- (IBAction)seekBackward:(id)sender;
- (IBAction)fadeOut:(id)sender withTime:(double)time;
- (void)initDefaults;
- (void)audioFader:(NSTimer *)audioTimer;
- (void)updateTimeField:(double)pos;
- (void)playEntryAtIndex:(int)i;
- (void)playEntry:(PlaylistEntry *)pe;
- (int)status;
@end

View File

@ -1,6 +1,6 @@
#import "PlaybackController.h"
#import "PlaylistView.h"
#import <Foundation/NSTimer.h>
#import "CogAudio/Status.h"
#import "PlaylistController.h"
@ -53,8 +53,14 @@
- (void)awakeFromNib
{
currentVolume = 100.0;
[volumeSlider setDoubleValue:pow(10.0, log10(0.5)/4.0)*100];
double percent;
percent = (float)[volumeSlider doubleValue]/[volumeSlider maxValue];//100.0;
percent = percent * percent * percent * percent;
currentVolume = ((float)[volumeSlider doubleValue]/100.0)*[volumeSlider maxValue];//percent * 1000;//0;//[volumeSlider doubleValue];
[positionSlider setEnabled:NO];
}
@ -265,16 +271,57 @@
[audioPlayer setVolume:currentVolume];
}
/* selector for NSTimer - gets passed the Timer object itself
and the appropriate userInfo, which in this case is an NSNumber
containing the current volume before we start fading. */
- (void)audioFader:(NSTimer *)audioTimer
{
double volume = currentVolume;
NSArray *origValues = [audioTimer userInfo];
id originalVolume = [origValues objectAtIndex:0];
id origSliderVolume = [origValues objectAtIndex:1];
if (volume > 0)
{
[self volumeDown:self];
}
else // volume is at 0 or below, we are ready to release the timer and move on
{
[audioPlayer pause];
currentVolume = [originalVolume doubleValue];
[audioPlayer setVolume:currentVolume];
[volumeSlider setDoubleValue:[origSliderVolume doubleValue]];
[audioTimer invalidate];
}
}
- (IBAction)fadeOut:(id)sender withTime:(double)time
{
id origCurrentVolume = [NSNumber numberWithDouble: currentVolume];
id origSliderVolume = [NSNumber numberWithDouble: [volumeSlider doubleValue]];
NSArray *originalValues = [NSArray arrayWithObjects:origCurrentVolume,origSliderVolume,nil];
NSTimer *fadeTimer;
NSLog(@"currentVolume here%f", [volumeSlider doubleValue]);
fadeTimer = [NSTimer scheduledTimerWithTimeInterval:time
target:self
selector:@selector(audioFader:)
userInfo:originalValues
repeats:YES];
}
- (IBAction)volumeDown:(id)sender
{
double percent;
[volumeSlider setDoubleValue:([volumeSlider doubleValue] - 5)];
percent = (float)[volumeSlider doubleValue]/100.0;
percent = (float)[volumeSlider doubleValue]/[volumeSlider maxValue];//100.0;
percent = percent * percent * percent * percent;
currentVolume = percent * 100.0;
currentVolume = (percent * [volumeSlider maxValue]) + [volumeSlider doubleValue];//100.0;
NSLog(@"currentVolume %f", currentVolume);
[audioPlayer setVolume:currentVolume];
}
@ -285,11 +332,16 @@
[volumeSlider setDoubleValue:([volumeSlider doubleValue] + 5)];
percent = (float)[volumeSlider doubleValue]/[volumeSlider maxValue];
percent = (float)[volumeSlider doubleValue]/[volumeSlider maxValue];//100.0;
percent = percent * percent * percent * percent;
currentVolume = percent * [volumeSlider maxValue];
currentVolume = (percent * [volumeSlider maxValue]) + [volumeSlider doubleValue];//100.0);
if (currentVolume > 400)
currentVolume = 400;
NSLog(@"%f", currentVolume);
[audioPlayer setVolume:currentVolume];
}
@ -362,11 +414,6 @@
}
- (int)status
{
return playbackStatus;
}
- (void)audioPlayer:(AudioPlayer *)player statusChanged:(id)s
{
int status = [s intValue];

View File

@ -1,4 +1,4 @@
//
// AudioController.m
// Cog
//
@ -137,6 +137,7 @@
[output setVolume:v];
}
//This is called by the delegate DURING a requestNextStream request.
- (void)setNextStream:(NSURL *)url
{

View File

@ -14,7 +14,7 @@
@interface PlaylistView : NSTableView {
IBOutlet PlaybackController *playbackController;
IBOutlet PlaylistController *playlistController;
NSMenu *headerContextMenu;
}

View File

@ -200,6 +200,11 @@
{
[playlistController clearFilterPredicate:self];
}
// shift+command+p - fade to pause
else if (modifiers == (NSCommandKeyMask | NSShiftKeyMask) && c == 0x70)
{
[playbackController fadeOut:self withTime:0.4];
}
else
{
[super keyDown:e];

View File

@ -1,76 +1,157 @@
{
IBClasses = (
{
CLASS = AppcastArrayController;
LANGUAGE = ObjC;
SUPERCLASS = NSArrayController;
},
{
ACTIONS = {openSheet = id; };
CLASS = FileDrawerPane;
LANGUAGE = ObjC;
OUTLETS = {rootPathTextView = NSTextField; };
SUPERCLASS = PreferencePane;
},
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{CLASS = HotKeyControl; LANGUAGE = ObjC; SUPERCLASS = NDHotKeyControl; },
{
ACTIONS = {
grabNextHotKey = id;
grabPlayHotKey = id;
grabPrevHotKey = id;
hotKeyChanged = id;
};
CLASS = HotKeyPane;
LANGUAGE = ObjC;
OUTLETS = {
nextHotKeyControl = HotKeyControl;
playHotKeyControl = HotKeyControl;
prevHotKeyControl = HotKeyControl;
};
SUPERCLASS = PreferencePane;
},
{CLASS = NDHotKeyControl; LANGUAGE = ObjC; SUPERCLASS = NSTextField; },
{
ACTIONS = {takeDeviceID = id; };
CLASS = OutputPane;
LANGUAGE = ObjC;
OUTLETS = {outputDevices = OutputsArrayController; };
SUPERCLASS = PreferencePane;
},
{
CLASS = OutputsArrayController;
LANGUAGE = ObjC;
SUPERCLASS = NSArrayController;
},
{
CLASS = PrefPaneController;
LANGUAGE = ObjC;
OUTLETS = {
fileDrawerPane = FileDrawerPane;
hotKeyPane = HotKeyPane;
outputPane = OutputPane;
remoteView = NSView;
scrobblerView = NSView;
updatesView = NSView;
};
SUPERCLASS = NSObject;
},
{
CLASS = PreferencePane;
LANGUAGE = ObjC;
OUTLETS = {view = NSView; };
SUPERCLASS = NSObject;
},
{
ACTIONS = {takeBool = id; };
CLASS = RemotePane;
LANGUAGE = ObjC;
OUTLETS = {onlyOnActive = NSButton; };
SUPERCLASS = PreferencePane;
},
{CLASS = ScrobblerPane; LANGUAGE = ObjC; SUPERCLASS = PreferencePane; },
{CLASS = UpdatesPane; LANGUAGE = ObjC; SUPERCLASS = PreferencePane; }
);
IBVersion = 1;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBClasses</key>
<array>
<dict>
<key>CLASS</key>
<string>AppcastArrayController</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSArrayController</string>
</dict>
<dict>
<key>CLASS</key>
<string>HotKeyControl</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NDHotKeyControl</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>grabNextHotKey</key>
<string>id</string>
<key>grabPlayHotKey</key>
<string>id</string>
<key>grabPrevHotKey</key>
<string>id</string>
<key>hotKeyChanged</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>HotKeyPane</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>nextHotKeyControl</key>
<string>HotKeyControl</string>
<key>playHotKeyControl</key>
<string>HotKeyControl</string>
<key>prevHotKeyControl</key>
<string>HotKeyControl</string>
</dict>
<key>SUPERCLASS</key>
<string>PreferencePane</string>
</dict>
<dict>
<key>CLASS</key>
<string>PrefPaneController</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>fileDrawerPane</key>
<string>FileDrawerPane</string>
<key>hotKeyPane</key>
<string>HotKeyPane</string>
<key>outputPane</key>
<string>OutputPane</string>
<key>remoteView</key>
<string>NSView</string>
<key>scrobblerView</key>
<string>NSView</string>
<key>updatesView</key>
<string>NSView</string>
</dict>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>CLASS</key>
<string>OutputsArrayController</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSArrayController</string>
</dict>
<dict>
<key>CLASS</key>
<string>FirstResponder</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSObject</string>
<key>LANGUAGE</key>
<string>ObjC</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>openSheet</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>FileDrawerPane</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>rootPathTextView</key>
<string>NSTextField</string>
</dict>
<key>SUPERCLASS</key>
<string>PreferencePane</string>
</dict>
<dict>
<key>CLASS</key>
<string>NDHotKeyControl</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSTextField</string>
</dict>
<dict>
<key>CLASS</key>
<string>PreferencePane</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>view</key>
<string>NSView</string>
</dict>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>takeDeviceID</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>OutputPane</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>outputDevices</key>
<string>OutputsArrayController</string>
</dict>
<key>SUPERCLASS</key>
<string>PreferencePane</string>
</dict>
</array>
<key>IBVersion</key>
<string>1</string>
</dict>
</plist>

View File

@ -1,36 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>291 101 356 534 0 0 1680 1028 </string>
<key>IBEditorPositions</key>
<dict>
<key>10</key>
<string>171 910 506 102 0 0 1680 1028 </string>
<key>11</key>
<string>677 567 452 151 0 0 1680 1028 </string>
<key>43</key>
<string>166 683 452 116 0 0 1680 1028 </string>
<key>50</key>
<string>660 357 452 124 0 0 1680 1028 </string>
<key>58</key>
<string>641 480 452 101 0 0 1680 1028 </string>
<key>85</key>
<string>758 836 452 116 0 0 1680 1028 </string>
</dict>
<key>IBFramework Version</key>
<string>446.1</string>
<string>629</string>
<key>IBLastKnownRelativeProjectPath</key>
<string>../../General.xcodeproj</string>
<key>IBOldestOS</key>
<integer>5</integer>
<key>IBOpenObjects</key>
<array>
<integer>50</integer>
<integer>11</integer>
<integer>10</integer>
<integer>58</integer>
<integer>85</integer>
<integer>43</integer>
</array>
<key>IBSystem Version</key>
<string>8P2137</string>
<string>9B18</string>
<key>targetFramework</key>
<string>IBCocoaFramework</string>
</dict>
</plist>