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)seek:(id)sender;
- (IBAction)seekForward:(id)sender; - (IBAction)seekForward:(id)sender;
- (IBAction)seekBackward:(id)sender; - (IBAction)seekBackward:(id)sender;
- (IBAction)fadeOut:(id)sender withTime:(double)time;
- (void)initDefaults; - (void)initDefaults;
- (void)audioFader:(NSTimer *)audioTimer;
- (void)updateTimeField:(double)pos; - (void)updateTimeField:(double)pos;
- (void)playEntryAtIndex:(int)i; - (void)playEntryAtIndex:(int)i;
- (void)playEntry:(PlaylistEntry *)pe; - (void)playEntry:(PlaylistEntry *)pe;
- (int)status;
@end @end

View File

@ -1,6 +1,6 @@
#import "PlaybackController.h" #import "PlaybackController.h"
#import "PlaylistView.h" #import "PlaylistView.h"
#import <Foundation/NSTimer.h>
#import "CogAudio/Status.h" #import "CogAudio/Status.h"
#import "PlaylistController.h" #import "PlaylistController.h"
@ -53,8 +53,14 @@
- (void)awakeFromNib - (void)awakeFromNib
{ {
currentVolume = 100.0;
[volumeSlider setDoubleValue:pow(10.0, log10(0.5)/4.0)*100]; [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]; [positionSlider setEnabled:NO];
} }
@ -265,16 +271,57 @@
[audioPlayer setVolume:currentVolume]; [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 - (IBAction)volumeDown:(id)sender
{ {
double percent; double percent;
[volumeSlider setDoubleValue:([volumeSlider doubleValue] - 5)]; [volumeSlider setDoubleValue:([volumeSlider doubleValue] - 5)];
percent = (float)[volumeSlider doubleValue]/100.0; percent = (float)[volumeSlider doubleValue]/[volumeSlider maxValue];//100.0;
percent = percent * percent * percent * percent; percent = percent * percent * percent * percent;
currentVolume = percent * 100.0; currentVolume = (percent * [volumeSlider maxValue]) + [volumeSlider doubleValue];//100.0;
NSLog(@"currentVolume %f", currentVolume);
[audioPlayer setVolume:currentVolume]; [audioPlayer setVolume:currentVolume];
} }
@ -285,11 +332,16 @@
[volumeSlider setDoubleValue:([volumeSlider doubleValue] + 5)]; [volumeSlider setDoubleValue:([volumeSlider doubleValue] + 5)];
percent = (float)[volumeSlider doubleValue]/[volumeSlider maxValue]; percent = (float)[volumeSlider doubleValue]/[volumeSlider maxValue];//100.0;
percent = percent * percent * percent * percent; 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]; [audioPlayer setVolume:currentVolume];
} }
@ -362,11 +414,6 @@
} }
- (int)status
{
return playbackStatus;
}
- (void)audioPlayer:(AudioPlayer *)player statusChanged:(id)s - (void)audioPlayer:(AudioPlayer *)player statusChanged:(id)s
{ {
int status = [s intValue]; int status = [s intValue];

View File

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

View File

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

View File

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

View File

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