CQTexperiment
vspader 2006-01-20 15:41:31 +00:00
parent 733d0d78d0
commit ed0a1c9bec
14 changed files with 316 additions and 4 deletions

View File

@ -123,7 +123,6 @@
8EE90D3908830662002238C8 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8EE90D3708830662002238C8 /* Localizable.strings */; };
8EEBB7130977DF6800D5D854 /* PlaybackController.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8EEBB7110977DF6800D5D854 /* PlaybackController.h */; };
8EEBB7140977DF6800D5D854 /* PlaybackController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EEBB7120977DF6800D5D854 /* PlaybackController.m */; };
8EECB4510979945E005080E6 /* Status.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8EECB4500979945E005080E6 /* Status.h */; };
8EF7BCF10874708F0012C2F4 /* volume_high.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EF7BCEF0874708F0012C2F4 /* volume_high.png */; };
8EF7BCF20874708F0012C2F4 /* volume_low.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EF7BCF00874708F0012C2F4 /* volume_low.png */; };
/* End PBXBuildFile section */
@ -220,7 +219,6 @@
8EB090C70976955800DB1521 /* WavPackFile.h in CopyFiles */,
8EEBB7130977DF6800D5D854 /* PlaybackController.h in CopyFiles */,
8E888D5809795247007E984F /* Shuffle.h in CopyFiles */,
8EECB4510979945E005080E6 /* Status.h in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -353,7 +351,6 @@
8EE90D3808830662002238C8 /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/Localizable.strings; sourceTree = "<group>"; };
8EEBB7110977DF6800D5D854 /* PlaybackController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PlaybackController.h; sourceTree = "<group>"; };
8EEBB7120977DF6800D5D854 /* PlaybackController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = PlaybackController.m; sourceTree = "<group>"; };
8EECB4500979945E005080E6 /* Status.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Status.h; sourceTree = "<group>"; };
8EF7BCEF0874708F0012C2F4 /* volume_high.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = volume_high.png; path = Icons/volume_high.png; sourceTree = "<group>"; };
8EF7BCF00874708F0012C2F4 /* volume_low.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = volume_low.png; path = Icons/volume_low.png; sourceTree = "<group>"; };
/* End PBXFileReference section */
@ -602,7 +599,6 @@
8EB090750976953C00DB1521 /* Semaphore.m */,
8EB090760976953C00DB1521 /* VirtualRingBuffer.h */,
8EB090770976953C00DB1521 /* VirtualRingBuffer.m */,
8EECB4500979945E005080E6 /* Status.h */,
);
name = Utils;
sourceTree = "<group>";

View File

@ -426,6 +426,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
PRODUCT_NAME = DecMPA;
WRAPPER_EXTENSION = framework;
ZERO_LINK = YES;
@ -446,6 +447,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
PRODUCT_NAME = DecMPA;
WRAPPER_EXTENSION = framework;
ZERO_LINK = NO;
@ -464,6 +466,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
PRODUCT_NAME = DecMPA;
WRAPPER_EXTENSION = framework;
};

View File

@ -754,6 +754,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
OTHER_CFLAGS = "-DHAVE_CONFIG_H";
PRODUCT_NAME = FAAD2;
WRAPPER_EXTENSION = framework;
@ -780,6 +781,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
OTHER_CFLAGS = "-DHAVE_CONFIG_H";
PRODUCT_NAME = FAAD2;
WRAPPER_EXTENSION = framework;
@ -804,6 +806,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
OTHER_CFLAGS = "-DHAVE_CONFIG_H";
PRODUCT_NAME = FAAD2;
WRAPPER_EXTENSION = framework;

View File

@ -479,6 +479,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
OTHER_CFLAGS = (
"-DHAVE_INTTYPES_H",
"-DFLAC__ALIGN_MALLOC_DATA",
@ -510,6 +511,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
OTHER_CFLAGS = (
"-DHAVE_INTTYPES_H",
"-DFLAC__ALIGN_MALLOC_DATA",
@ -539,6 +541,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
OTHER_CFLAGS = (
"-DVERSION=1.1.2",
"-DHAVE_INTTYPES_H",

View File

@ -505,6 +505,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
OTHER_CFLAGS = (
"-maltivec",
"-faltivec",
@ -535,6 +536,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
OTHER_CFLAGS = (
"-maltivec",
"-faltivec",
@ -562,6 +564,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
OTHER_CFLAGS = (
"-maltivec",
"-faltivec",

View File

@ -326,6 +326,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
PRODUCT_NAME = MPCDec;
WRAPPER_EXTENSION = framework;
ZERO_LINK = YES;
@ -348,6 +349,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
PRODUCT_NAME = MPCDec;
WRAPPER_EXTENSION = framework;
ZERO_LINK = NO;
@ -368,6 +370,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
PRODUCT_NAME = MPCDec;
WRAPPER_EXTENSION = framework;
};

View File

@ -270,6 +270,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
OTHER_CFLAGS = "-D__MACOSX__";
PRODUCT_NAME = Ogg;
WRAPPER_EXTENSION = framework;
@ -291,6 +292,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
OTHER_CFLAGS = "-D__MACOSX__";
PRODUCT_NAME = Ogg;
WRAPPER_EXTENSION = framework;
@ -310,6 +312,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
OTHER_CFLAGS = "-D__MACOSX__";
PRODUCT_NAME = Ogg;
WRAPPER_EXTENSION = framework;

View File

@ -320,6 +320,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
OTHER_CFLAGS = "-DHAVE_CONFIG_H";
PRODUCT_NAME = Shorten;
WRAPPER_EXTENSION = framework;
@ -342,6 +343,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
OTHER_CFLAGS = "-DHAVE_CONFIG_H";
PRODUCT_NAME = Shorten;
WRAPPER_EXTENSION = framework;
@ -362,6 +364,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
OTHER_CFLAGS = "-DHAVE_CONFIG_H";
PRODUCT_NAME = Shorten;
WRAPPER_EXTENSION = framework;

View File

@ -565,6 +565,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
PRODUCT_NAME = SndFile;
WRAPPER_EXTENSION = framework;
ZERO_LINK = YES;
@ -585,6 +586,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
PRODUCT_NAME = SndFile;
WRAPPER_EXTENSION = framework;
ZERO_LINK = NO;
@ -603,6 +605,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
PRODUCT_NAME = SndFile;
WRAPPER_EXTENSION = framework;
};

View File

@ -728,6 +728,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
PRODUCT_NAME = TagLib;
WRAPPER_EXTENSION = framework;
ZERO_LINK = YES;
@ -748,6 +749,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
PRODUCT_NAME = TagLib;
WRAPPER_EXTENSION = framework;
ZERO_LINK = NO;
@ -766,6 +768,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
PRODUCT_NAME = TagLib;
WRAPPER_EXTENSION = framework;
};

View File

@ -576,6 +576,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
OTHER_CFLAGS = "-D__MACOSX__";
PRODUCT_NAME = Vorbis;
WRAPPER_EXTENSION = framework;
@ -603,6 +604,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
OTHER_CFLAGS = "-D__MACOSX__";
PRODUCT_NAME = Vorbis;
WRAPPER_EXTENSION = framework;
@ -628,6 +630,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
OTHER_CFLAGS = "-D__MACOSX__";
PRODUCT_NAME = Vorbis;
WRAPPER_EXTENSION = framework;

View File

@ -335,6 +335,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
OTHER_CFLAGS = (
"-DPACK",
"-DUNPACK",
@ -369,6 +370,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
OTHER_CFLAGS = (
"-DPACK",
"-DUNPACK",
@ -401,6 +403,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
LIBRARY_STYLE = DYNAMIC;
MACH_O_TYPE = mh_dylib;
OTHER_CFLAGS = (
"-DPACK",
"-DUNPACK",

60
PlaybackController.h Normal file
View File

@ -0,0 +1,60 @@
/* SoundController */
#import <Cocoa/Cocoa.h>
#import "SoundController.h"
#import "PlaylistController.h"
#import "TrackingSlider.h"
@class PlaylistView;
@interface PlaybackController : NSObject
{
IBOutlet PlaylistController *playlistController;
IBOutlet PlaylistView *playlistView;
IBOutlet TrackingSlider *positionSlider;
IBOutlet NSTextField *timeField;
IBOutlet NSTextField *lengthField;
IBOutlet NSTextField *bitrateField;
IBOutlet NSButton *playButton;
BOOL waitingForPlay; //No sneaky changing on us
SoundController *soundController;
int playbackStatus;
BOOL showTimeRemaining;
}
- (IBAction)toggleShowTimeRemaining:(id)sender;
- (IBAction)changeVolume:(id)sender;
- (IBAction)playPauseResume:(id)sender;
- (IBAction)pauseResume:(id)sender;
- (IBAction)play:(id)sender;
- (IBAction)pause:(id)sender;
- (IBAction)resume:(id)sender;
- (IBAction)stop:(id)sender;
- (IBAction)next:(id)sender;
- (IBAction)prev:(id)sender;
- (IBAction)seek:(id)sender;
- (void)updateTimeField:(double)pos;
- (void)playEntryAtIndex:(int)i;
- (void)playEntry:(PlaylistEntry *)pe;
//Methods since this is SoundController's delegate
- (void)delegateNotifyStatusUpdate:(int)status;
- (void)delegateNotifyPositionUpdate:(double)pos;
- (void)delegateNotifyBitrateUpdate:(float)bitrate;
- (void)delegateNotifySongChanged:(double)length;
- (void)delegateRequestNextSong:(int)queueSize;
@end

223
PlaybackController.m Normal file
View File

@ -0,0 +1,223 @@
#import "PlaybackController.h"
#import "PlaylistView.h"
#import "DBLog.h"
#import "Status.h"
@implementation PlaybackController
- (id)init
{
self = [super init];
if (self)
{
soundController = [[SoundController alloc] initWithDelegate:self];
playbackStatus = kCogStatusStopped;
showTimeRemaining = NO;
}
return self;
}
- (void)awakeFromNib
{
}
- (IBAction)playPauseResume:(id)sender
{
NSLog(@"PLAYING");
if (playbackStatus == kCogStatusStopped)
[self play:self];
else
[self pauseResume:self];
}
- (IBAction)pauseResume:(id)sender
{
// DBLog(@"Pause/Resume Sent!");
if (playbackStatus == kCogStatusPaused)
[self resume:self];
else
[self pause:self];
}
- (IBAction)pause:(id)sender
{
// DBLog(@"Pause Sent!");
[soundController pause];
}
- (IBAction)resume:(id)sender
{
// DBLog(@"Resume Sent!");
[soundController resume];
}
- (IBAction)stop:(id)sender
{
// DBLog(@"Stop Sent!");
[soundController stop];
}
//called by double-clicking on table
- (void)playEntryAtIndex:(int)i
{
PlaylistEntry *pe = [[playlistController arrangedObjects] objectAtIndex:i];
[playlistController setCurrentEntry:pe];
[self playEntry:pe];
}
- (IBAction)play:(id)sender
{
if ([playlistView selectedRow] == -1)
[playlistView selectRow:0 byExtendingSelection:NO];
[self playEntryAtIndex:[playlistView selectedRow]];
}
- (void)playEntry:(PlaylistEntry *)pe;
{
// DBLog(@"PlayEntry: %@ Sent!", [pe filename]);
[soundController play:[pe filename]];
}
- (IBAction)next:(id)sender
{
if ([playlistController next] == nil)
return;
[self playEntry:[playlistController currentEntry]];
}
- (IBAction)prev:(id)sender
{
if ([playlistController prev] == nil)
return;
[self playEntry:[playlistController currentEntry]];
}
- (IBAction)seek:(id)sender
{
// DBLog(@"SEEKING?");
double time;
time = [positionSlider doubleValue];
if ([sender tracking] == NO) // check if user stopped sliding before playing audio
[soundController seekToTime:time];
[self updateTimeField:time];
}
- (void)changePlayButtonImage:(NSString *)name
{
NSImage *img = [NSImage imageNamed:[name stringByAppendingString:@"_gray"]];
NSImage *alt = [NSImage imageNamed:[name stringByAppendingString:@"_blue"]];
[img retain];
[alt retain];
if (img == nil)
{
DBLog(@"NIL IMAGE!!!");
}
if (alt == nil)
{
DBLog(@"NIL ALT");
}
[playButton setImage:img];
[playButton setAlternateImage:alt];
}
- (IBAction)changeVolume:(id)sender
{
float v = (float)[sender doubleValue];
[soundController setVolume:v];
}
- (void)updateTimeField:(double)pos
{
NSString *text;
if (showTimeRemaining == NO)
{
int sec = (int)(pos/1000.0);
text = [NSString stringWithFormat:NSLocalizedString(@"TimeElapsed", @""), sec/60, sec%60];
}
else
{
int sec = (int)(([positionSlider maxValue] - pos)/1000.0);
text = [NSString stringWithFormat:NSLocalizedString(@"TimeRemaining", @""), sec/60, sec%60];
}
[timeField setStringValue:text];
}
- (IBAction)toggleShowTimeRemaining:(id)sender
{
showTimeRemaining = !showTimeRemaining;
[self updateTimeField:[positionSlider doubleValue]];
}
- (void)delegateRequestNextSong:(int)queueSize
{
PlaylistEntry *pe;
pe = [playlistController entryAtOffset:(queueSize+1)];
if (pe == nil)
[soundController setNextSong:nil];
else
[soundController setNextSong:[pe filename]];
}
- (void)delegateNotifySongChanged:(double)length
{
[playlistController next];
// [positionSlider setMaxValue:length];
// [positionSlider setDoubleValue:0];
// [self updateTimeField:0.0f];
}
- (void)delegateNotifyBitrateUpdate:(float)bitrate
{
// [bitrateField setIntValue:bitrate];
}
- (void)delegateNotifyPositionUpdate:(double)pos
{
if ([positionSlider tracking] == NO)
{
// DBLog(@"Received pos update: %f", pos);
[positionSlider setDoubleValue:pos];
[self updateTimeField:pos];
}
}
- (void)delegateNotifyStatusUpdate:(int)status
{
if (status == kCogStatusStopped || status == kCogStatusPaused)
{
//Show play image
[self changePlayButtonImage:@"play"];
}
else if (status == kCogStatusPlaying)
{
//Show pause
[self changePlayButtonImage:@"pause"];
}
playbackStatus = status;
}
@end