Compare commits
47 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c6ed4c48b6 | |||
| d65c918f00 | |||
| e771fe257a | |||
| 7fc587d3af | |||
| 7bcf2517cb | |||
| 47de71d817 | |||
| cdee3dadd5 | |||
| 4b76949836 | |||
| 55172b2356 | |||
| 302a047f6a | |||
| 2705a7b559 | |||
| e620db225a | |||
| 6f51b2b387 | |||
| a8202b44ad | |||
| ddfe22106f | |||
| 64a9e963ee | |||
| 2309329709 | |||
| bb19920533 | |||
| 44429ec91a | |||
| 3936165aeb | |||
| 996744ffc4 | |||
| 3ae090c761 | |||
| 33bdcee78a | |||
| 081c7047f5 | |||
| 4d952e2fa5 | |||
| f2084dab2a | |||
| 115dc2b8a0 | |||
| a832f27a5a | |||
| 199f63d7e2 | |||
| f5f40304d0 | |||
| 6ea04c0f7b | |||
| ab9fb5b9bd | |||
| f98d520efd | |||
| 6a44909a2f | |||
| c85d1d9d2f | |||
| d03a5f76e6 | |||
| 6d7625027f | |||
| cce5ee0af1 | |||
| cc868e79dd | |||
| d2ad3d2034 | |||
| 3fdb33209d | |||
| e16c775be8 | |||
| 59a3a22c6a | |||
| 4c7719f168 | |||
| 5789954cb9 | |||
| c34c7c9f89 | |||
| 6745265dd5 |
+2
-2
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "EZAudio"
|
||||
s.version = "0.3.0"
|
||||
s.version = "0.6.0"
|
||||
s.summary = "A simple, intuitive audio framework for iOS and OSX useful for anyone doing audio processing and/or audio-based visualizations."
|
||||
s.homepage = "https://github.com/syedhali/EZAudio"
|
||||
s.screenshots = "https://s3-us-west-1.amazonaws.com/ezaudio-media/EZAudioSummary.png"
|
||||
@@ -15,4 +15,4 @@ Pod::Spec.new do |s|
|
||||
s.osx.frameworks = 'AudioToolbox','AudioUnit','CoreAudio','QuartzCore','OpenGL','GLKit'
|
||||
s.dependency 'TPCircularBuffer', '~> 0.0'
|
||||
s.requires_arc = true;
|
||||
end
|
||||
end
|
||||
@@ -43,7 +43,6 @@
|
||||
#import "EZPlot.h"
|
||||
#import "EZAudioPlot.h"
|
||||
#import "EZAudioPlotGL.h"
|
||||
#import "EZAudioPlotGLKViewController.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
+25
-9
@@ -33,6 +33,14 @@
|
||||
*/
|
||||
+ (NSArray *)inputDevices;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Enumerates all the available output devices and returns the result in an NSArray of EZAudioDevice instances.
|
||||
@return An NSArray of output EZAudioDevice instances.
|
||||
*/
|
||||
+ (NSArray *)outputDevices;
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
|
||||
/**
|
||||
@@ -42,6 +50,13 @@
|
||||
*/
|
||||
+ (EZAudioDevice *)currentInputDevice;
|
||||
|
||||
/**
|
||||
Provides the current EZAudioDevice that is being used to output audio.
|
||||
- iOS only
|
||||
@return An EZAudioDevice instance representing the currently selected ouotput device.
|
||||
*/
|
||||
+ (EZAudioDevice *)currentOutputDevice;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -52,6 +67,16 @@
|
||||
+ (void)enumerateInputDevicesUsingBlock:(void(^)(EZAudioDevice *device,
|
||||
BOOL *stop))block;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Enumerates all the available output devices.
|
||||
- iOS only
|
||||
@param block When enumerating this block executes repeatedly for each EZAudioDevice found. It contains two arguments - first, the EZAudioDevice found, then a pointer to a stop BOOL to allow breaking out of the enumeration)
|
||||
*/
|
||||
+ (void)enumerateOutputDevicesUsingBlock:(void (^)(EZAudioDevice *device,
|
||||
BOOL *stop))block;
|
||||
|
||||
#elif TARGET_OS_MAC
|
||||
|
||||
/**
|
||||
@@ -63,15 +88,6 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Enumerates all the available output devices and returns the result in an NSArray of EZAudioDevice instances.
|
||||
- OSX only
|
||||
@return An NSArray of output EZAudioDevice instances.
|
||||
*/
|
||||
+ (NSArray *)outputDevices;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Enumerates all the available devices.
|
||||
- OSX only
|
||||
|
||||
@@ -49,6 +49,19 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
+ (EZAudioDevice *)currentOutputDevice
|
||||
{
|
||||
AVAudioSession *session = [AVAudioSession sharedInstance];
|
||||
AVAudioSessionPortDescription *port = [[[session currentRoute] outputs] firstObject];
|
||||
AVAudioSessionDataSourceDescription *dataSource = [session outputDataSource];
|
||||
EZAudioDevice *device = [[EZAudioDevice alloc] init];
|
||||
device.port = port;
|
||||
device.dataSource = dataSource;
|
||||
return device;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
+ (NSArray *)inputDevices
|
||||
{
|
||||
__block NSMutableArray *devices = [NSMutableArray array];
|
||||
@@ -61,6 +74,18 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
+ (NSArray *)outputDevices
|
||||
{
|
||||
__block NSMutableArray *devices = [NSMutableArray array];
|
||||
[self enumerateOutputDevicesUsingBlock:^(EZAudioDevice *device, BOOL *stop)
|
||||
{
|
||||
[devices addObject:device];
|
||||
}];
|
||||
return devices;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
+ (void)enumerateInputDevicesUsingBlock:(void (^)(EZAudioDevice *, BOOL *))block
|
||||
{
|
||||
if (!block)
|
||||
@@ -101,6 +126,42 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
+ (void)enumerateOutputDevicesUsingBlock:(void (^)(EZAudioDevice *, BOOL *))block
|
||||
{
|
||||
if (!block)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AVAudioSessionRouteDescription *currentRoute = [[AVAudioSession sharedInstance] currentRoute];
|
||||
NSArray *portDescriptions = [currentRoute outputs];
|
||||
|
||||
BOOL stop;
|
||||
for (AVAudioSessionPortDescription *outputDevicePortDescription in portDescriptions)
|
||||
{
|
||||
// add any additional sub-devices
|
||||
NSArray *dataSources = [outputDevicePortDescription dataSources];
|
||||
if (dataSources.count)
|
||||
{
|
||||
for (AVAudioSessionDataSourceDescription *outputDeviceDataSourceDescription in dataSources)
|
||||
{
|
||||
EZAudioDevice *device = [[EZAudioDevice alloc] init];
|
||||
device.port = outputDevicePortDescription;
|
||||
device.dataSource = outputDeviceDataSourceDescription;
|
||||
block(device, &stop);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EZAudioDevice *device = [[EZAudioDevice alloc] init];
|
||||
device.port = outputDevicePortDescription;
|
||||
block(device, &stop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (NSString *)name
|
||||
{
|
||||
NSMutableString *name = [NSMutableString string];
|
||||
|
||||
@@ -80,7 +80,7 @@ typedef void (^EZAudioWaveformDataCompletionBlock)(float **waveformData, int len
|
||||
/**
|
||||
The EZAudioFile provides a lightweight and intuitive way to asynchronously interact with audio files. These interactions included reading audio data, seeking within an audio file, getting information about the file, and pulling the waveform data for visualizing the contents of the audio file. The EZAudioFileDelegate provides event callbacks for when reads, seeks, and various updates happen within the audio file to allow the caller to interact with the action in meaningful ways. Common use cases here could be to read the audio file's data as AudioBufferList structures for output (see EZOutput) and visualizing the audio file's data as a float array using an audio plot (see EZAudioPlot).
|
||||
*/
|
||||
@interface EZAudioFile : NSObject
|
||||
@interface EZAudioFile : NSObject <NSCopying>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Properties
|
||||
|
||||
@@ -160,6 +160,15 @@ typedef struct
|
||||
clientFormat:clientFormat];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - NSCopying
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (id)copyWithZone:(NSZone *)zone
|
||||
{
|
||||
return [EZAudioFile audioFileWithURL:self.url];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Class Methods
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -667,6 +676,29 @@ typedef struct
|
||||
[self seekToFrame:frame];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Description
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (NSString *)description
|
||||
{
|
||||
return [NSString stringWithFormat:@"%@ {\n"
|
||||
" url: %@,\n"
|
||||
" duration: %f,\n"
|
||||
" totalFrames: %lld,\n"
|
||||
" metadata: %@,\n"
|
||||
" fileFormat: { %@ },\n"
|
||||
" clientFormat: { %@ } \n"
|
||||
"}",
|
||||
[super description],
|
||||
[self url],
|
||||
[self duration],
|
||||
[self totalFrames],
|
||||
[self metadata],
|
||||
[EZAudioUtilities stringForAudioStreamBasicDescription:[self fileFormat]],
|
||||
[EZAudioUtilities stringForAudioStreamBasicDescription:[self clientFormat]]];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@end
|
||||
|
||||
+219
-106
@@ -28,41 +28,60 @@
|
||||
#import "EZAudioFile.h"
|
||||
#import "EZOutput.h"
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#elif TARGET_OS_MAC
|
||||
#endif
|
||||
|
||||
@class EZAudioPlayer;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Notifications
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
The EZAudioPlayerDelegate provides event callbacks for the EZAudioPlayer. These type of events are triggered by changes in the EZAudioPlayer's state and allow someone implementing the EZAudioPlayer to more easily update their user interface. Events are triggered anytime the EZAudioPlayer resumes/pauses playback, reaches the end of the file, reads audio data and converts it to float data visualizations (using the EZAudioFile), and updates its cursor position within the audio file during playback (use this for the play position on a slider on the user interface).
|
||||
Notification that occurs whenever the EZAudioPlayer changes its `audioFile` property. Check the new value using the EZAudioPlayer's `audioFile` property.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const EZAudioPlayerDidChangeAudioFileNotification;
|
||||
|
||||
/**
|
||||
Notification that occurs whenever the EZAudioPlayer changes its `device` property. Check the new value using the EZAudioPlayer's `device` property.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const EZAudioPlayerDidChangeOutputDeviceNotification;
|
||||
|
||||
/**
|
||||
Notification that occurs whenever the EZAudioPlayer changes its `output` component's `pan` property. Check the new value using the EZAudioPlayer's `pan` property.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const EZAudioPlayerDidChangePanNotification;
|
||||
|
||||
/**
|
||||
Notification that occurs whenever the EZAudioPlayer changes its `output` component's play state. Check the new value using the EZAudioPlayer's `isPlaying` property.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const EZAudioPlayerDidChangePlayStateNotification;
|
||||
|
||||
/**
|
||||
Notification that occurs whenever the EZAudioPlayer changes its `output` component's `volume` property. Check the new value using the EZAudioPlayer's `volume` property.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const EZAudioPlayerDidChangeVolumeNotification;
|
||||
|
||||
/**
|
||||
Notification that occurs whenever the EZAudioPlayer has reached the end of a file and its `shouldLoop` property has been set to NO.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const EZAudioPlayerDidReachEndOfFileNotification;
|
||||
|
||||
/**
|
||||
Notification that occurs whenever the EZAudioPlayer performs a seek via the `seekToFrame` method or `setCurrentTime:` property setter. Check the new `currentTime` or `frameIndex` value using the EZAudioPlayer's `currentTime` or `frameIndex` property, respectively.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString * const EZAudioPlayerDidSeekNotification;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - EZAudioPlayerDelegate
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
The EZAudioPlayerDelegate provides event callbacks for the EZAudioPlayer. Since 0.5.0 the EZAudioPlayerDelegate provides a smaller set of delegate methods in favor of notifications to allow multiple receivers of the EZAudioPlayer event callbacks since only one player is typically used in an application. Specifically, these methods are provided for high frequency callbacks that wrap the EZAudioPlayer's internal EZAudioFile and EZOutput instances.
|
||||
@warning These callbacks don't necessarily occur on the main thread so make sure you wrap any UI code in a GCD block like: dispatch_async(dispatch_get_main_queue(), ^{ // Update UI });
|
||||
*/
|
||||
@protocol EZAudioPlayerDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
/**
|
||||
Triggered by the EZAudioPlayer when the playback has been resumed or started.
|
||||
@param audioPlayer The instance of the EZAudioPlayer that triggered the event
|
||||
@param audioFile The instance of the EZAudioFile that the event was triggered from
|
||||
*/
|
||||
-(void)audioPlayer:(EZAudioPlayer*)audioPlayer didResumePlaybackOnAudioFile:(EZAudioFile*)audioFile;
|
||||
|
||||
/**
|
||||
Triggered by the EZAudioPlayer when the playback has been paused.
|
||||
@param audioPlayer The instance of the EZAudioPlayer that triggered the event
|
||||
@param audioFile The instance of the EZAudioFile that the event was triggered from
|
||||
*/
|
||||
-(void)audioPlayer:(EZAudioPlayer*)audioPlayer didPausePlaybackOnAudioFile:(EZAudioFile*)audioFile;
|
||||
|
||||
/**
|
||||
Triggered by the EZAudioPlayer when the output has reached the end of the EZAudioFile it's playing. If the EZAudioPlayer has its `shouldLoop` property set to true this will trigger, but playback will continue to loop once its hit the end of the audio file.
|
||||
@param audioPlayer The instance of the EZAudioPlayer that triggered the event
|
||||
@param audioFile The instance of the EZAudioFile that the event was triggered from
|
||||
*/
|
||||
-(void)audioPlayer:(EZAudioPlayer*)audioPlayer reachedEndOfAudioFile:(EZAudioFile*)audioFile;
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Triggered by the EZAudioPlayer's internal EZAudioFile's EZAudioFileDelegate callback and notifies the delegate of the read audio data as a float array instead of a buffer list. Common use case of this would be to visualize the float data using an audio plot or audio data dependent OpenGL sketch.
|
||||
@@ -72,11 +91,13 @@
|
||||
@param numberOfChannels The number of channels. 2 for stereo, 1 for mono.
|
||||
@param audioFile The instance of the EZAudioFile that the event was triggered from
|
||||
*/
|
||||
-(void) audioPlayer:(EZAudioPlayer*)audioPlayer
|
||||
readAudio:(float**)buffer
|
||||
- (void) audioPlayer:(EZAudioPlayer *)audioPlayer
|
||||
playedAudio:(float **)buffer
|
||||
withBufferSize:(UInt32)bufferSize
|
||||
withNumberOfChannels:(UInt32)numberOfChannels
|
||||
inAudioFile:(EZAudioFile*)audioFile;;
|
||||
inAudioFile:(EZAudioFile *)audioFile;;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Triggered by EZAudioPlayer's internal EZAudioFile's EZAudioFileDelegate callback and notifies the delegate of the current playback position. The framePosition provides the current frame position and can be calculated against the EZAudioPlayer's total frames using the `totalFrames` function from the EZAudioPlayer.
|
||||
@@ -84,18 +105,27 @@
|
||||
@param framePosition The new frame index as a 64-bit signed integer
|
||||
@param audioFile The instance of the EZAudioFile that the event was triggered from
|
||||
*/
|
||||
-(void)audioPlayer:(EZAudioPlayer*)audioPlayer
|
||||
updatedPosition:(SInt64)framePosition
|
||||
inAudioFile:(EZAudioFile*)audioFile;
|
||||
- (void)audioPlayer:(EZAudioPlayer *)audioPlayer
|
||||
updatedPosition:(SInt64)framePosition
|
||||
inAudioFile:(EZAudioFile *)audioFile;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
The EZAudioPlayer acts as the master delegate (the EZAudioFileDelegate) over whatever EZAudioFile it is using for playback. Classes that want to get the EZAudioFileDelegate callbacks should implement the EZAudioPlayer's EZAudioPlayerDelegate on the EZAudioPlayer instance.
|
||||
*/
|
||||
@interface EZAudioPlayer : NSObject
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - EZAudioPlayer
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
The EZAudioPlayer provides an interface that combines the EZAudioFile and EZOutput to play local audio files. This class acts as the master delegate (the EZAudioFileDelegate) over whatever EZAudioFile instance, the `audioFile` property, it is using for playback as well as the EZOutputDelegate and EZOutputDataSource over whatever EZOutput instance is set as the `output`. Classes that want to get the EZAudioFileDelegate callbacks should implement the EZAudioPlayer's EZAudioPlayerDelegate on the EZAudioPlayer instance. Since 0.5.0 the EZAudioPlayer offers notifications over the usual delegate methods to allow multiple receivers to get the EZAudioPlayer's state changes since one player will typically be used in one application. The EZAudioPlayerDelegate, the `delegate`, provides callbacks for high frequency methods that simply wrap the EZAudioFileDelegate and EZOutputDelegate callbacks for providing the audio buffer played as well as the position updating (you will typically have one scrub bar in an application).
|
||||
*/
|
||||
@interface EZAudioPlayer : NSObject <EZAudioFileDelegate,
|
||||
EZOutputDataSource,
|
||||
EZOutputDelegate>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Properties
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
///-----------------------------------------------------------
|
||||
/// @name Properties
|
||||
///-----------------------------------------------------------
|
||||
@@ -103,14 +133,19 @@
|
||||
/**
|
||||
The EZAudioPlayerDelegate that will handle the audio player callbacks
|
||||
*/
|
||||
@property (nonatomic,assign) id<EZAudioPlayerDelegate> audioPlayerDelegate;
|
||||
@property (nonatomic, weak) id<EZAudioPlayerDelegate> delegate;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
A BOOL indicating whether the player should loop the file
|
||||
*/
|
||||
@property (nonatomic,assign) BOOL shouldLoop;
|
||||
@property (nonatomic, assign) BOOL shouldLoop;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Initializers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
///-----------------------------------------------------------
|
||||
/// @name Initializers
|
||||
///-----------------------------------------------------------
|
||||
@@ -120,72 +155,114 @@
|
||||
@param audioFile The instance of the EZAudioFile to use for initializing the EZAudioPlayer
|
||||
@return The newly created instance of the EZAudioPlayer
|
||||
*/
|
||||
-(EZAudioPlayer*)initWithEZAudioFile:(EZAudioFile*)audioFile;
|
||||
- (instancetype)initWithAudioFile:(EZAudioFile *)audioFile;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Initializes the EZAudioPlayer with an EZAudioFile instance and provides a way to assign the EZAudioPlayerDelegate on instantiation. This does not use the EZAudioFile by reference, but instead creates a separate EZAudioFile instance with the same file at the given file path provided by the internal NSURL to use for internal seeking so it doesn't cause any locking between the caller's instance of the EZAudioFile.
|
||||
@param audioFile The instance of the EZAudioFile to use for initializing the EZAudioPlayer
|
||||
@param audioPlayerDelegate The receiver that will act as the EZAudioPlayerDelegate. Set to nil if it should have no delegate or use the initWithEZAudioFile: function instead.
|
||||
@param delegate The receiver that will act as the EZAudioPlayerDelegate. Set to nil if it should have no delegate or use the initWithAudioFile: function instead.
|
||||
@return The newly created instance of the EZAudioPlayer
|
||||
*/
|
||||
-(EZAudioPlayer*)initWithEZAudioFile:(EZAudioFile*)audioFile
|
||||
withDelegate:(id<EZAudioPlayerDelegate>)audioPlayerDelegate;
|
||||
- (instancetype)initWithAudioFile:(EZAudioFile *)audioFile
|
||||
delegate:(id<EZAudioPlayerDelegate>)delegate;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Initializes the EZAudioPlayer with an EZAudioPlayerDelegate.
|
||||
@param delegate The receiver that will act as the EZAudioPlayerDelegate. Set to nil if it should have no delegate or use the initWithAudioFile: function instead.
|
||||
@return The newly created instance of the EZAudioPlayer
|
||||
*/
|
||||
- (instancetype)initWithDelegate:(id<EZAudioPlayerDelegate>)delegate;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Initializes the EZAudioPlayer with an NSURL instance representing the file path of the audio file.
|
||||
@param url The NSURL instance representing the file path of the audio file.
|
||||
@return The newly created instance of the EZAudioPlayer
|
||||
*/
|
||||
-(EZAudioPlayer*)initWithURL:(NSURL*)url;
|
||||
- (instancetype)initWithURL:(NSURL*)url;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Initializes the EZAudioPlayer with an NSURL instance representing the file path of the audio file and a caller to assign as the EZAudioPlayerDelegate on instantiation.
|
||||
@param url The NSURL instance representing the file path of the audio file.
|
||||
@param audioPlayerDelegate The receiver that will act as the EZAudioPlayerDelegate. Set to nil if it should have no delegate or use the initWithEZAudioFile: function instead.
|
||||
@param delegate The receiver that will act as the EZAudioPlayerDelegate. Set to nil if it should have no delegate or use the initWithAudioFile: function instead.
|
||||
@return The newly created instance of the EZAudioPlayer
|
||||
*/
|
||||
-(EZAudioPlayer*)initWithURL:(NSURL*)url
|
||||
withDelegate:(id<EZAudioPlayerDelegate>)audioPlayerDelegate;
|
||||
|
||||
- (instancetype)initWithURL:(NSURL*)url
|
||||
delegate:(id<EZAudioPlayerDelegate>)delegate;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Class Initializers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
///-----------------------------------------------------------
|
||||
/// @name Class Initializers
|
||||
///-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
Class initializer that initializes the EZAudioPlayer with an EZAudioFile instance. This does not use the EZAudioFile by reference, but instead creates a separate EZAudioFile instance with the same file at the given file path provided by the internal NSURL to use for internal seeking so it doesn't cause any locking between the caller's instance of the EZAudioFile.
|
||||
Class initializer that creates a default EZAudioPlayer.
|
||||
@return The newly created instance of the EZAudioPlayer
|
||||
*/
|
||||
+ (instancetype)audioPlayer;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Class initializer that creates the EZAudioPlayer with an EZAudioFile instance. This does not use the EZAudioFile by reference, but instead creates a separate EZAudioFile instance with the same file at the given file path provided by the internal NSURL to use for internal seeking so it doesn't cause any locking between the caller's instance of the EZAudioFile.
|
||||
@param audioFile The instance of the EZAudioFile to use for initializing the EZAudioPlayer
|
||||
@return The newly created instance of the EZAudioPlayer
|
||||
*/
|
||||
+(EZAudioPlayer*)audioPlayerWithEZAudioFile:(EZAudioFile*)audioFile;
|
||||
+ (instancetype)audioPlayerWithAudioFile:(EZAudioFile *)audioFile;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Class initializer that initializes the EZAudioPlayer with an EZAudioFile instance and provides a way to assign the EZAudioPlayerDelegate on instantiation. This does not use the EZAudioFile by reference, but instead creates a separate EZAudioFile instance with the same file at the given file path provided by the internal NSURL to use for internal seeking so it doesn't cause any locking between the caller's instance of the EZAudioFile.
|
||||
Class initializer that creates the EZAudioPlayer with an EZAudioFile instance and provides a way to assign the EZAudioPlayerDelegate on instantiation. This does not use the EZAudioFile by reference, but instead creates a separate EZAudioFile instance with the same file at the given file path provided by the internal NSURL to use for internal seeking so it doesn't cause any locking between the caller's instance of the EZAudioFile.
|
||||
@param audioFile The instance of the EZAudioFile to use for initializing the EZAudioPlayer
|
||||
@param audioPlayerDelegate The receiver that will act as the EZAudioPlayerDelegate. Set to nil if it should have no delegate or use the audioPlayerWithEZAudioFile: function instead.
|
||||
@param delegate The receiver that will act as the EZAudioPlayerDelegate. Set to nil if it should have no delegate or use the audioPlayerWithAudioFile: function instead.
|
||||
@return The newly created instance of the EZAudioPlayer
|
||||
*/
|
||||
+(EZAudioPlayer*)audioPlayerWithEZAudioFile:(EZAudioFile*)audioFile
|
||||
withDelegate:(id<EZAudioPlayerDelegate>)audioPlayerDelegate;
|
||||
+ (instancetype)audioPlayerWithAudioFile:(EZAudioFile *)audioFile
|
||||
delegate:(id<EZAudioPlayerDelegate>)delegate;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Class initializer that initializes the EZAudioPlayer with an NSURL instance representing the file path of the audio file.
|
||||
Class initializer that creates a default EZAudioPlayer with an EZAudioPlayerDelegate..
|
||||
@return The newly created instance of the EZAudioPlayer
|
||||
*/
|
||||
+ (instancetype)audioPlayerWithDelegate:(id<EZAudioPlayerDelegate>)delegate;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Class initializer that creates the EZAudioPlayer with an NSURL instance representing the file path of the audio file.
|
||||
@param url The NSURL instance representing the file path of the audio file.
|
||||
@return The newly created instance of the EZAudioPlayer
|
||||
*/
|
||||
+(EZAudioPlayer*)audioPlayerWithURL:(NSURL*)url;
|
||||
+ (instancetype)audioPlayerWithURL:(NSURL*)url;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Class initializer that initializes the EZAudioPlayer with an NSURL instance representing the file path of the audio file and a caller to assign as the EZAudioPlayerDelegate on instantiation.
|
||||
Class initializer that creates the EZAudioPlayer with an NSURL instance representing the file path of the audio file and a caller to assign as the EZAudioPlayerDelegate on instantiation.
|
||||
@param url The NSURL instance representing the file path of the audio file.
|
||||
@param audioPlayerDelegate The receiver that will act as the EZAudioPlayerDelegate. Set to nil if it should have no delegate or use the audioPlayerWithURL: function instead.
|
||||
@param delegate The receiver that will act as the EZAudioPlayerDelegate. Set to nil if it should have no delegate or use the audioPlayerWithURL: function instead.
|
||||
@return The newly created instance of the EZAudioPlayer
|
||||
*/
|
||||
+(EZAudioPlayer*)audioPlayerWithURL:(NSURL*)url
|
||||
withDelegate:(id<EZAudioPlayerDelegate>)audioPlayerDelegate;
|
||||
+ (instancetype)audioPlayerWithURL:(NSURL*)url
|
||||
delegate:(id<EZAudioPlayerDelegate>)delegate;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Singleton
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
///-----------------------------------------------------------
|
||||
/// @name Shared Instance
|
||||
///-----------------------------------------------------------
|
||||
@@ -194,108 +271,144 @@
|
||||
The shared instance (singleton) of the audio player. Most applications will only have one instance of the EZAudioPlayer that can be reused with multiple different audio files.
|
||||
* @return The shared instance of the EZAudioPlayer.
|
||||
*/
|
||||
+(EZAudioPlayer*)sharedAudioPlayer;
|
||||
+ (instancetype)sharedAudioPlayer;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Properties
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#pragma mark - Getters
|
||||
///-----------------------------------------------------------
|
||||
/// @name Getting The Audio Player's Properties
|
||||
/// @name Properties
|
||||
///-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides the EZAudioFile instance that is being used as the datasource for playback.
|
||||
@return The EZAudioFile instance that is currently being used for playback.
|
||||
Provides the EZAudioFile instance that is being used as the datasource for playback. When set it creates a copy of the EZAudioFile provided for internal use. This does not use the EZAudioFile by reference, but instead creates a copy of the EZAudioFile instance provided.
|
||||
*/
|
||||
-(EZAudioFile*)audioFile;
|
||||
@property (nonatomic, readwrite, copy) EZAudioFile *audioFile;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides the current time (a.k.a. the seek position) in seconds within the audio file that's being used for playback. This can be helpful when displaying the audio player's current time over duration.
|
||||
@return A float representing the current time within the audio file used for playback.
|
||||
Provides the current offset in the audio file as an NSTimeInterval (i.e. in seconds). When setting this it will determine the correct frame offset and perform a `seekToFrame` to the new time offset.
|
||||
@warning Make sure the new current time offset is less than the `duration` or you will receive an invalid seek assertion.
|
||||
*/
|
||||
-(float)currentTime;
|
||||
@property (nonatomic, readwrite) NSTimeInterval currentTime;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides a flag indicating whether the EZAudioPlayer has reached the end of the audio file used for playback.
|
||||
@return A BOOL indicating whether or not the EZAudioPlayer has reached the end of the file it is using for playback.
|
||||
The EZAudioDevice instance that is being used by the `output`. Similarly, setting this just sets the `device` property of the `output`.
|
||||
*/
|
||||
-(BOOL)endOfFile;
|
||||
@property (readwrite) EZAudioDevice *device;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides the duration of the audio file in seconds.
|
||||
*/
|
||||
@property (readonly) NSTimeInterval duration;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides the current time as an NSString with the time format MM:SS.
|
||||
*/
|
||||
@property (readonly) NSString *formattedCurrentTime;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides the duration as an NSString with the time format MM:SS.
|
||||
*/
|
||||
@property (readonly) NSString *formattedDuration;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides the EZOutput that is being used to handle the actual playback of the audio data. This property is also settable, but note that the EZAudioPlayer will become the output's EZOutputDataSource and EZOutputDelegate. To listen for the EZOutput's delegate methods your view should implement the EZAudioPlayerDelegate and set itself as the EZAudioPlayer's `delegate`.
|
||||
*/
|
||||
@property (nonatomic, strong, readwrite) EZOutput *output;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides the frame index (a.k.a the seek positon) within the audio file being used for playback. This can be helpful when seeking through the audio file.
|
||||
@return An SInt64 representing the current frame index within the audio file used for playback.
|
||||
*/
|
||||
-(SInt64)frameIndex;
|
||||
@property (readonly) SInt64 frameIndex;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides a flag indicating whether the EZAudioPlayer is currently playing back any audio.
|
||||
@return A BOOL indicating whether or not the EZAudioPlayer is performing playback,
|
||||
*/
|
||||
-(BOOL)isPlaying;
|
||||
@property (readonly) BOOL isPlaying;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides the EZOutput instance that is being used to provide playback to the system output.
|
||||
@return The EZOutput instance that is currently being used for output playback.
|
||||
Provides the current pan from the audio player's internal `output` component. Setting the pan adjusts the direction of the audio signal from left (0) to right (1). Default is 0.5 (middle).
|
||||
*/
|
||||
-(EZOutput*)output;
|
||||
@property (nonatomic, assign) float pan;
|
||||
|
||||
/**
|
||||
Provides the total duration of the current audio file being used for playback (in seconds).
|
||||
@return A float representing the total duration of the current audio file being used for playback in seconds.
|
||||
*/
|
||||
-(float)totalDuration;
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides the total amount of frames in the current audio file being used for playback.
|
||||
@return A SInt64 representing the total amount of frames in the current audio file being used for playback.
|
||||
*/
|
||||
-(SInt64)totalFrames;
|
||||
@property (readonly) SInt64 totalFrames;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides the file path that's currently being used by the player for playback.
|
||||
@return The NSURL representing the file path of the audio file being used for playback.
|
||||
*/
|
||||
-(NSURL*)url;
|
||||
@property (nonatomic, copy, readonly) NSURL *url;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides the current volume from the audio player's internal `output` component. Setting the volume adjusts the gain of the output between 0 and 1. Default is 1.
|
||||
*/
|
||||
@property (nonatomic, assign) float volume;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Actions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#pragma mark - Setters
|
||||
///-----------------------------------------------------------
|
||||
/// @name Setting The File/Output
|
||||
/// @name Controlling Playback
|
||||
///-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
Sets the EZAudioFile to use for playback. This does not use the EZAudioFile by reference, but instead creates a separate EZAudioFile instance with the same file at the given file path provided by the internal NSURL to use for internal seeking so it doesn't cause any locking between the caller's instance of the EZAudioFile.
|
||||
@param audioFile The new EZAudioFile instance that should be used for playback
|
||||
Starts playback.
|
||||
*/
|
||||
-(void)setAudioFile:(EZAudioFile*)audioFile;
|
||||
- (void)play;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Sets the EZOutput to route playback. By default this uses the [EZOutput sharedOutput] singleton.
|
||||
@param output The new EZOutput instance that should be used for playback
|
||||
Loads an EZAudioFile and immediately starts playing it.
|
||||
@param audioFile An EZAudioFile to use for immediate playback.
|
||||
*/
|
||||
-(void)setOutput:(EZOutput*)output;
|
||||
- (void)playAudioFile:(EZAudioFile *)audioFile;
|
||||
|
||||
#pragma mark - Methods
|
||||
///-----------------------------------------------------------
|
||||
/// @name Play/Pause/Seeking the Player
|
||||
///-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
Starts or resumes playback.
|
||||
*/
|
||||
-(void)play;
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Pauses playback.
|
||||
*/
|
||||
-(void)pause;
|
||||
- (void)pause;
|
||||
|
||||
/**
|
||||
Stops playback.
|
||||
*/
|
||||
-(void)stop;
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Seeks playback to a specified frame within the internal EZAudioFile. This will notify the EZAudioFileDelegate (if specified) with the audioPlayer:updatedPosition:inAudioFile: function.
|
||||
@param frame The new frame position to seek to as a SInt64.
|
||||
*/
|
||||
-(void)seekToFrame:(SInt64)frame;
|
||||
- (void)seekToFrame:(SInt64)frame;
|
||||
|
||||
@end
|
||||
@end
|
||||
+334
-192
@@ -26,274 +26,416 @@
|
||||
#import "EZAudioPlayer.h"
|
||||
#import "EZAudioUtilities.h"
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
#elif TARGET_OS_MAC
|
||||
#endif
|
||||
@interface EZAudioPlayer () <EZAudioFileDelegate,EZOutputDataSource>
|
||||
{
|
||||
BOOL _eof;
|
||||
}
|
||||
@property (nonatomic,strong,setter=setAudioFile:) EZAudioFile *audioFile;
|
||||
@property (nonatomic,strong,setter=setOutput:) EZOutput *output;
|
||||
@end
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Notifications
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
NSString * const EZAudioPlayerDidChangeAudioFileNotification = @"EZAudioPlayerDidChangeAudioFileNotification";
|
||||
NSString * const EZAudioPlayerDidChangeOutputDeviceNotification = @"EZAudioPlayerDidChangeOutputDeviceNotification";
|
||||
NSString * const EZAudioPlayerDidChangePanNotification = @"EZAudioPlayerDidChangePanNotification";
|
||||
NSString * const EZAudioPlayerDidChangePlayStateNotification = @"EZAudioPlayerDidChangePlayStateNotification";
|
||||
NSString * const EZAudioPlayerDidChangeVolumeNotification = @"EZAudioPlayerDidChangeVolumeNotification";
|
||||
NSString * const EZAudioPlayerDidReachEndOfFileNotification = @"EZAudioPlayerDidReachEndOfFileNotification";
|
||||
NSString * const EZAudioPlayerDidSeekNotification = @"EZAudioPlayerDidSeekNotification";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - EZAudioPlayer (Implementation)
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@implementation EZAudioPlayer
|
||||
@synthesize audioFile = _audioFile;
|
||||
@synthesize audioPlayerDelegate = _audioPlayerDelegate;
|
||||
@synthesize output = _output;
|
||||
@synthesize shouldLoop = _shouldLoop;
|
||||
|
||||
#pragma mark - Initializers
|
||||
-(id)init {
|
||||
self = [super init];
|
||||
if(self){
|
||||
[self _configureAudioPlayer];
|
||||
}
|
||||
return self;
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Class Methods
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
+ (instancetype)audioPlayer
|
||||
{
|
||||
return [[self alloc] init];
|
||||
}
|
||||
|
||||
-(EZAudioPlayer*)initWithEZAudioFile:(EZAudioFile *)audioFile {
|
||||
return [self initWithEZAudioFile:audioFile withDelegate:nil];
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
+ (instancetype)audioPlayerWithDelegate:(id<EZAudioPlayerDelegate>)delegate
|
||||
{
|
||||
return [[self alloc] initWithDelegate:delegate];
|
||||
}
|
||||
|
||||
-(EZAudioPlayer *)initWithEZAudioFile:(EZAudioFile *)audioFile
|
||||
withDelegate:(id<EZAudioPlayerDelegate>)audioPlayerDelegate {
|
||||
self = [super init];
|
||||
if(self){
|
||||
// This should make a separate reference to the audio file
|
||||
[self _configureAudioPlayer];
|
||||
self.audioFile = audioFile;
|
||||
self.audioPlayerDelegate = audioPlayerDelegate;
|
||||
}
|
||||
return self;
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
+ (instancetype)audioPlayerWithAudioFile:(EZAudioFile *)audioFile
|
||||
{
|
||||
return [[self alloc] initWithAudioFile:audioFile];
|
||||
}
|
||||
|
||||
-(EZAudioPlayer *)initWithURL:(NSURL *)url {
|
||||
return [self initWithURL:url withDelegate:nil];
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
+ (instancetype)audioPlayerWithAudioFile:(EZAudioFile *)audioFile
|
||||
delegate:(id<EZAudioPlayerDelegate>)delegate
|
||||
{
|
||||
return [[self alloc] initWithAudioFile:audioFile
|
||||
delegate:delegate];
|
||||
}
|
||||
|
||||
-(EZAudioPlayer *)initWithURL:(NSURL *)url
|
||||
withDelegate:(id<EZAudioPlayerDelegate>)audioPlayerDelegate {
|
||||
self = [super init];
|
||||
if(self){
|
||||
[self _configureAudioPlayer];
|
||||
self.audioFile = [[EZAudioFile alloc] initWithURL:url];
|
||||
self.audioFile.delegate = self;
|
||||
self.audioPlayerDelegate = audioPlayerDelegate;
|
||||
}
|
||||
return self;
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
+ (instancetype)audioPlayerWithURL:(NSURL *)url
|
||||
{
|
||||
return [[self alloc] initWithURL:url];
|
||||
}
|
||||
|
||||
#pragma mark - Class Initializers
|
||||
+(EZAudioPlayer *)audioPlayerWithEZAudioFile:(EZAudioFile *)audioFile {
|
||||
return [[EZAudioPlayer alloc] initWithEZAudioFile:audioFile];
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
+ (instancetype)audioPlayerWithURL:(NSURL *)url
|
||||
delegate:(id<EZAudioPlayerDelegate>)delegate
|
||||
{
|
||||
return [[self alloc] initWithURL:url delegate:delegate];
|
||||
}
|
||||
|
||||
+(EZAudioPlayer *)audioPlayerWithEZAudioFile:(EZAudioFile *)audioFile
|
||||
withDelegate:(id<EZAudioPlayerDelegate>)audioPlayerDelegate {
|
||||
return [[EZAudioPlayer alloc] initWithEZAudioFile:audioFile
|
||||
withDelegate:audioPlayerDelegate];
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Initialization
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
[self setup];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+(EZAudioPlayer *)audioPlayerWithURL:(NSURL *)url {
|
||||
return [[EZAudioPlayer alloc] initWithURL:url];
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (instancetype)initWithDelegate:(id<EZAudioPlayerDelegate>)delegate
|
||||
{
|
||||
self = [self init];
|
||||
if (self)
|
||||
{
|
||||
self.delegate = delegate;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+(EZAudioPlayer *)audioPlayerWithURL:(NSURL *)url
|
||||
withDelegate:(id<EZAudioPlayerDelegate>)audioPlayerDelegate {
|
||||
return [[EZAudioPlayer alloc] initWithURL:url
|
||||
withDelegate:audioPlayerDelegate];
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (instancetype)initWithAudioFile:(EZAudioFile *)audioFile
|
||||
{
|
||||
return [self initWithAudioFile:audioFile delegate:nil];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (instancetype)initWithAudioFile:(EZAudioFile *)audioFile
|
||||
delegate:(id<EZAudioPlayerDelegate>)delegate
|
||||
{
|
||||
self = [self initWithDelegate:delegate];
|
||||
if (self)
|
||||
{
|
||||
self.audioFile = audioFile;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (instancetype)initWithURL:(NSURL *)url
|
||||
{
|
||||
return [self initWithURL:url delegate:nil];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (instancetype)initWithURL:(NSURL *)url
|
||||
delegate:(id<EZAudioPlayerDelegate>)delegate
|
||||
{
|
||||
self = [self initWithDelegate:delegate];
|
||||
if (self)
|
||||
{
|
||||
self.audioFile = [EZAudioFile audioFileWithURL:url delegate:self];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Singleton
|
||||
+(EZAudioPlayer *)sharedAudioPlayer {
|
||||
static EZAudioPlayer *_sharedAudioPlayer = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
_sharedAudioPlayer = [[EZAudioPlayer alloc] init];
|
||||
});
|
||||
return _sharedAudioPlayer;
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
+ (instancetype)sharedAudioPlayer
|
||||
{
|
||||
static EZAudioPlayer *player;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^
|
||||
{
|
||||
player = [[self alloc] init];
|
||||
});
|
||||
return player;
|
||||
}
|
||||
|
||||
#pragma mark - Private Configuration
|
||||
-(void)_configureAudioPlayer {
|
||||
|
||||
// Defaults
|
||||
self.output = [EZOutput sharedOutput];
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
// Configure the AVSession
|
||||
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
|
||||
NSError *err = NULL;
|
||||
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:&err];
|
||||
if (err){
|
||||
NSLog(@"There was an error creating the audio session");
|
||||
}
|
||||
[audioSession overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:NULL];
|
||||
if (err){
|
||||
NSLog(@"There was an error sending the audio to the speakers");
|
||||
}
|
||||
#elif TARGET_OS_MAC
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Setup
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)setup
|
||||
{
|
||||
self.output = [EZOutput output];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Getters
|
||||
-(EZAudioFile*)audioFile {
|
||||
return _audioFile;
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (NSTimeInterval)currentTime
|
||||
{
|
||||
return [self.audioFile currentTime];
|
||||
}
|
||||
|
||||
-(float)currentTime {
|
||||
NSAssert(_audioFile,@"No audio file to perform the seek on, check that EZAudioFile is not nil");
|
||||
return [EZAudioUtilities MAP:self.audioFile.frameIndex
|
||||
leftMin:0
|
||||
leftMax:self.audioFile.totalFrames
|
||||
rightMin:0
|
||||
rightMax:self.audioFile.duration];
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (EZAudioDevice *)device
|
||||
{
|
||||
return [self.output device];
|
||||
}
|
||||
|
||||
-(BOOL)endOfFile {
|
||||
return _eof;
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (NSTimeInterval)duration
|
||||
{
|
||||
return [self.audioFile duration];
|
||||
}
|
||||
|
||||
-(SInt64)frameIndex {
|
||||
NSAssert(_audioFile,@"No audio file to perform the seek on, check that EZAudioFile is not nil");
|
||||
return _audioFile.frameIndex;
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (NSString *)formattedCurrentTime
|
||||
{
|
||||
return [self.audioFile formattedCurrentTime];
|
||||
}
|
||||
|
||||
-(BOOL)isPlaying {
|
||||
return self.output.isPlaying;
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (NSString *)formattedDuration
|
||||
{
|
||||
return [self.audioFile formattedDuration];
|
||||
}
|
||||
|
||||
-(EZOutput*)output {
|
||||
NSAssert(_output,@"No output was found, this should by default be the EZOutput shared instance");
|
||||
return _output;
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (SInt64)frameIndex
|
||||
{
|
||||
return [self.audioFile frameIndex];
|
||||
}
|
||||
|
||||
-(float)totalDuration {
|
||||
NSAssert(_audioFile,@"No audio file to perform the seek on, check that EZAudioFile is not nil");
|
||||
return _audioFile.duration;
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (BOOL)isPlaying
|
||||
{
|
||||
return [self.output isPlaying];
|
||||
}
|
||||
|
||||
-(SInt64)totalFrames {
|
||||
NSAssert(_audioFile,@"No audio file to perform the seek on, check that EZAudioFile is not nil");
|
||||
return _audioFile.totalFrames;
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (float)pan
|
||||
{
|
||||
return [self.output pan];
|
||||
}
|
||||
|
||||
-(NSURL *)url {
|
||||
NSAssert(_audioFile,@"No audio file to perform the seek on, check that EZAudioFile is not nil");
|
||||
return _audioFile.url;
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (SInt64)totalFrames
|
||||
{
|
||||
return [self.audioFile totalFrames];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (float)volume
|
||||
{
|
||||
return [self.output volume];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Setters
|
||||
-(void)setAudioFile:(EZAudioFile *)audioFile {
|
||||
if (_audioFile){
|
||||
_audioFile.delegate = nil;
|
||||
}
|
||||
_eof = NO;
|
||||
_audioFile = [EZAudioFile audioFileWithURL:audioFile.url];
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)setAudioFile:(EZAudioFile *)audioFile
|
||||
{
|
||||
_audioFile = [audioFile copy];
|
||||
_audioFile.delegate = self;
|
||||
NSAssert(_output,@"No output was found, this should by default be the EZOutput shared instance");
|
||||
[_output setAudioStreamBasicDescription:self.audioFile.clientFormat];
|
||||
AudioStreamBasicDescription inputFormat = _audioFile.clientFormat;
|
||||
[self.output setInputFormat:inputFormat];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:EZAudioPlayerDidChangeAudioFileNotification
|
||||
object:self];
|
||||
}
|
||||
|
||||
-(void)setOutput:(EZOutput*)output {
|
||||
_output = output;
|
||||
_output.outputDataSource = self;
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)setCurrentTime:(NSTimeInterval)currentTime
|
||||
{
|
||||
[self.audioFile setCurrentTime:currentTime];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:EZAudioPlayerDidSeekNotification
|
||||
object:self];
|
||||
}
|
||||
|
||||
#pragma mark - Methods
|
||||
-(void)play {
|
||||
NSAssert(_audioFile,@"No audio file to perform the seek on, check that EZAudioFile is not nil");
|
||||
if (_audioFile){
|
||||
[_output startPlayback];
|
||||
if (self.frameIndex != self.totalFrames){
|
||||
_eof = NO;
|
||||
}
|
||||
if (self.audioPlayerDelegate){
|
||||
if ([self.audioPlayerDelegate respondsToSelector:@selector(audioPlayer:didResumePlaybackOnAudioFile:)]){
|
||||
// Notify the delegate we're starting playback
|
||||
[self.audioPlayerDelegate audioPlayer:self didResumePlaybackOnAudioFile:_audioFile];
|
||||
}
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)setDevice:(EZAudioDevice *)device
|
||||
{
|
||||
[self.output setDevice:device];
|
||||
}
|
||||
|
||||
-(void)pause {
|
||||
NSAssert(self.audioFile,@"No audio file to perform the seek on, check that EZAudioFile is not nil");
|
||||
if (_audioFile){
|
||||
[_output stopPlayback];
|
||||
if (self.audioPlayerDelegate){
|
||||
if ([self.audioPlayerDelegate respondsToSelector:@selector(audioPlayer:didPausePlaybackOnAudioFile:)]){
|
||||
// Notify the delegate we're pausing playback
|
||||
[self.audioPlayerDelegate audioPlayer:self didPausePlaybackOnAudioFile:_audioFile];
|
||||
}
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)setOutput:(EZOutput *)output
|
||||
{
|
||||
_output = output;
|
||||
_output.dataSource = self;
|
||||
_output.delegate = self;
|
||||
}
|
||||
|
||||
-(void)seekToFrame:(SInt64)frame {
|
||||
NSAssert(_audioFile,@"No audio file to perform the seek on, check that EZAudioFile is not nil");
|
||||
if (_audioFile){
|
||||
[_audioFile seekToFrame:frame];
|
||||
}
|
||||
if (self.frameIndex != self.totalFrames){
|
||||
_eof = NO;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)setPan:(float)pan
|
||||
{
|
||||
[self.output setPan:pan];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:EZAudioPlayerDidChangePanNotification
|
||||
object:self];
|
||||
}
|
||||
|
||||
-(void)stop {
|
||||
NSAssert(_audioFile,@"No audio file to perform the seek on, check that EZAudioFile is not nil");
|
||||
if (_audioFile){
|
||||
[_output stopPlayback];
|
||||
[_audioFile seekToFrame:0];
|
||||
_eof = NO;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)setVolume:(float)volume
|
||||
{
|
||||
[self.output setVolume:volume];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:EZAudioPlayerDidChangeVolumeNotification
|
||||
object:self];
|
||||
}
|
||||
|
||||
#pragma mark - EZAudioFileDelegate
|
||||
-(void)audioFile:(EZAudioFile *)audioFile
|
||||
readAudio:(float **)buffer
|
||||
withBufferSize:(UInt32)bufferSize
|
||||
withNumberOfChannels:(UInt32)numberOfChannels {
|
||||
if (self.audioPlayerDelegate){
|
||||
if ([self.audioPlayerDelegate respondsToSelector:@selector(audioPlayer:readAudio:withBufferSize:withNumberOfChannels:inAudioFile:)]){
|
||||
[self.audioPlayerDelegate audioPlayer:self
|
||||
readAudio:buffer
|
||||
withBufferSize:bufferSize
|
||||
withNumberOfChannels:numberOfChannels
|
||||
inAudioFile:audioFile];
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Actions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)play
|
||||
{
|
||||
[self.output startPlayback];
|
||||
}
|
||||
|
||||
-(void)audioFile:(EZAudioFile *)audioFile updatedPosition:(SInt64)framePosition {
|
||||
if (self.audioPlayerDelegate){
|
||||
if ([self.audioPlayerDelegate respondsToSelector:@selector(audioPlayer:updatedPosition:inAudioFile:)]){
|
||||
[self.audioPlayerDelegate audioPlayer:self
|
||||
updatedPosition:framePosition
|
||||
inAudioFile:audioFile];
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)playAudioFile:(EZAudioFile *)audioFile
|
||||
{
|
||||
//
|
||||
// stop playing anything that might currently be playing
|
||||
//
|
||||
[self pause];
|
||||
|
||||
//
|
||||
// set new stream
|
||||
//
|
||||
self.audioFile = audioFile;
|
||||
|
||||
//
|
||||
// begin playback
|
||||
//
|
||||
[self play];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)pause
|
||||
{
|
||||
[self.output stopPlayback];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)seekToFrame:(SInt64)frame
|
||||
{
|
||||
[self.audioFile seekToFrame:frame];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:EZAudioPlayerDidSeekNotification
|
||||
object:self];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - EZOutputDataSource
|
||||
-(void) output:(EZOutput *)output
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (OSStatus) output:(EZOutput *)output
|
||||
shouldFillAudioBufferList:(AudioBufferList *)audioBufferList
|
||||
withNumberOfFrames:(UInt32)frames
|
||||
timestamp:(const AudioTimeStamp *)timestamp
|
||||
{
|
||||
if (self.audioFile)
|
||||
{
|
||||
UInt32 bufferSize;
|
||||
BOOL eof;
|
||||
[self.audioFile readFrames:frames
|
||||
audioBufferList:audioBufferList
|
||||
bufferSize:&bufferSize
|
||||
eof:&_eof];
|
||||
if (_eof && self.shouldLoop)
|
||||
eof:&eof];
|
||||
if (eof && self.shouldLoop)
|
||||
{
|
||||
[self seekToFrame:0];
|
||||
}
|
||||
else if (eof)
|
||||
{
|
||||
[self pause];
|
||||
[self seekToFrame:0];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:EZAudioPlayerDidReachEndOfFileNotification
|
||||
object:self];
|
||||
}
|
||||
}
|
||||
return noErr;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - EZAudioFileDelegate
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)audioFile:(EZAudioFile *)audioFile updatedPosition:(SInt64)framePosition
|
||||
{
|
||||
if ([self.delegate respondsToSelector:@selector(audioPlayer:updatedPosition:inAudioFile:)])
|
||||
{
|
||||
[self.delegate audioPlayer:self
|
||||
updatedPosition:framePosition
|
||||
inAudioFile:audioFile];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - EZOutputDelegate
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)output:(EZOutput *)output changedDevice:(EZAudioDevice *)device
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:EZAudioPlayerDidChangeOutputDeviceNotification
|
||||
object:self];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)output:(EZOutput *)output changedPlayingState:(BOOL)isPlaying
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:EZAudioPlayerDidChangePlayStateNotification
|
||||
object:self];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void) output:(EZOutput *)output
|
||||
playedAudio:(float **)buffer
|
||||
withBufferSize:(UInt32)bufferSize
|
||||
withNumberOfChannels:(UInt32)numberOfChannels
|
||||
{
|
||||
if ([self.delegate respondsToSelector:@selector(audioPlayer:playedAudio:withBufferSize:withNumberOfChannels:inAudioFile:)])
|
||||
{
|
||||
[self.delegate audioPlayer:self
|
||||
playedAudio:buffer
|
||||
withBufferSize:bufferSize
|
||||
withNumberOfChannels:numberOfChannels
|
||||
inAudioFile:self.audioFile];
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@end
|
||||
@@ -24,8 +24,6 @@
|
||||
// THE SOFTWARE.
|
||||
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#import "TargetConditionals.h"
|
||||
#import "EZAudioUtilities.h"
|
||||
#import "EZPlot.h"
|
||||
|
||||
@class EZAudio;
|
||||
@@ -115,16 +113,16 @@ FOUNDATION_EXPORT UInt32 const EZAudioPlotDefaultMaxHistoryBufferLength;
|
||||
///-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
The length of the rolling history display. Can grow or shrink the display up to the maximum size specified by the kEZAudioPlotMaxHistoryBufferLength macro. Will return the actual set value, which will be either the given value if smaller than the kEZAudioPlotMaxHistoryBufferLength or kEZAudioPlotMaxHistoryBufferLength if a larger value is attempted to be set.
|
||||
Sets the length of the rolling history buffer (i.e. the number of points in the rolling plot's buffer). Can grow or shrink the display up to the maximum size specified by the `maximumRollingHistoryLength` method. Will return the actual set value, which will be either the given value if smaller than the `maximumRollingHistoryLength` or `maximumRollingHistoryLength` if a larger value is attempted to be set.
|
||||
@param historyLength The new length of the rolling history buffer.
|
||||
@return The new value equal to the historyLength or the kEZAudioPlotMaxHistoryBufferLength.
|
||||
@return The new value equal to the historyLength or the `maximumRollingHistoryLength`.
|
||||
*/
|
||||
-(int)setRollingHistoryLength:(int)historyLength;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides the length of the rolling history buffer
|
||||
Provides the length of the rolling history buffer (i.e. the number of points in the rolling plot's buffer).
|
||||
* @return An int representing the length of the rolling history buffer
|
||||
*/
|
||||
-(int)rollingHistoryLength;
|
||||
@@ -187,8 +185,7 @@ FOUNDATION_EXPORT UInt32 const EZAudioPlotDefaultMaxHistoryBufferLength;
|
||||
@param data A float array of the sample data. Subclasses should copy this data to a separate array to avoid threading issues.
|
||||
@param length The length of the float array as an int.
|
||||
*/
|
||||
-(void)setSampleData:(float *)data
|
||||
length:(int)length;
|
||||
-(void)setSampleData:(float *)data length:(int)length;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -41,9 +41,9 @@ UInt32 const EZAudioPlotDefaultMaxHistoryBufferLength = 8192;
|
||||
|
||||
@interface EZAudioPlot () <EZAudioDisplayLinkDelegate>
|
||||
@property (nonatomic, strong) EZAudioDisplayLink *displayLink;
|
||||
@property (nonatomic, assign) EZPlotHistoryInfo *historyInfo;
|
||||
@property (nonatomic, assign) CGPoint *points;
|
||||
@property (nonatomic, assign) UInt32 pointCount;
|
||||
@property (nonatomic, assign) EZPlotHistoryInfo *historyInfo;
|
||||
@property (nonatomic, assign) CGPoint *points;
|
||||
@property (nonatomic, assign) UInt32 pointCount;
|
||||
@end
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
+125
-87
@@ -23,126 +23,126 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#import "TargetConditionals.h"
|
||||
#import <GLKit/GLKit.h>
|
||||
#import "EZPlot.h"
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
#import <GLKit/GLKit.h>
|
||||
@class EZAudioPlotGLKViewController;
|
||||
#elif TARGET_OS_MAC
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <GLKit/GLKit.h>
|
||||
#import <OpenGL/gl3.h>
|
||||
#import <QuartzCore/CVDisplayLink.h>
|
||||
#if !TARGET_OS_IPHONE
|
||||
#import <OpenGL/OpenGL.h>
|
||||
#endif
|
||||
|
||||
#pragma mark - Enumerations
|
||||
/**
|
||||
Constant drawing types wrapping around the OpenGL equivalents. In the audio drawings the line strip will be the stroked graph while the triangle will provide the filled equivalent.
|
||||
*/
|
||||
typedef NS_ENUM(NSUInteger,EZAudioPlotGLDrawType){
|
||||
/**
|
||||
* Maps to the OpenGL constant for a line strip, which for the audio graph will correspond to a stroked drawing (no fill).
|
||||
*/
|
||||
EZAudioPlotGLDrawTypeLineStrip = GL_LINE_STRIP,
|
||||
/**
|
||||
* Maps to the OpenGL constant for a triangle strip, which for the audio graph will correspond to a filled drawing.
|
||||
*/
|
||||
EZAudioPlotGLDrawTypeTriangleStrip = GL_TRIANGLE_STRIP
|
||||
};
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Data Structures
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#pragma mark - Structures
|
||||
/**
|
||||
A structure describing a 2D point (x,y) in space for an audio plot.
|
||||
*/
|
||||
typedef struct {
|
||||
GLfloat x;
|
||||
GLfloat y;
|
||||
typedef struct
|
||||
{
|
||||
GLfloat x;
|
||||
GLfloat y;
|
||||
} EZAudioPlotGLPoint;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - EZAudioPlotGL
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
EZAudioPlotGL is a subclass of either the EZPlot on iOS or an NSOpenGLView on OSX. I apologize ahead of time for the weirdness in the docs for this class, but I had to do a bit of hackery to get a universal namespace for something works on both iOS and OSX without any additional components. The EZAudioPlotGL provides an the same utilities and interface as the EZAudioPlot with the added benefit of being GPU-accelerated. This is the recommended plot to use on iOS devices to get super fast real-time drawings of audio streams. For the methods and properties below I've included notes on the bottom just indicating which OS they correspond to. In most (if not all) use cases you can just refer to the EZPlot documentation to see which custom properties can be setup. There update function is the same as the EZPlot as well: `updateBuffer:withBufferSize:`
|
||||
EZAudioPlotGL is a subclass of either a GLKView on iOS or an NSOpenGLView on OSX. As of 0.6.0 this class no longer depends on an embedded GLKViewController for iOS as the display link is just manually managed within this single view instead. The EZAudioPlotGL provides the same kind of audio plot as the EZAudioPlot, but uses OpenGL to GPU-accelerate the drawing of the points, which means you can fit a lot more points and complex geometries.
|
||||
*/
|
||||
#if TARGET_OS_IPHONE
|
||||
@interface EZAudioPlotGL : EZPlot
|
||||
@interface EZAudioPlotGL : GLKView
|
||||
#elif TARGET_OS_MAC
|
||||
@interface EZAudioPlotGL : NSOpenGLView
|
||||
#endif
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
|
||||
// Inherited from EZPlot
|
||||
|
||||
#elif TARGET_OS_MAC
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Properties
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
///-----------------------------------------------------------
|
||||
/// @name Customizing The Plot's Appearance
|
||||
///-----------------------------------------------------------
|
||||
/**
|
||||
The default background color of the plot. For iOS the color is specified as a UIColor while for OSX the color is an NSColor. The default value on both platforms is black.
|
||||
*/
|
||||
@property (nonatomic,strong) id backgroundColor;
|
||||
|
||||
/**
|
||||
The default color of the plot's data (i.e. waveform, y-axis values). For iOS the color is specified as a UIColor while for OSX the color is an NSColor. The default value on both platforms is red.
|
||||
The default background color of the plot. For iOS the color is specified as a UIColor while for OSX the color is an NSColor. The default value on both platforms is a sweet looking green.
|
||||
@warning On OSX, if you set the background to a value where the alpha component is 0 then the EZAudioPlotGL will automatically set its superview to be layer-backed.
|
||||
*/
|
||||
@property (nonatomic,strong) id color;
|
||||
@property (nonatomic, strong) id backgroundColor;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
The default color of the plot's data (i.e. waveform, y-axis values). For iOS the color is specified as a UIColor while for OSX the color is an NSColor. The default value on both platforms is white.
|
||||
*/
|
||||
@property (nonatomic, strong) id color;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
The plot's gain value, which controls the scale of the y-axis values. The default value of the gain is 1.0f and should always be greater than 0.0f.
|
||||
*/
|
||||
@property (nonatomic,assign,setter=setGain:) float gain;
|
||||
@property (nonatomic, assign) float gain;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
The type of plot as specified by the `EZPlotType` enumeration (i.e. a buffer or rolling plot type).
|
||||
The type of plot as specified by the `EZPlotType` enumeration (i.e. a buffer or rolling plot type). Default is EZPlotTypeBuffer.
|
||||
*/
|
||||
@property (nonatomic,assign,setter=setPlotType:) EZPlotType plotType;
|
||||
@property (nonatomic, assign) EZPlotType plotType;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
A BOOL indicating whether or not to fill in the graph. A value of YES will make a filled graph (filling in the space between the x-axis and the y-value), while a value of NO will create a stroked graph (connecting the points along the y-axis).
|
||||
A BOOL indicating whether or not to fill in the graph. A value of YES will make a filled graph (filling in the space between the x-axis and the y-value), while a value of NO will create a stroked graph (connecting the points along the y-axis). Default is NO.
|
||||
*/
|
||||
@property (nonatomic,assign,setter=setShouldFill:) BOOL shouldFill;
|
||||
@property (nonatomic, assign) BOOL shouldFill;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
A boolean indicating whether the graph should be rotated along the x-axis to give a mirrored reflection. This is typical for audio plots to produce the classic waveform look. A value of YES will produce a mirrored reflection of the y-values about the x-axis, while a value of NO will only plot the y-values.
|
||||
A boolean indicating whether the graph should be rotated along the x-axis to give a mirrored reflection. This is typical for audio plots to produce the classic waveform look. A value of YES will produce a mirrored reflection of the y-values about the x-axis, while a value of NO will only plot the y-values. Default is NO.
|
||||
*/
|
||||
@property (nonatomic,assign,setter=setShouldMirror:) BOOL shouldMirror;
|
||||
@property (nonatomic, assign) BOOL shouldMirror;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Updating The Plot
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#pragma mark - Get Samples
|
||||
///-----------------------------------------------------------
|
||||
/// @name Updating The Plot
|
||||
///-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
Updates the plot with the new buffer data and tells the view to redraw itself. Caller will provide a float array with the values they expect to see on the y-axis. The plot will internally handle mapping the x-axis and y-axis to the current view port, any interpolation for fills effects, and mirroring.
|
||||
@param buffer A float array of values to map to the y-axis.
|
||||
@param bufferSize The size of the float array that will be mapped to the y-axis.
|
||||
@warning The bufferSize is expected to be the same, constant value once initial triggered. For plots using OpenGL a vertex buffer object will be allocated with a maximum buffersize of (2 * the initial given buffer size) to account for any interpolation necessary for filling in the graph. Updates use the glBufferSubData(...) function, which will crash if the buffersize exceeds the initial maximum allocated size.
|
||||
*/
|
||||
-(void)updateBuffer:(float *)buffer
|
||||
withBufferSize:(UInt32)bufferSize;
|
||||
|
||||
#endif
|
||||
-(void)updateBuffer:(float *)buffer withBufferSize:(UInt32)bufferSize;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Adjust Resolution
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
///-----------------------------------------------------------
|
||||
/// @name Adjusting The Resolution
|
||||
///-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
Sets the length of the rolling history display. Can grow or shrink the display up to the maximum size specified by the kEZAudioPlotMaxHistoryBufferLength macro. Will return the actual set value, which will be either the given value if smaller than the kEZAudioPlotMaxHistoryBufferLength or kEZAudioPlotMaxHistoryBufferLength if a larger value is attempted to be set.
|
||||
Sets the length of the rolling history buffer (i.e. the number of points in the rolling plot's buffer). Can grow or shrink the display up to the maximum size specified by the `maximumRollingHistoryLength` method. Will return the actual set value, which will be either the given value if smaller than the `maximumRollingHistoryLength` or `maximumRollingHistoryLength` if a larger value is attempted to be set.
|
||||
@param historyLength The new length of the rolling history buffer.
|
||||
@return The new value equal to the historyLength or the kEZAudioPlotMaxHistoryBufferLength.
|
||||
@return The new value equal to the historyLength or the `maximumRollingHistoryLength`.
|
||||
*/
|
||||
-(int)setRollingHistoryLength:(int)historyLength;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides the length of the rolling history buffer
|
||||
Provides the length of the rolling history buffer (i.e. the number of points in the rolling plot's buffer).
|
||||
* @return An int representing the length of the rolling history buffer
|
||||
*/
|
||||
-(int)rollingHistoryLength;
|
||||
|
||||
#pragma mark - Shared Methods
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Clearing The Plot
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
///-----------------------------------------------------------
|
||||
/// @name Clearing The Plot
|
||||
///-----------------------------------------------------------
|
||||
@@ -152,32 +152,70 @@ typedef struct {
|
||||
*/
|
||||
-(void)clear;
|
||||
|
||||
///-----------------------------------------------------------
|
||||
/// @name Shared OpenGL Methods
|
||||
///-----------------------------------------------------------
|
||||
/**
|
||||
Converts a float array to an array of EZAudioPlotGLPoint structures that hold the (x,y) values the OpenGL buffer needs to properly plot its points.
|
||||
@param graph A pointer to the array that should hold the EZAudioPlotGLPoint structures.
|
||||
@param graphSize The size (or length) of the array with the EZAudioPlotGLPoint structures.
|
||||
@param drawingType The EZAudioPlotGLDrawType constant defining whether the plot should interpolate between points for a triangle strip (filled waveform) or not for a line strip (stroked waveform)
|
||||
@param buffer The float array holding the audio data
|
||||
@param bufferSize The size of the float array holding the audio data
|
||||
@param gain The gain (always greater than 0.0) to apply to the amplitudes (y-values) of the graph. Y-values can only range from -1.0 to 1.0 so any value that's greater will be rounded to -1.0 or 1.0.
|
||||
*/
|
||||
+(void)fillGraph:(EZAudioPlotGLPoint*)graph
|
||||
withGraphSize:(UInt32)graphSize
|
||||
forDrawingType:(EZAudioPlotGLDrawType)drawingType
|
||||
withBuffer:(float*)buffer
|
||||
withBufferSize:(UInt32)bufferSize
|
||||
withGain:(float)gain;
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Start/Stop Display Link
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Determines the proper size of a graph given a EZAudioPlotGLDrawType (line strip or triangle strip) and the size of the incoming buffer. Triangle strips require interpolating between points so the buffer becomes 2*bufferSize
|
||||
@param drawingType The EZAudioPlotGLDraw type (line strip or triangle strip)
|
||||
@param bufferSize The size of the float array holding the audio data coming in.
|
||||
@return A Int32 representing the proper graph size that should be used to account for any necessary interpolating between points.
|
||||
Call this method to tell the EZAudioDisplayLink to stop drawing temporarily.
|
||||
*/
|
||||
+(UInt32)graphSizeForDrawingType:(EZAudioPlotGLDrawType)drawingType
|
||||
withBufferSize:(UInt32)bufferSize;
|
||||
- (void)pauseDrawing;
|
||||
|
||||
@end
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Call this method to manually tell the EZAudioDisplayLink to start drawing again.
|
||||
*/
|
||||
- (void)resumeDrawing;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Subclass
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
///-----------------------------------------------------------
|
||||
/// @name Customizing The Drawing
|
||||
///-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
This method is used to perform the actual OpenGL drawing code to clear the background and draw the lines representing the 2D audio plot. Subclasses can use the current implementation as an example and implement their own custom geometries. This is the analogy of overriding the drawRect: method in an NSView or UIView.
|
||||
@param points An array of EZAudioPlotGLPoint structures representing the mapped audio data to x,y coordinates. The x-axis goes from 0 to the number of points (pointCount) while the y-axis goes from -1 to 1. Check out the implementation of this method to see how the model view matrix of the base effect is transformed to map this properly to the viewport.
|
||||
@param pointCount A UInt32 representing the number of points contained in the points array.
|
||||
@param baseEffect An optional GLKBaseEffect to use as a default shader. Call prepareToDraw on the base effect before any glDrawArrays call.
|
||||
@param vbo The Vertex Buffer Object used to buffer the point data.
|
||||
@param vab The Vertex Array Buffer used to bind the Vertex Buffer Object. This is a Mac only thing, you can ignore this completely on iOS.
|
||||
@param interpolated A BOOL indicating whether the data has been interpolated. This means the point data is twice as long, where every other point is 0 on the y-axis to allow drawing triangle stripes for filled in waveforms. Typically if the point data is interpolated you will be using the GL_TRIANGLE_STRIP drawing mode, while non-interpolated plots will just use a GL_LINE_STRIP drawing mode.
|
||||
@param mirrored A BOOL indicating whether the plot should be mirrored about the y-axis (or whatever geometry you come up with).
|
||||
@param gain A float representing a gain that should be used to influence the height or intensity of your geometry's shape. A gain of 0.0 means silence, a gain of 1.0 means full volume (you're welcome to boost this to whatever you want).
|
||||
*/
|
||||
- (void)redrawWithPoints:(EZAudioPlotGLPoint *)points
|
||||
pointCount:(UInt32)pointCount
|
||||
baseEffect:(GLKBaseEffect *)baseEffect
|
||||
vertexBufferObject:(GLuint)vbo
|
||||
vertexArrayBuffer:(GLuint)vab
|
||||
interpolated:(BOOL)interpolated
|
||||
mirrored:(BOOL)mirrored
|
||||
gain:(float)gain;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
///-----------------------------------------------------------
|
||||
/// @name Subclass Methods
|
||||
///-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides the default length of the rolling history buffer when the plot is initialized. Default is `EZAudioPlotDefaultHistoryBufferLength` constant.
|
||||
@return An int describing the initial length of the rolling history buffer.
|
||||
*/
|
||||
- (int)defaultRollingHistoryLength;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides the default maximum rolling history length - that is, the maximum amount of points the `setRollingHistoryLength:` method may be set to. If a length higher than this is set then the plot will likely crash because the appropriate resources are only allocated once during the plot's initialization step. Defualt is `EZAudioPlotDefaultMaxHistoryBufferLength` constant.
|
||||
@return An int describing the maximum length of the absolute rolling history buffer.
|
||||
*/
|
||||
- (int)maximumRollingHistoryLength;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@end
|
||||
+480
-718
File diff suppressed because it is too large
Load Diff
@@ -1,127 +0,0 @@
|
||||
//
|
||||
// EZAudioPlotGLKViewController.h
|
||||
// EZAudio
|
||||
//
|
||||
// Created by Syed Haris Ali on 11/22/13.
|
||||
// Copyright (c) 2015 Syed Haris Ali. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#import "TargetConditionals.h"
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
|
||||
#import "EZAudioPlotGL.h"
|
||||
|
||||
@class EZAudio;
|
||||
|
||||
/**
|
||||
EZAudioPlotGLKViewController is a subclass of the GLKViewController and handles the OpenGL drawing routine for iOS OpenGL ES views. This class has not been used outside the scope of the EZAudioPlotGL, but should be safe to use by itself if the intended use case is to have a view controller take up the whole screen.
|
||||
*/
|
||||
@interface EZAudioPlotGLKViewController : GLKViewController
|
||||
|
||||
#pragma mark - Properties
|
||||
///-----------------------------------------------------------
|
||||
/// @name Customizing The Plot's Appearance
|
||||
///-----------------------------------------------------------
|
||||
/**
|
||||
The default background color of the plot. For iOS the color is specified as a UIColor while for OSX the color is an NSColor. The default value on both platforms is black.
|
||||
*/
|
||||
@property (nonatomic,strong) UIColor *backgroundColor;
|
||||
|
||||
/**
|
||||
The default shader to use to fill the graph.
|
||||
*/
|
||||
@property (nonatomic,strong) GLKBaseEffect *baseEffect;
|
||||
|
||||
/**
|
||||
The default color of the plot's data (i.e. waveform, y-axis values). For iOS the color is specified as a UIColor while for OSX the color is an NSColor. The default value on both platforms is red.
|
||||
*/
|
||||
@property (nonatomic,strong) UIColor *color;
|
||||
|
||||
/**
|
||||
The OpenGL ES context (EAGLContext) in which to perform the drawing
|
||||
*/
|
||||
@property (nonatomic,strong) EAGLContext *context;
|
||||
|
||||
/**
|
||||
The EZAudioPlotGLDrawType specifying which OpenGL primitive to use for drawing (either line strip for stroke and no fill or triangle strip for fill)
|
||||
*/
|
||||
@property (nonatomic,assign) EZAudioPlotGLDrawType drawingType;
|
||||
|
||||
/**
|
||||
The plot's gain value, which controls the scale of the y-axis values. The default value of the gain is 1.0f and should always be greater than 0.0f.
|
||||
*/
|
||||
@property (nonatomic,assign,setter=setGain:) float gain;
|
||||
|
||||
/**
|
||||
The type of plot as specified by the `EZPlotType` enumeration (i.e. a buffer or rolling plot type).
|
||||
*/
|
||||
@property (nonatomic,assign,setter=setPlotType:) EZPlotType plotType;
|
||||
|
||||
/**
|
||||
A boolean indicating whether the graph should be rotated along the x-axis to give a mirrored reflection. This is typical for audio plots to produce the classic waveform look. A value of YES will produce a mirrored reflection of the y-values about the x-axis, while a value of NO will only plot the y-values.
|
||||
*/
|
||||
@property (nonatomic,assign,setter=setShouldMirror:) BOOL shouldMirror;
|
||||
|
||||
#pragma mark - Adjust Resolution
|
||||
///-----------------------------------------------------------
|
||||
/// @name Adjusting The Resolution
|
||||
///-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
Sets the length of the rolling history display. Can grow or shrink the display up to the maximum size specified by the kEZAudioPlotMaxHistoryBufferLength macro. Will return the actual set value, which will be either the given value if smaller than the kEZAudioPlotMaxHistoryBufferLength or kEZAudioPlotMaxHistoryBufferLength if a larger value is attempted to be set.
|
||||
@param historyLength The new length of the rolling history buffer.
|
||||
@return The new value equal to the historyLength or the kEZAudioPlotMaxHistoryBufferLength.
|
||||
*/
|
||||
-(int)setRollingHistoryLength:(int)historyLength;
|
||||
|
||||
/**
|
||||
Provides the length of the rolling history buffer
|
||||
* @return An int representing the length of the rolling history buffer
|
||||
*/
|
||||
-(int)rollingHistoryLength;
|
||||
|
||||
#pragma mark - Clearing
|
||||
///-----------------------------------------------------------
|
||||
/// @name Clearing The Plot
|
||||
///-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
Clears all data from the audio plot (includes both EZPlotTypeBuffer and EZPlotTypeRolling)
|
||||
*/
|
||||
-(void)clear;
|
||||
|
||||
#pragma mark - Get Samples
|
||||
///-----------------------------------------------------------
|
||||
/// @name Updating The Plot
|
||||
///-----------------------------------------------------------
|
||||
/**
|
||||
Updates the plot with the new buffer data and tells the view to redraw itself. Caller will provide a float array with the values they expect to see on the y-axis. The plot will internally handle mapping the x-axis and y-axis to the current view port, any interpolation for fills effects, and mirroring.
|
||||
@param buffer A float array of values to map to the y-axis.
|
||||
@param bufferSize The size of the float array that will be mapped to the y-axis.
|
||||
@warning The bufferSize is expected to be the same, constant value once initial triggered. For plots using OpenGL a vertex buffer object will be allocated with a maximum buffersize of (2 * the initial given buffer size) to account for any interpolation necessary for filling in the graph. Updates use the glBufferSubData(...) function, which will crash if the buffersize exceeds the initial maximum allocated size.
|
||||
*/
|
||||
-(void)updateBuffer:(float *)buffer
|
||||
withBufferSize:(UInt32)bufferSize;
|
||||
|
||||
@end
|
||||
|
||||
#elif TARGET_OS_MAC
|
||||
#endif
|
||||
@@ -1,486 +0,0 @@
|
||||
//
|
||||
// EZAudioPlotGLKViewController.m
|
||||
// EZAudio
|
||||
//
|
||||
// Created by Syed Haris Ali on 11/22/13.
|
||||
// Copyright (c) 2015 Syed Haris Ali. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
|
||||
#import "EZAudioPlotGLKViewController.h"
|
||||
#import "EZAudioUtilities.h"
|
||||
#import "EZAudioPlot.h"
|
||||
|
||||
@interface EZAudioPlotGLKViewController () {
|
||||
|
||||
// Flags indicating whether the plots have been instantiated
|
||||
BOOL _hasBufferPlotData;
|
||||
BOOL _hasRollingPlotData;
|
||||
|
||||
// The buffers
|
||||
GLuint _bufferPlotVBO;
|
||||
GLuint _rollingPlotVBO;
|
||||
|
||||
// Buffers size
|
||||
UInt32 _bufferPlotGraphSize;
|
||||
UInt32 _rollingPlotGraphSize;
|
||||
|
||||
// Rolling History
|
||||
BOOL _setMaxLength;
|
||||
float *_scrollHistory;
|
||||
int _scrollHistoryIndex;
|
||||
UInt32 _scrollHistoryLength;
|
||||
BOOL _changingHistorySize;
|
||||
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation EZAudioPlotGLKViewController
|
||||
@synthesize baseEffect = _baseEffect;
|
||||
@synthesize context = _context;
|
||||
@synthesize drawingType = _drawingType;
|
||||
@synthesize plotType = _plotType;
|
||||
@synthesize shouldMirror = _shouldMirror;
|
||||
|
||||
#pragma mark - Initialization
|
||||
-(id)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
[self initializeView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id)initWithCoder:(NSCoder *)aDecoder {
|
||||
self = [super initWithCoder:aDecoder];
|
||||
if(self){
|
||||
[self initializeView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
||||
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
||||
if(self){
|
||||
[self initializeView];
|
||||
}
|
||||
return self;
|
||||
|
||||
}
|
||||
#pragma mark - Initialize Properties Here
|
||||
-(void)initializeView {
|
||||
// Setup the base effect
|
||||
self.baseEffect = [[GLKBaseEffect alloc] init];
|
||||
self.baseEffect.useConstantColor = GL_TRUE;
|
||||
self.preferredFramesPerSecond = 60;
|
||||
_scrollHistory = NULL;
|
||||
_scrollHistoryLength = EZAudioPlotDefaultHistoryBufferLength;
|
||||
}
|
||||
|
||||
#pragma mark - View Did Load
|
||||
-(void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
// Setup the context
|
||||
if (![EAGLContext currentContext])
|
||||
{
|
||||
self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
||||
}
|
||||
else
|
||||
{
|
||||
self.context = [EAGLContext currentContext];
|
||||
}
|
||||
|
||||
if (!self.context) {
|
||||
NSLog(@"Failed to create ES context");
|
||||
}
|
||||
else {
|
||||
EAGLContext.currentContext = self.context;
|
||||
}
|
||||
|
||||
// Set the view's context
|
||||
GLKView *view = (GLKView *)self.view;
|
||||
view.context = self.context;
|
||||
view.drawableMultisample = GLKViewDrawableMultisample4X;
|
||||
view.opaque = NO;
|
||||
|
||||
// Generate both the buffer id references
|
||||
glGenBuffers(1, &_bufferPlotVBO);
|
||||
glGenBuffers(1, &_rollingPlotVBO);
|
||||
|
||||
// Refresh color values
|
||||
[self _refreshWithBackgroundColor: self.backgroundColor];
|
||||
[self _refreshWithColor: self.color];
|
||||
|
||||
// Set the line width for the context
|
||||
glLineWidth(2.0);
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - Adjust Resolution
|
||||
-(int)setRollingHistoryLength:(int)historyLength {
|
||||
_changingHistorySize = YES;
|
||||
historyLength = MIN(historyLength, EZAudioPlotDefaultMaxHistoryBufferLength);
|
||||
size_t floatByteSize = sizeof(float);
|
||||
if (_scrollHistoryLength != historyLength){
|
||||
_scrollHistoryLength = historyLength;
|
||||
}
|
||||
_scrollHistory = realloc(_scrollHistory,_scrollHistoryLength*floatByteSize);
|
||||
if (_scrollHistoryIndex < _scrollHistoryLength){
|
||||
memset(&_scrollHistory[_scrollHistoryIndex],
|
||||
0,
|
||||
(_scrollHistoryLength-_scrollHistoryIndex)*floatByteSize);
|
||||
}
|
||||
else {
|
||||
_scrollHistoryIndex = _scrollHistoryLength;
|
||||
}
|
||||
[self _updateRollingPlotDisplay];
|
||||
_changingHistorySize = NO;
|
||||
return historyLength;
|
||||
}
|
||||
|
||||
-(int)rollingHistoryLength {
|
||||
return _scrollHistoryLength;
|
||||
}
|
||||
|
||||
#pragma mark - Clearing
|
||||
-(void)clear
|
||||
{
|
||||
_scrollHistoryIndex = 0;
|
||||
[self _clearBufferPlot];
|
||||
[self _clearRollingPlot];
|
||||
}
|
||||
|
||||
-(void)_clearBufferPlot
|
||||
{
|
||||
if (_hasBufferPlotData)
|
||||
{
|
||||
float empty[_bufferPlotGraphSize];
|
||||
memset( empty, 0.0f, sizeof(float));
|
||||
[self _updateBufferPlotBufferWithAudioReceived:empty
|
||||
withBufferSize:_bufferPlotGraphSize];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)_clearRollingPlot
|
||||
{
|
||||
if (_hasRollingPlotData)
|
||||
{
|
||||
float empty[_rollingPlotGraphSize];
|
||||
EZAudioPlotGLPoint graph[_rollingPlotGraphSize];
|
||||
// Figure out better way to do this
|
||||
for(int i = 0; i < _rollingPlotGraphSize; i++)
|
||||
{
|
||||
empty[i] = 0.0f;
|
||||
}
|
||||
for(int i = 0; i < _scrollHistoryLength; i++)
|
||||
{
|
||||
_scrollHistory[i] = 0.0f;
|
||||
}
|
||||
// Update the scroll history datasource
|
||||
[EZAudioUtilities updateScrollHistory:&_scrollHistory
|
||||
withLength:_scrollHistoryLength
|
||||
atIndex:&_scrollHistoryIndex
|
||||
withBuffer:empty
|
||||
withBufferSize:_rollingPlotGraphSize
|
||||
isResolutionChanging:&_changingHistorySize];
|
||||
// Fill in graph data
|
||||
[EZAudioPlotGL fillGraph:graph
|
||||
withGraphSize:_rollingPlotGraphSize
|
||||
forDrawingType:_drawingType
|
||||
withBuffer:_scrollHistory
|
||||
withBufferSize:_scrollHistoryLength
|
||||
withGain:self.gain];
|
||||
// Update the drawing
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(graph), graph);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Get Samples
|
||||
-(void)updateBuffer:(float *)buffer
|
||||
withBufferSize:(UInt32)bufferSize {
|
||||
|
||||
// Make sure the update render loop is active
|
||||
if (self.paused) self.paused = NO;
|
||||
|
||||
// Make sure we are updating the buffers on the correct gl context.
|
||||
EAGLContext.currentContext = self.context;
|
||||
|
||||
// Draw based on plot type
|
||||
switch(_plotType) {
|
||||
case EZPlotTypeBuffer:
|
||||
[self _updateBufferPlotBufferWithAudioReceived:buffer
|
||||
withBufferSize:bufferSize];
|
||||
break;
|
||||
case EZPlotTypeRolling:
|
||||
[self _updateRollingPlotBufferWithAudioReceived:buffer
|
||||
withBufferSize:bufferSize];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - Buffer Updating By Type
|
||||
-(void)_updateBufferPlotBufferWithAudioReceived:(float*)buffer
|
||||
withBufferSize:(UInt32)bufferSize {
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _bufferPlotVBO);
|
||||
|
||||
// If starting with a VBO of half of our max size make sure we initialize it to anticipate
|
||||
// a filled graph (which needs 2 * bufferSize) to allocate its resources properly
|
||||
if (!_hasBufferPlotData && _drawingType == EZAudioPlotGLDrawTypeLineStrip){
|
||||
EZAudioPlotGLPoint maxGraph[2*bufferSize];
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(maxGraph), maxGraph, GL_STREAM_DRAW);
|
||||
_hasBufferPlotData = YES;
|
||||
}
|
||||
|
||||
// Setup the buffer plot's graph size
|
||||
_bufferPlotGraphSize = [EZAudioPlotGL graphSizeForDrawingType:_drawingType
|
||||
withBufferSize:bufferSize];
|
||||
|
||||
// Setup the graph
|
||||
EZAudioPlotGLPoint graph[_bufferPlotGraphSize];
|
||||
|
||||
// Fill in graph data
|
||||
[EZAudioPlotGL fillGraph:graph
|
||||
withGraphSize:_bufferPlotGraphSize
|
||||
forDrawingType:_drawingType
|
||||
withBuffer:buffer
|
||||
withBufferSize:bufferSize
|
||||
withGain:self.gain];
|
||||
|
||||
if (!_hasBufferPlotData){
|
||||
glBufferData( GL_ARRAY_BUFFER, sizeof(graph), graph, GL_STREAM_DRAW);
|
||||
_hasBufferPlotData = YES;
|
||||
}
|
||||
else {
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(graph), graph);
|
||||
}
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
}
|
||||
|
||||
-(void)_updateRollingPlotBufferWithAudioReceived:(float*)buffer
|
||||
withBufferSize:(UInt32)bufferSize {
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _rollingPlotVBO);
|
||||
|
||||
|
||||
|
||||
// If starting with a VBO of half of our max size make sure we initialize it to anticipate
|
||||
// a filled graph (which needs 2 * bufferSize) to allocate its resources properly
|
||||
if (!_hasRollingPlotData){
|
||||
EZAudioPlotGLPoint maxGraph[2*EZAudioPlotDefaultMaxHistoryBufferLength];
|
||||
glBufferData( GL_ARRAY_BUFFER, sizeof(maxGraph), maxGraph, GL_STREAM_DRAW);
|
||||
_hasRollingPlotData = YES;
|
||||
}
|
||||
|
||||
// Setup the plot
|
||||
_rollingPlotGraphSize = [EZAudioPlotGL graphSizeForDrawingType:_drawingType
|
||||
withBufferSize:_scrollHistoryLength];
|
||||
|
||||
// Fill the graph with data
|
||||
EZAudioPlotGLPoint graph[_rollingPlotGraphSize];
|
||||
|
||||
// Update the scroll history datasource
|
||||
[EZAudioUtilities updateScrollHistory:&_scrollHistory
|
||||
withLength:_scrollHistoryLength
|
||||
atIndex:&_scrollHistoryIndex
|
||||
withBuffer:buffer
|
||||
withBufferSize:bufferSize
|
||||
isResolutionChanging:&_changingHistorySize];
|
||||
|
||||
// Fill in graph data
|
||||
[EZAudioPlotGL fillGraph:graph
|
||||
withGraphSize:_rollingPlotGraphSize
|
||||
forDrawingType:_drawingType
|
||||
withBuffer:_scrollHistory
|
||||
withBufferSize:_scrollHistoryLength
|
||||
withGain:self.gain];
|
||||
|
||||
// Update the drawing
|
||||
if (!_hasRollingPlotData){
|
||||
glBufferData( GL_ARRAY_BUFFER, sizeof(graph) , graph, GL_STREAM_DRAW);
|
||||
_hasRollingPlotData = YES;
|
||||
}
|
||||
else {
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(graph), graph);
|
||||
}
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
}
|
||||
|
||||
-(void)_updateRollingPlotDisplay {
|
||||
// Setup the plot
|
||||
_rollingPlotGraphSize = [EZAudioPlotGL graphSizeForDrawingType:_drawingType
|
||||
withBufferSize:_scrollHistoryLength];
|
||||
|
||||
// Fill the graph with data
|
||||
EZAudioPlotGLPoint graph[_rollingPlotGraphSize];
|
||||
|
||||
// Fill in graph data
|
||||
[EZAudioPlotGL fillGraph:graph
|
||||
withGraphSize:_rollingPlotGraphSize
|
||||
forDrawingType:_drawingType
|
||||
withBuffer:_scrollHistory
|
||||
withBufferSize:_scrollHistoryLength
|
||||
withGain:self.gain];
|
||||
|
||||
// Update the drawing
|
||||
if (_hasRollingPlotData){
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(graph), graph);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Drawing
|
||||
-(void)glkView:(GLKView *)view drawInRect:(CGRect)rect {
|
||||
|
||||
EAGLContext.currentContext = self.context;
|
||||
|
||||
// Clear the context
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
if (_hasBufferPlotData || _hasRollingPlotData){
|
||||
// Prepare the effect for drawing
|
||||
[self.baseEffect prepareToDraw];
|
||||
|
||||
// Plot either a buffer plot or a rolling plot
|
||||
switch(_plotType) {
|
||||
case EZPlotTypeBuffer:
|
||||
[self _drawBufferPlotWithView:view
|
||||
drawInRect:rect];
|
||||
break;
|
||||
case EZPlotTypeRolling:
|
||||
[self _drawRollingPlotWithView:view
|
||||
drawInRect:rect];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Private Drawing
|
||||
-(void)_drawBufferPlotWithView:(GLKView*)view drawInRect:(CGRect)rect {
|
||||
if (_hasBufferPlotData){
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _bufferPlotVBO);
|
||||
glEnableVertexAttribArray(GLKVertexAttribPosition);
|
||||
glVertexAttribPointer(GLKVertexAttribPosition, 2, GL_FLOAT, GL_FALSE, sizeof(EZAudioPlotGLPoint), NULL);
|
||||
|
||||
// Normal plot
|
||||
|
||||
self.baseEffect.transform.modelviewMatrix = GLKMatrix4MakeXRotation(0);
|
||||
glDrawArrays(_drawingType, 0, _bufferPlotGraphSize);
|
||||
|
||||
|
||||
if (self.shouldMirror){
|
||||
// Mirrored plot
|
||||
[self.baseEffect prepareToDraw];
|
||||
|
||||
self.baseEffect.transform.modelviewMatrix = GLKMatrix4MakeXRotation(M_PI);
|
||||
glDrawArrays(_drawingType, 0, _bufferPlotGraphSize);
|
||||
|
||||
}
|
||||
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER,0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
-(void)_drawRollingPlotWithView:(GLKView*)view drawInRect:(CGRect)rect {
|
||||
if (_hasRollingPlotData){
|
||||
|
||||
// Normal plot
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _rollingPlotVBO);
|
||||
glEnableVertexAttribArray(GLKVertexAttribPosition);
|
||||
glVertexAttribPointer(GLKVertexAttribPosition, 2, GL_FLOAT, GL_FALSE, sizeof(EZAudioPlotGLPoint), NULL);
|
||||
|
||||
// Normal plot
|
||||
|
||||
self.baseEffect.transform.modelviewMatrix = GLKMatrix4MakeXRotation(0);
|
||||
glDrawArrays(_drawingType, 0, _rollingPlotGraphSize);
|
||||
|
||||
|
||||
if (self.shouldMirror){
|
||||
// Mirrored plot
|
||||
[self.baseEffect prepareToDraw];
|
||||
|
||||
self.baseEffect.transform.modelviewMatrix = GLKMatrix4MakeXRotation(3.14159265359);
|
||||
glDrawArrays(_drawingType, 0, _rollingPlotGraphSize);
|
||||
|
||||
}
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER,0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Setters
|
||||
-(void)setBackgroundColor:(UIColor *)backgroundColor {
|
||||
// Set the background color
|
||||
_backgroundColor = backgroundColor;
|
||||
// Refresh background color (map to GL vector)
|
||||
[self _refreshWithBackgroundColor:backgroundColor];
|
||||
}
|
||||
|
||||
-(void)setColor:(UIColor *)color {
|
||||
// Set the color
|
||||
_color = color;
|
||||
// Refresh the color (map to GL vector)
|
||||
[self _refreshWithColor:color];
|
||||
}
|
||||
|
||||
#pragma mark - Private Setters
|
||||
-(void)_refreshWithBackgroundColor:(UIColor*)backgroundColor {
|
||||
// Extract colors
|
||||
CGFloat red; CGFloat green; CGFloat blue; CGFloat alpha;
|
||||
[backgroundColor getRed:&red
|
||||
green:&green
|
||||
blue:&blue
|
||||
alpha:&alpha];
|
||||
// Set them on the context
|
||||
glClearColor((GLclampf)red,(GLclampf)green,(GLclampf)blue,(GLclampf)alpha);
|
||||
}
|
||||
|
||||
-(void)_refreshWithColor:(UIColor*)color {
|
||||
// Extract colors
|
||||
CGFloat red; CGFloat green; CGFloat blue; CGFloat alpha;
|
||||
[color getRed:&red
|
||||
green:&green
|
||||
blue:&blue
|
||||
alpha:&alpha];
|
||||
// Set them on the base shader
|
||||
self.baseEffect.constantColor = GLKVector4Make((GLclampf)red,(GLclampf)green,(GLclampf)blue,(GLclampf)alpha);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#elif TARGET_OS_MAC
|
||||
|
||||
#endif
|
||||
@@ -25,8 +25,8 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <AudioToolbox/AudioToolbox.h>
|
||||
#import <TargetConditionals.h>
|
||||
#import "TPCircularBuffer.h"
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#elif TARGET_OS_MAC
|
||||
@@ -46,6 +46,17 @@ typedef struct
|
||||
TPCircularBuffer circularBuffer;
|
||||
} EZPlotHistoryInfo;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
A data structure that holds information about a node in the context of an AUGraph.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
AudioUnit audioUnit;
|
||||
AUNode node;
|
||||
} EZAudioNodeInfo;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Types
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -56,6 +67,14 @@ typedef CGRect EZRect;
|
||||
typedef NSRect EZRect;
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
typedef UIColor EZColor;
|
||||
#elif TARGET_OS_MAC
|
||||
typedef NSColor EZColor;
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - EZAudioUtilities
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -393,6 +412,28 @@ typedef NSRect EZRect;
|
||||
*/
|
||||
+ (NSString *)stringFromUInt32Code:(UInt32)code;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Color Utility
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
///-----------------------------------------------------------
|
||||
/// @name Color Utility
|
||||
///-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
Helper function to get the color components from a CGColorRef in the RGBA colorspace.
|
||||
@param color A CGColorRef that represents a color.
|
||||
@param red A pointer to a CGFloat to hold the value of the red component. This value will be between 0 and 1.
|
||||
@param green A pointer to a CGFloat to hold the value of the green component. This value will be between 0 and 1.
|
||||
@param blue A pointer to a CGFloat to hold the value of the blue component. This value will be between 0 and 1.
|
||||
@param alpha A pointer to a CGFloat to hold the value of the alpha component. This value will be between 0 and 1.
|
||||
*/
|
||||
+ (void)getColorComponentsFromCGColor:(CGColorRef)color
|
||||
red:(CGFloat *)red
|
||||
green:(CGFloat *)green
|
||||
blue:(CGFloat *)blue
|
||||
alpha:(CGFloat *)alpha;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Plot Utility
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -467,6 +508,14 @@ typedef NSRect EZRect;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Zeroes out a EZPlotHistoryInfo data structure without freeing the resources.
|
||||
@param historyInfo A pointer to a EZPlotHistoryInfo data structure
|
||||
*/
|
||||
+ (void)clearHistoryInfo:(EZPlotHistoryInfo *)historyInfo;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Frees a EZPlotHistoryInfo data structure
|
||||
@param historyInfo A pointer to a EZPlotHistoryInfo data structure
|
||||
|
||||
@@ -534,6 +534,31 @@ BOOL __shouldExitOnCheckResultFail = YES;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Color Utility
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
///-----------------------------------------------------------
|
||||
/// @name Color Utility
|
||||
///-----------------------------------------------------------
|
||||
|
||||
+ (void)getColorComponentsFromCGColor:(CGColorRef)color
|
||||
red:(CGFloat *)red
|
||||
green:(CGFloat *)green
|
||||
blue:(CGFloat *)blue
|
||||
alpha:(CGFloat *)alpha
|
||||
{
|
||||
size_t componentCount = CGColorGetNumberOfComponents(color);
|
||||
if (componentCount == 4)
|
||||
{
|
||||
const CGFloat *components = CGColorGetComponents(color);
|
||||
*red = components[0];
|
||||
*green = components[1];
|
||||
*blue = components[2];
|
||||
*alpha = components[3];
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - TPCircularBuffer Utility
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -591,17 +616,25 @@ BOOL __shouldExitOnCheckResultFail = YES;
|
||||
memmove(historyInfo->buffer, historyBuffer, bytes);
|
||||
if (targetBytes <= availableBytes)
|
||||
{
|
||||
TPCircularBufferConsume(&historyInfo->circularBuffer, sizeof(src));
|
||||
TPCircularBufferConsume(&historyInfo->circularBuffer, availableBytes - targetBytes);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
+ (void)clearHistoryInfo:(EZPlotHistoryInfo *)historyInfo
|
||||
{
|
||||
memset(historyInfo->buffer, 0, historyInfo->bufferSize * sizeof(float));
|
||||
TPCircularBufferClear(&historyInfo->circularBuffer);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
+ (void)freeHistoryInfo:(EZPlotHistoryInfo *)historyInfo
|
||||
{
|
||||
free(historyInfo->buffer);
|
||||
free(historyInfo);
|
||||
TPCircularBufferClear(&historyInfo->circularBuffer);
|
||||
TPCircularBufferCleanup(&historyInfo->circularBuffer);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
The delegate for the EZMicrophone provides a receiver for the incoming audio data events. When the microphone has been successfully internally configured it will try to send its delegate an AudioStreamBasicDescription describing the format of the incoming audio data.
|
||||
The EZMicrophoneDelegate for the EZMicrophone provides a receiver for the incoming audio data events. When the microphone has been successfully internally configured it will try to send its delegate an AudioStreamBasicDescription describing the format of the incoming audio data.
|
||||
|
||||
The audio data itself is sent back to the delegate in various forms:
|
||||
|
||||
@@ -55,10 +55,9 @@
|
||||
///-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
Called anytime the input device changes on an `EZMicrophone` instance. Mac only.
|
||||
Called anytime the input device changes on an `EZMicrophone` instance.
|
||||
@param microphone The instance of the EZMicrophone that triggered the event.
|
||||
@param device The instance of the new EZAudioDevice the microphone is using to pull input.
|
||||
@param notification Incase the device changed because of a notification (like from AVAudioSession) then we provide that notification to give the full context of the change.
|
||||
*/
|
||||
- (void)microphone:(EZMicrophone *)microphone changedDevice:(EZAudioDevice *)device;
|
||||
|
||||
@@ -77,7 +76,7 @@
|
||||
///-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
Returns back a float array of the audio received. This occurs on the background thread so any drawing code must explicity perform its functions on the main thread.
|
||||
This method provides an array of float arrays of the audio received, each float array representing a channel of audio data This occurs on the background thread so any drawing code must explicity perform its functions on the main thread.
|
||||
@param microphone The instance of the EZMicrophone that triggered the event.
|
||||
@param buffer The audio data as an array of float arrays. In a stereo signal buffer[0] represents the left channel while buffer[1] would represent the right channel.
|
||||
@param bufferSize The size of each of the buffers (the length of each float array).
|
||||
@@ -304,7 +303,9 @@
|
||||
*/
|
||||
- (AudioUnit *)audioUnit;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Setters
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
///-----------------------------------------------------------
|
||||
/// @name Customizing The Microphone Stream Format
|
||||
|
||||
@@ -535,21 +535,23 @@ static OSStatus EZAudioMicrophoneCallback(void *inRefCon,
|
||||
- (void)setOutput:(EZOutput *)output
|
||||
{
|
||||
_output = output;
|
||||
[_output setAudioStreamBasicDescription:self.audioStreamBasicDescription];
|
||||
_output.outputDataSource = self;
|
||||
_output.inputFormat = self.audioStreamBasicDescription;
|
||||
_output.dataSource = self;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - EZOutputDataSource
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void) output:(EZOutput *)output
|
||||
- (OSStatus) output:(EZOutput *)output
|
||||
shouldFillAudioBufferList:(AudioBufferList *)audioBufferList
|
||||
withNumberOfFrames:(UInt32)frames
|
||||
timestamp:(const AudioTimeStamp *)timestamp
|
||||
{
|
||||
memcpy(audioBufferList,
|
||||
self.info->audioBufferList,
|
||||
sizeof(AudioBufferList) + (self.info->audioBufferList->mNumberBuffers - 1)*sizeof(AudioBuffer));
|
||||
return noErr;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
+249
-74
@@ -30,72 +30,102 @@
|
||||
#import <AudioUnit/AudioUnit.h>
|
||||
#endif
|
||||
|
||||
#import "TPCircularBuffer.h"
|
||||
|
||||
@class EZAudioDevice;
|
||||
@class EZOutput;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Constants
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
FOUNDATION_EXPORT UInt32 const EZOutputMaximumFramesPerSlice;
|
||||
FOUNDATION_EXPORT Float64 const EZOutputDefaultSampleRate;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - EZOutputDataSource
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
The EZOutputDataSource (required for the EZOutput) specifies a receiver to provide audio data when the EZOutput is started. Only ONE datasource method is expected to be implemented and priority is given as such:
|
||||
1.) `output:callbackWithActionFlags:inTimeStamp:inBusNumber:inNumberFrames:ioData:`
|
||||
2.) `outputShouldUseCircularBuffer:`
|
||||
3.) `output:needsBufferListWithFrames:withBufferSize:`
|
||||
The EZOutputDataSource specifies a receiver to provide audio data when the EZOutput is started. Since the 0.4.0 release this has been simplified to only one data source method.
|
||||
*/
|
||||
@protocol EZOutputDataSource <NSObject>
|
||||
|
||||
@optional
|
||||
///-----------------------------------------------------------
|
||||
/// @name Pulling The Audio Data
|
||||
/// @name Providing Audio Data
|
||||
///-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides complete override of the output callback function. The delegate is expected to
|
||||
@param output The instance of the EZOutput that asked for the data
|
||||
@param ioActionFlags AudioUnitRenderActionFlags provided by the output callback
|
||||
@param inTimeStamp AudioTimeStamp reference provided by the output callback
|
||||
@param inBusNumber UInt32 representing the bus number provided by the output callback
|
||||
@param inNumberFrames UInt32 representing the number of frames provided by the output callback
|
||||
@param ioData AudioBufferList pointer representing the audio data that will be used for output provided by the output callback (fill this!)
|
||||
*/
|
||||
-(void)output:(EZOutput*)output
|
||||
callbackWithActionFlags:(AudioUnitRenderActionFlags*)ioActionFlags
|
||||
inTimeStamp:(const AudioTimeStamp*)inTimeStamp
|
||||
inBusNumber:(UInt32)inBusNumber
|
||||
inNumberFrames:(UInt32)inNumberFrames
|
||||
ioData:(AudioBufferList*)ioData;
|
||||
@required
|
||||
|
||||
/**
|
||||
Provides output using a circular
|
||||
@param output The instance of the EZOutput that asked for the data
|
||||
@return The EZOutputDataSource's TPCircularBuffer structure holding the audio data in a circular buffer
|
||||
*/
|
||||
-(TPCircularBuffer*)outputShouldUseCircularBuffer:(EZOutput *)output;
|
||||
|
||||
|
||||
/**
|
||||
Provides a way to provide output with data anytime the EZOutput needs audio data to play. This function provides an already allocated AudioBufferList to use for providing audio data into the output buffer.
|
||||
Provides a way to provide output with data anytime the EZOutput needs audio data to play. This function provides an already allocated AudioBufferList to use for providing audio data into the output buffer. The expected format of the audio data provided here is specified by the EZOutput `inputFormat` property. This audio data will be converted into the client format specified by the EZOutput `clientFormat` property.
|
||||
@param output The instance of the EZOutput that asked for the data.
|
||||
@param audioBufferList The AudioBufferList structure pointer that needs to be filled with audio data
|
||||
@param frames The amount of frames as a UInt32 that output will need to properly fill its output buffer.
|
||||
@return A pointer to the AudioBufferList structure holding the audio data. If nil or NULL, will output silence.
|
||||
@param timestamp A AudioTimeStamp pointer to use if you need the current host time.
|
||||
@return An OSStatus code. If there was no error then use the noErr status code.
|
||||
*/
|
||||
-(void) output:(EZOutput *)output
|
||||
shouldFillAudioBufferList:(AudioBufferList*)audioBufferList
|
||||
withNumberOfFrames:(UInt32)frames;
|
||||
- (OSStatus) output:(EZOutput *)output
|
||||
shouldFillAudioBufferList:(AudioBufferList *)audioBufferList
|
||||
withNumberOfFrames:(UInt32)frames
|
||||
timestamp:(const AudioTimeStamp *)timestamp;
|
||||
|
||||
@end
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - EZOutputDelegate
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
The EZOutputDelegate for the EZOutput component provides a receiver to handle play state, device, and audio data change events. This is very similar to the EZMicrophoneDelegate for the EZMicrophone and the EZAudioFileDelegate for the EZAudioFile.
|
||||
*/
|
||||
@protocol EZOutputDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
|
||||
/**
|
||||
Called anytime the EZOutput starts or stops.
|
||||
@param output The instance of the EZOutput that triggered the event.
|
||||
@param isPlaying A BOOL indicating whether the EZOutput instance is playing or not.
|
||||
*/
|
||||
- (void)output:(EZOutput *)output changedPlayingState:(BOOL)isPlaying;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Called anytime the `device` changes on an EZOutput instance.
|
||||
@param output The instance of the EZOutput that triggered the event.
|
||||
@param device The instance of the new EZAudioDevice the output is using to play audio data.
|
||||
*/
|
||||
- (void)output:(EZOutput *)output changedDevice:(EZAudioDevice *)device;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Like the EZMicrophoneDelegate, for the EZOutput this method provides an array of float arrays of the audio received, each float array representing a channel of audio data. This occurs on the background thread so any drawing code must explicity perform its functions on the main thread.
|
||||
@param output The instance of the EZOutput that triggered the event.
|
||||
@param buffer The audio data as an array of float arrays. In a stereo signal buffer[0] represents the left channel while buffer[1] would represent the right channel.
|
||||
@param bufferSize A UInt32 representing the size of each of the buffers (the length of each float array).
|
||||
@param numberOfChannels A UInt32 representing the number of channels (you can use this to know how many float arrays are in the `buffer` parameter.
|
||||
@warning This function executes on a background thread to avoid blocking any audio operations. If operations should be performed on any other thread (like the main thread) it should be performed within a dispatch block like so: dispatch_async(dispatch_get_main_queue(), ^{ ...Your Code... })
|
||||
*/
|
||||
- (void) output:(EZOutput *)output
|
||||
playedAudio:(float **)buffer
|
||||
withBufferSize:(UInt32)bufferSize
|
||||
withNumberOfChannels:(UInt32)numberOfChannels;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
The EZOutput component provides a generic output to glue all the other EZAudio components together and push whatever sound you've created to the default output device (think opposite of the microphone). The EZOutputDataSource provides the required AudioBufferList needed to populate the output buffer.
|
||||
The EZOutput component provides a generic output to glue all the other EZAudio components together and push whatever sound you've created to the default output device (think opposite of the microphone). The EZOutputDataSource provides the required AudioBufferList needed to populate the output buffer while the EZOutputDelegate provides the same kind of mechanism as the EZMicrophoneDelegate or EZAudioFileDelegate in that you will receive a callback that provides non-interleaved, float data for visualizing the output (done using an internal float converter). As of 0.4.0 the EZOutput has been simplified to a single EZOutputDataSource method and now uses an AUGraph to provide format conversion from the `inputFormat` to the playback graph's `clientFormat` linear PCM formats, mixer controls for setting volume and pan settings, hooks to add in any number of effect audio units (see the `connectOutputOfSourceNode:sourceNodeOutputBus:toDestinationNode:destinationNodeInputBus:inGraph:` subclass method), and hardware device toggling (via EZAudioDevice).
|
||||
*/
|
||||
@interface EZOutput : NSObject
|
||||
|
||||
#pragma mark - Properties
|
||||
/**
|
||||
The EZOutputDataSource that provides the required AudioBufferList to the output callback function
|
||||
*/
|
||||
@property (nonatomic,assign) id<EZOutputDataSource>outputDataSource;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Initializers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
///-----------------------------------------------------------
|
||||
/// @name Initializers
|
||||
///-----------------------------------------------------------
|
||||
@@ -105,29 +135,38 @@ inNumberFrames:(UInt32)inNumberFrames
|
||||
@param dataSource The EZOutputDataSource that will be used to pull the audio data for the output callback.
|
||||
@return A newly created instance of the EZOutput class.
|
||||
*/
|
||||
-(id)initWithDataSource:(id<EZOutputDataSource>)dataSource;
|
||||
- (instancetype)initWithDataSource:(id<EZOutputDataSource>)dataSource;
|
||||
|
||||
/**
|
||||
Creates a new instance of the EZOutput and allows the caller to specify an EZOutputDataSource.
|
||||
@param dataSource The EZOutputDataSource that will be used to pull the audio data for the output callback.
|
||||
@param audioStreamBasicDescription The AudioStreamBasicDescription of the EZOutput.
|
||||
@warning AudioStreamBasicDescriptions that are invalid will cause the EZOutput to fail to initialize
|
||||
@param inputFormat The AudioStreamBasicDescription of the EZOutput.
|
||||
@warning AudioStreamBasicDescription input formats must be linear PCM!
|
||||
@return A newly created instance of the EZOutput class.
|
||||
*/
|
||||
-(id) initWithDataSource:(id<EZOutputDataSource>)dataSource
|
||||
withAudioStreamBasicDescription:(AudioStreamBasicDescription)audioStreamBasicDescription;
|
||||
- (instancetype)initWithDataSource:(id<EZOutputDataSource>)dataSource
|
||||
inputFormat:(AudioStreamBasicDescription)inputFormat;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Class Initializers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
///-----------------------------------------------------------
|
||||
/// @name Class Initializers
|
||||
///-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
Class method to create a new instance of the EZOutput
|
||||
@return A newly created instance of the EZOutput class.
|
||||
*/
|
||||
+ (instancetype)output;
|
||||
|
||||
/**
|
||||
Class method to create a new instance of the EZOutput and allows the caller to specify an EZOutputDataSource.
|
||||
@param dataSource The EZOutputDataSource that will be used to pull the audio data for the output callback.
|
||||
@return A newly created instance of the EZOutput class.
|
||||
*/
|
||||
+(EZOutput*)outputWithDataSource:(id<EZOutputDataSource>)dataSource;
|
||||
+ (instancetype)outputWithDataSource:(id<EZOutputDataSource>)dataSource;
|
||||
|
||||
/**
|
||||
Class method to create a new instance of the EZOutput and allows the caller to specify an EZOutputDataSource.
|
||||
@@ -136,10 +175,13 @@ inNumberFrames:(UInt32)inNumberFrames
|
||||
@warning AudioStreamBasicDescriptions that are invalid will cause the EZOutput to fail to initialize
|
||||
@return A newly created instance of the EZOutput class.
|
||||
*/
|
||||
+(EZOutput*)outputWithDataSource:(id<EZOutputDataSource>)dataSource
|
||||
withAudioStreamBasicDescription:(AudioStreamBasicDescription)audioStreamBasicDescription;
|
||||
+ (instancetype)outputWithDataSource:(id<EZOutputDataSource>)dataSource
|
||||
inputFormat:(AudioStreamBasicDescription)inputFormat;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Singleton
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
///-----------------------------------------------------------
|
||||
/// @name Shared Instance
|
||||
///-----------------------------------------------------------
|
||||
@@ -148,9 +190,123 @@ inNumberFrames:(UInt32)inNumberFrames
|
||||
Creates a shared instance of the EZOutput (one app will usually only need one output and share the role of the EZOutputDataSource).
|
||||
@return The shared instance of the EZOutput class.
|
||||
*/
|
||||
+(EZOutput*)sharedOutput;
|
||||
+ (instancetype)sharedOutput;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Properties
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
///-----------------------------------------------------------
|
||||
/// @name Setting/Getting The Stream Formats
|
||||
///-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides the AudioStreamBasicDescription structure used at the beginning of the playback graph which is then converted into the `clientFormat` using the AUConverter audio unit.
|
||||
@warning The AudioStreamBasicDescription set here must be linear PCM. Compressed formats are not supported...the EZAudioFile's clientFormat performs the audio conversion on the fly from compressed to linear PCM so there is no additional work to be done there.
|
||||
@return An AudioStreamBasicDescription structure describing
|
||||
*/
|
||||
@property (nonatomic, readwrite) AudioStreamBasicDescription inputFormat;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides the AudioStreamBasicDescription structure that serves as the common format used throughout the playback graph (similar to how the EZAudioFile as a clientFormat that is linear PCM to be shared amongst other components). The `inputFormat` is converted into this format at the beginning of the playback graph using an AUConverter audio unit. Defaults to the whatever the `defaultClientFormat` method returns is if a custom one isn't explicitly set.
|
||||
@warning The AudioStreamBasicDescription set here must be linear PCM. Compressed formats are not supported by Audio Units.
|
||||
@return An AudioStreamBasicDescription structure describing the common client format for the playback graph.
|
||||
*/
|
||||
@property (nonatomic, readwrite) AudioStreamBasicDescription clientFormat;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
///-----------------------------------------------------------
|
||||
/// @name Setting/Getting The Data Source and Delegate
|
||||
///-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
The EZOutputDataSource that provides the audio data in the `inputFormat` for the EZOutput to play. If an EZOutputDataSource is not specified then the EZOutput will just output silence.
|
||||
*/
|
||||
@property (nonatomic, weak) id<EZOutputDataSource> dataSource;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
The EZOutputDelegate for which to handle the output callbacks
|
||||
*/
|
||||
@property (nonatomic, weak) id<EZOutputDelegate> delegate;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides a flag indicating whether the EZOutput is pulling audio data from the EZOutputDataSource for playback.
|
||||
@return YES if the EZOutput is running, NO if it is stopped
|
||||
*/
|
||||
@property (readonly) BOOL isPlaying;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides the current pan from the audio player's mixer audio unit in the playback graph. Setting the pan adjusts the direction of the audio signal from left (0) to right (1). Default is 0.5 (middle).
|
||||
*/
|
||||
@property (nonatomic, assign) float pan;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides the current volume from the audio player's mixer audio unit in the playback graph. Setting the volume adjusts the gain of the output between 0 and 1. Default is 1.
|
||||
*/
|
||||
@property (nonatomic, assign) float volume;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Core Audio Properties
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
///-----------------------------------------------------------
|
||||
/// @name Core Audio Properties
|
||||
///-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
The AUGraph used to chain together the converter, mixer, and output audio units.
|
||||
*/
|
||||
@property (readonly) AUGraph graph;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
The AudioUnit that is being used to convert the audio data coming into the output's playback graph.
|
||||
*/
|
||||
@property (readonly) AudioUnit converterAudioUnit;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
The AudioUnit that is being used as the mixer to adjust the volume on the output's playback graph.
|
||||
*/
|
||||
@property (readonly) AudioUnit mixerAudioUnit;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
The AudioUnit that is being used as the hardware output for the output's playback graph.
|
||||
*/
|
||||
@property (readonly) AudioUnit outputAudioUnit;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Setters
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
///-----------------------------------------------------------
|
||||
/// @name Getting/Setting The Output's Hardware Device
|
||||
///-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
An EZAudioDevice instance that is used to route the audio data out to the speaker. To find a list of available output devices see the EZAudioDevice `outputDevices` method.
|
||||
*/
|
||||
@property (nonatomic, strong, readwrite) EZAudioDevice *device;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Actions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#pragma mark - Events
|
||||
///-----------------------------------------------------------
|
||||
/// @name Starting/Stopping The Output
|
||||
///-----------------------------------------------------------
|
||||
@@ -158,44 +314,63 @@ inNumberFrames:(UInt32)inNumberFrames
|
||||
/**
|
||||
Starts pulling audio data from the EZOutputDataSource to the default device output.
|
||||
*/
|
||||
-(void)startPlayback;
|
||||
- (void)startPlayback;
|
||||
|
||||
///-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
Stops pulling audio data from the EZOutputDataSource to the default device output.
|
||||
*/
|
||||
-(void)stopPlayback;
|
||||
- (void)stopPlayback;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Subclass
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#pragma mark - Getters
|
||||
///-----------------------------------------------------------
|
||||
/// @name Getting The Output Audio Format
|
||||
/// @name Subclass
|
||||
///-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides the AudioStreamBasicDescription structure containing the format of the microphone's audio.
|
||||
@return An AudioStreamBasicDescription structure describing the format of the microphone's audio.
|
||||
This method handles connecting the converter node to the mixer node within the AUGraph that is being used as the playback graph. Subclasses can override this method and insert their custom nodes to perform effects processing on the audio data being rendered.
|
||||
|
||||
This was inspired by Daniel Kennett's blog post on how to add a custom equalizer to a CocoaLibSpotify SPCoreAudioController's AUGraph. For more information see Daniel's post and example code here: http://ikennd.ac/blog/2012/04/augraph-basics-in-cocoalibspotify/.
|
||||
@param sourceNode An AUNode representing the node the audio data is coming from.
|
||||
@param sourceNodeOutputBus A UInt32 representing the output bus from the source node that should be connected into the next node's input bus.
|
||||
@param destinationNode An AUNode representing the node the audio data should be connected to.
|
||||
@param destinationNodeInputBus A UInt32 representing the input bus the source node's output bus should be connecting to.
|
||||
@param graph The AUGraph that is being used to hold the playback graph. Same as from the `graph` property.
|
||||
@return An OSStatus code. For no error return back `noErr`.
|
||||
*/
|
||||
-(AudioStreamBasicDescription)audioStreamBasicDescription;
|
||||
- (OSStatus)connectOutputOfSourceNode:(AUNode)sourceNode
|
||||
sourceNodeOutputBus:(UInt32)sourceNodeOutputBus
|
||||
toDestinationNode:(AUNode)destinationNode
|
||||
destinationNodeInputBus:(UInt32)destinationNodeInputBus
|
||||
inGraph:(AUGraph)graph;
|
||||
|
||||
///-----------------------------------------------------------
|
||||
/// @name Getting The State Of The Output
|
||||
///-----------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Provides a flag indicating whether the EZOutput is pulling audio data from the EZOutputDataSource for playback.
|
||||
@return YES if the EZOutput is pulling audio data to the output device, NO if it is stopped
|
||||
The default AudioStreamBasicDescription set as the client format of the output if no custom `clientFormat` is set. Defaults to a 44.1 kHz stereo, non-interleaved, float format.
|
||||
@return An AudioStreamBasicDescription that will be used as the default stream format.
|
||||
*/
|
||||
-(BOOL)isPlaying;
|
||||
- (AudioStreamBasicDescription)defaultClientFormat;
|
||||
|
||||
#pragma mark - Setters
|
||||
///-----------------------------------------------------------
|
||||
/// @name Customizing The Output Format
|
||||
///-----------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Sets the AudioStreamBasicDescription on the output.
|
||||
@warning Do not set this during playback.
|
||||
@param asbd The new AudioStreamBasicDescription to use in place of the current audio format description.
|
||||
The default AudioStreamBasicDescription set as the `inputFormat` of the output if no custom `inputFormat` is set. Defaults to a 44.1 kHz stereo, non-interleaved, float format.
|
||||
@return An AudioStreamBasicDescription that will be used as the default stream format.
|
||||
*/
|
||||
-(void)setAudioStreamBasicDescription:(AudioStreamBasicDescription)asbd;
|
||||
- (AudioStreamBasicDescription)defaultInputFormat;
|
||||
|
||||
@end
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
The default value used as the AudioUnit subtype when creating the hardware output component. By default this is kAudioUnitSubType_RemoteIO for iOS and kAudioUnitSubType_HALOutput for OSX.
|
||||
@warning If you change this to anything other than kAudioUnitSubType_HALOutput for OSX you will get a failed assertion because devices can only be set when using the HAL audio unit.
|
||||
@return An OSType that represents the AudioUnit subtype for the hardware output component.
|
||||
*/
|
||||
- (OSType)outputAudioUnitSubType;
|
||||
|
||||
@end
|
||||
+688
-305
File diff suppressed because it is too large
Load Diff
@@ -43,6 +43,7 @@ typedef NS_ENUM(NSInteger, EZPlotType)
|
||||
Plot that displays only the samples of the current buffer
|
||||
*/
|
||||
EZPlotTypeBuffer,
|
||||
|
||||
/**
|
||||
Plot that displays a rolling history of values using the RMS calculated for each incoming buffer
|
||||
*/
|
||||
|
||||
-6
@@ -30,7 +30,6 @@
|
||||
66755A371B3B790D0013E67E /* EZAudioPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755A1A1B3B790D0013E67E /* EZAudioPlayer.m */; };
|
||||
66755A381B3B790D0013E67E /* EZAudioPlot.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755A1C1B3B790D0013E67E /* EZAudioPlot.m */; };
|
||||
66755A391B3B790D0013E67E /* EZAudioPlotGL.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755A1E1B3B790D0013E67E /* EZAudioPlotGL.m */; };
|
||||
66755A3A1B3B790D0013E67E /* EZAudioPlotGLKViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755A201B3B790D0013E67E /* EZAudioPlotGLKViewController.m */; };
|
||||
66755A3B1B3B790D0013E67E /* EZAudioUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755A221B3B790D0013E67E /* EZAudioUtilities.m */; };
|
||||
66755A3C1B3B790D0013E67E /* EZMicrophone.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755A241B3B790D0013E67E /* EZMicrophone.m */; };
|
||||
66755A3D1B3B790D0013E67E /* EZOutput.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755A261B3B790D0013E67E /* EZOutput.m */; };
|
||||
@@ -89,8 +88,6 @@
|
||||
66755A1C1B3B790D0013E67E /* EZAudioPlot.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlot.m; sourceTree = "<group>"; };
|
||||
66755A1D1B3B790D0013E67E /* EZAudioPlotGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGL.h; sourceTree = "<group>"; };
|
||||
66755A1E1B3B790D0013E67E /* EZAudioPlotGL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGL.m; sourceTree = "<group>"; };
|
||||
66755A1F1B3B790D0013E67E /* EZAudioPlotGLKViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGLKViewController.h; sourceTree = "<group>"; };
|
||||
66755A201B3B790D0013E67E /* EZAudioPlotGLKViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGLKViewController.m; sourceTree = "<group>"; };
|
||||
66755A211B3B790D0013E67E /* EZAudioUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioUtilities.h; sourceTree = "<group>"; };
|
||||
66755A221B3B790D0013E67E /* EZAudioUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioUtilities.m; sourceTree = "<group>"; };
|
||||
66755A231B3B790D0013E67E /* EZMicrophone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZMicrophone.h; sourceTree = "<group>"; };
|
||||
@@ -183,8 +180,6 @@
|
||||
66755A1C1B3B790D0013E67E /* EZAudioPlot.m */,
|
||||
66755A1D1B3B790D0013E67E /* EZAudioPlotGL.h */,
|
||||
66755A1E1B3B790D0013E67E /* EZAudioPlotGL.m */,
|
||||
66755A1F1B3B790D0013E67E /* EZAudioPlotGLKViewController.h */,
|
||||
66755A201B3B790D0013E67E /* EZAudioPlotGLKViewController.m */,
|
||||
66755A211B3B790D0013E67E /* EZAudioUtilities.h */,
|
||||
66755A221B3B790D0013E67E /* EZAudioUtilities.m */,
|
||||
66755A231B3B790D0013E67E /* EZMicrophone.h */,
|
||||
@@ -425,7 +420,6 @@
|
||||
66755A371B3B790D0013E67E /* EZAudioPlayer.m in Sources */,
|
||||
94056D88185B97E300EB94BA /* CoreGraphicsWaveformViewController.m in Sources */,
|
||||
66755A391B3B790D0013E67E /* EZAudioPlotGL.m in Sources */,
|
||||
66755A3A1B3B790D0013E67E /* EZAudioPlotGLKViewController.m in Sources */,
|
||||
66755A341B3B790D0013E67E /* EZAudioFile.m in Sources */,
|
||||
66755A3D1B3B790D0013E67E /* EZOutput.m in Sources */,
|
||||
66755A3B1B3B790D0013E67E /* EZAudioUtilities.m in Sources */,
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
66755B8D1B3B79380013E67E /* EZAudioPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755B701B3B79380013E67E /* EZAudioPlayer.m */; };
|
||||
66755B8E1B3B79380013E67E /* EZAudioPlot.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755B721B3B79380013E67E /* EZAudioPlot.m */; };
|
||||
66755B8F1B3B79380013E67E /* EZAudioPlotGL.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755B741B3B79380013E67E /* EZAudioPlotGL.m */; };
|
||||
66755B901B3B79380013E67E /* EZAudioPlotGLKViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755B761B3B79380013E67E /* EZAudioPlotGLKViewController.m */; };
|
||||
66755B911B3B79380013E67E /* EZAudioUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755B781B3B79380013E67E /* EZAudioUtilities.m */; };
|
||||
66755B921B3B79380013E67E /* EZMicrophone.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755B7A1B3B79380013E67E /* EZMicrophone.m */; };
|
||||
66755B931B3B79380013E67E /* EZOutput.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755B7C1B3B79380013E67E /* EZOutput.m */; };
|
||||
@@ -76,8 +75,6 @@
|
||||
66755B721B3B79380013E67E /* EZAudioPlot.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlot.m; sourceTree = "<group>"; };
|
||||
66755B731B3B79380013E67E /* EZAudioPlotGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGL.h; sourceTree = "<group>"; };
|
||||
66755B741B3B79380013E67E /* EZAudioPlotGL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGL.m; sourceTree = "<group>"; };
|
||||
66755B751B3B79380013E67E /* EZAudioPlotGLKViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGLKViewController.h; sourceTree = "<group>"; };
|
||||
66755B761B3B79380013E67E /* EZAudioPlotGLKViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGLKViewController.m; sourceTree = "<group>"; };
|
||||
66755B771B3B79380013E67E /* EZAudioUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioUtilities.h; sourceTree = "<group>"; };
|
||||
66755B781B3B79380013E67E /* EZAudioUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioUtilities.m; sourceTree = "<group>"; };
|
||||
66755B791B3B79380013E67E /* EZMicrophone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZMicrophone.h; sourceTree = "<group>"; };
|
||||
@@ -172,8 +169,6 @@
|
||||
66755B721B3B79380013E67E /* EZAudioPlot.m */,
|
||||
66755B731B3B79380013E67E /* EZAudioPlotGL.h */,
|
||||
66755B741B3B79380013E67E /* EZAudioPlotGL.m */,
|
||||
66755B751B3B79380013E67E /* EZAudioPlotGLKViewController.h */,
|
||||
66755B761B3B79380013E67E /* EZAudioPlotGLKViewController.m */,
|
||||
66755B771B3B79380013E67E /* EZAudioUtilities.h */,
|
||||
66755B781B3B79380013E67E /* EZAudioUtilities.m */,
|
||||
66755B791B3B79380013E67E /* EZMicrophone.h */,
|
||||
@@ -398,7 +393,6 @@
|
||||
66755B8D1B3B79380013E67E /* EZAudioPlayer.m in Sources */,
|
||||
9417A9D61872130200D9D37B /* FFTViewController.m in Sources */,
|
||||
66755B8F1B3B79380013E67E /* EZAudioPlotGL.m in Sources */,
|
||||
66755B901B3B79380013E67E /* EZAudioPlotGLKViewController.m in Sources */,
|
||||
66755B8A1B3B79380013E67E /* EZAudioFile.m in Sources */,
|
||||
66755B931B3B79380013E67E /* EZOutput.m in Sources */,
|
||||
66755B911B3B79380013E67E /* EZAudioUtilities.m in Sources */,
|
||||
|
||||
-6
@@ -16,7 +16,6 @@
|
||||
66755A701B3B79130013E67E /* EZAudioPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755A531B3B79130013E67E /* EZAudioPlayer.m */; };
|
||||
66755A711B3B79130013E67E /* EZAudioPlot.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755A551B3B79130013E67E /* EZAudioPlot.m */; };
|
||||
66755A721B3B79130013E67E /* EZAudioPlotGL.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755A571B3B79130013E67E /* EZAudioPlotGL.m */; };
|
||||
66755A731B3B79130013E67E /* EZAudioPlotGLKViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755A591B3B79130013E67E /* EZAudioPlotGLKViewController.m */; };
|
||||
66755A741B3B79130013E67E /* EZAudioUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755A5B1B3B79130013E67E /* EZAudioUtilities.m */; };
|
||||
66755A751B3B79130013E67E /* EZMicrophone.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755A5D1B3B79130013E67E /* EZMicrophone.m */; };
|
||||
66755A761B3B79130013E67E /* EZOutput.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755A5F1B3B79130013E67E /* EZOutput.m */; };
|
||||
@@ -75,8 +74,6 @@
|
||||
66755A551B3B79130013E67E /* EZAudioPlot.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlot.m; sourceTree = "<group>"; };
|
||||
66755A561B3B79130013E67E /* EZAudioPlotGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGL.h; sourceTree = "<group>"; };
|
||||
66755A571B3B79130013E67E /* EZAudioPlotGL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGL.m; sourceTree = "<group>"; };
|
||||
66755A581B3B79130013E67E /* EZAudioPlotGLKViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGLKViewController.h; sourceTree = "<group>"; };
|
||||
66755A591B3B79130013E67E /* EZAudioPlotGLKViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGLKViewController.m; sourceTree = "<group>"; };
|
||||
66755A5A1B3B79130013E67E /* EZAudioUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioUtilities.h; sourceTree = "<group>"; };
|
||||
66755A5B1B3B79130013E67E /* EZAudioUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioUtilities.m; sourceTree = "<group>"; };
|
||||
66755A5C1B3B79130013E67E /* EZMicrophone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZMicrophone.h; sourceTree = "<group>"; };
|
||||
@@ -169,8 +166,6 @@
|
||||
66755A551B3B79130013E67E /* EZAudioPlot.m */,
|
||||
66755A561B3B79130013E67E /* EZAudioPlotGL.h */,
|
||||
66755A571B3B79130013E67E /* EZAudioPlotGL.m */,
|
||||
66755A581B3B79130013E67E /* EZAudioPlotGLKViewController.h */,
|
||||
66755A591B3B79130013E67E /* EZAudioPlotGLKViewController.m */,
|
||||
66755A5A1B3B79130013E67E /* EZAudioUtilities.h */,
|
||||
66755A5B1B3B79130013E67E /* EZAudioUtilities.m */,
|
||||
66755A5C1B3B79130013E67E /* EZMicrophone.h */,
|
||||
@@ -394,7 +389,6 @@
|
||||
66755A701B3B79130013E67E /* EZAudioPlayer.m in Sources */,
|
||||
94056DAA185BB0BC00EB94BA /* AppDelegate.m in Sources */,
|
||||
66755A721B3B79130013E67E /* EZAudioPlotGL.m in Sources */,
|
||||
66755A731B3B79130013E67E /* EZAudioPlotGLKViewController.m in Sources */,
|
||||
66755A6D1B3B79130013E67E /* EZAudioFile.m in Sources */,
|
||||
66755A761B3B79130013E67E /* EZOutput.m in Sources */,
|
||||
66755A741B3B79130013E67E /* EZAudioUtilities.m in Sources */,
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7702" systemVersion="14C109" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment version="1070" identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7702"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7706"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="OpenGLWaveformViewController">
|
||||
|
||||
-6
@@ -16,7 +16,6 @@
|
||||
66755B541B3B79310013E67E /* EZAudioPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755B371B3B79310013E67E /* EZAudioPlayer.m */; };
|
||||
66755B551B3B79310013E67E /* EZAudioPlot.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755B391B3B79310013E67E /* EZAudioPlot.m */; };
|
||||
66755B561B3B79310013E67E /* EZAudioPlotGL.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755B3B1B3B79310013E67E /* EZAudioPlotGL.m */; };
|
||||
66755B571B3B79310013E67E /* EZAudioPlotGLKViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755B3D1B3B79310013E67E /* EZAudioPlotGLKViewController.m */; };
|
||||
66755B581B3B79310013E67E /* EZAudioUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755B3F1B3B79310013E67E /* EZAudioUtilities.m */; };
|
||||
66755B591B3B79310013E67E /* EZMicrophone.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755B411B3B79310013E67E /* EZMicrophone.m */; };
|
||||
66755B5A1B3B79310013E67E /* EZOutput.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755B431B3B79310013E67E /* EZOutput.m */; };
|
||||
@@ -75,8 +74,6 @@
|
||||
66755B391B3B79310013E67E /* EZAudioPlot.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlot.m; sourceTree = "<group>"; };
|
||||
66755B3A1B3B79310013E67E /* EZAudioPlotGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGL.h; sourceTree = "<group>"; };
|
||||
66755B3B1B3B79310013E67E /* EZAudioPlotGL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGL.m; sourceTree = "<group>"; };
|
||||
66755B3C1B3B79310013E67E /* EZAudioPlotGLKViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGLKViewController.h; sourceTree = "<group>"; };
|
||||
66755B3D1B3B79310013E67E /* EZAudioPlotGLKViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGLKViewController.m; sourceTree = "<group>"; };
|
||||
66755B3E1B3B79310013E67E /* EZAudioUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioUtilities.h; sourceTree = "<group>"; };
|
||||
66755B3F1B3B79310013E67E /* EZAudioUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioUtilities.m; sourceTree = "<group>"; };
|
||||
66755B401B3B79310013E67E /* EZMicrophone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZMicrophone.h; sourceTree = "<group>"; };
|
||||
@@ -169,8 +166,6 @@
|
||||
66755B391B3B79310013E67E /* EZAudioPlot.m */,
|
||||
66755B3A1B3B79310013E67E /* EZAudioPlotGL.h */,
|
||||
66755B3B1B3B79310013E67E /* EZAudioPlotGL.m */,
|
||||
66755B3C1B3B79310013E67E /* EZAudioPlotGLKViewController.h */,
|
||||
66755B3D1B3B79310013E67E /* EZAudioPlotGLKViewController.m */,
|
||||
66755B3E1B3B79310013E67E /* EZAudioUtilities.h */,
|
||||
66755B3F1B3B79310013E67E /* EZAudioUtilities.m */,
|
||||
66755B401B3B79310013E67E /* EZMicrophone.h */,
|
||||
@@ -394,7 +389,6 @@
|
||||
66755B541B3B79310013E67E /* EZAudioPlayer.m in Sources */,
|
||||
941D72211864C4D7007D52D8 /* PassThroughViewController.m in Sources */,
|
||||
66755B561B3B79310013E67E /* EZAudioPlotGL.m in Sources */,
|
||||
66755B571B3B79310013E67E /* EZAudioPlotGLKViewController.m in Sources */,
|
||||
66755B511B3B79310013E67E /* EZAudioFile.m in Sources */,
|
||||
66755B5A1B3B79310013E67E /* EZOutput.m in Sources */,
|
||||
66755B581B3B79310013E67E /* EZAudioUtilities.m in Sources */,
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@
|
||||
*/
|
||||
#import "EZAudio.h"
|
||||
|
||||
@interface PassThroughViewController : NSViewController <EZMicrophoneDelegate,EZOutputDataSource>
|
||||
@interface PassThroughViewController : NSViewController <EZMicrophoneDelegate>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Components
|
||||
|
||||
-6
@@ -17,7 +17,6 @@
|
||||
66755AA91B3B791C0013E67E /* EZAudioPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755A8C1B3B791C0013E67E /* EZAudioPlayer.m */; };
|
||||
66755AAA1B3B791C0013E67E /* EZAudioPlot.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755A8E1B3B791C0013E67E /* EZAudioPlot.m */; };
|
||||
66755AAB1B3B791C0013E67E /* EZAudioPlotGL.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755A901B3B791C0013E67E /* EZAudioPlotGL.m */; };
|
||||
66755AAC1B3B791C0013E67E /* EZAudioPlotGLKViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755A921B3B791C0013E67E /* EZAudioPlotGLKViewController.m */; };
|
||||
66755AAD1B3B791C0013E67E /* EZAudioUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755A941B3B791C0013E67E /* EZAudioUtilities.m */; };
|
||||
66755AAE1B3B791C0013E67E /* EZMicrophone.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755A961B3B791C0013E67E /* EZMicrophone.m */; };
|
||||
66755AAF1B3B791C0013E67E /* EZOutput.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755A981B3B791C0013E67E /* EZOutput.m */; };
|
||||
@@ -77,8 +76,6 @@
|
||||
66755A8E1B3B791C0013E67E /* EZAudioPlot.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlot.m; sourceTree = "<group>"; };
|
||||
66755A8F1B3B791C0013E67E /* EZAudioPlotGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGL.h; sourceTree = "<group>"; };
|
||||
66755A901B3B791C0013E67E /* EZAudioPlotGL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGL.m; sourceTree = "<group>"; };
|
||||
66755A911B3B791C0013E67E /* EZAudioPlotGLKViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGLKViewController.h; sourceTree = "<group>"; };
|
||||
66755A921B3B791C0013E67E /* EZAudioPlotGLKViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGLKViewController.m; sourceTree = "<group>"; };
|
||||
66755A931B3B791C0013E67E /* EZAudioUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioUtilities.h; sourceTree = "<group>"; };
|
||||
66755A941B3B791C0013E67E /* EZAudioUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioUtilities.m; sourceTree = "<group>"; };
|
||||
66755A951B3B791C0013E67E /* EZMicrophone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZMicrophone.h; sourceTree = "<group>"; };
|
||||
@@ -171,8 +168,6 @@
|
||||
66755A8E1B3B791C0013E67E /* EZAudioPlot.m */,
|
||||
66755A8F1B3B791C0013E67E /* EZAudioPlotGL.h */,
|
||||
66755A901B3B791C0013E67E /* EZAudioPlotGL.m */,
|
||||
66755A911B3B791C0013E67E /* EZAudioPlotGLKViewController.h */,
|
||||
66755A921B3B791C0013E67E /* EZAudioPlotGLKViewController.m */,
|
||||
66755A931B3B791C0013E67E /* EZAudioUtilities.h */,
|
||||
66755A941B3B791C0013E67E /* EZAudioUtilities.m */,
|
||||
66755A951B3B791C0013E67E /* EZMicrophone.h */,
|
||||
@@ -398,7 +393,6 @@
|
||||
66755AA91B3B791C0013E67E /* EZAudioPlayer.m in Sources */,
|
||||
94056F31185BD86D00EB94BA /* PlayFileViewController.m in Sources */,
|
||||
66755AAB1B3B791C0013E67E /* EZAudioPlotGL.m in Sources */,
|
||||
66755AAC1B3B791C0013E67E /* EZAudioPlotGLKViewController.m in Sources */,
|
||||
66755AA61B3B791C0013E67E /* EZAudioFile.m in Sources */,
|
||||
66755AAF1B3B791C0013E67E /* EZOutput.m in Sources */,
|
||||
66755AAD1B3B791C0013E67E /* EZAudioUtilities.m in Sources */,
|
||||
|
||||
+34
-13
@@ -36,18 +36,24 @@
|
||||
/**
|
||||
Using the EZOutputDataSource to provide output data to the EZOutput component.
|
||||
*/
|
||||
@interface PlayFileViewController : NSViewController <NSOpenSavePanelDelegate,EZAudioFileDelegate,EZOutputDataSource>
|
||||
@interface PlayFileViewController : NSViewController <NSOpenSavePanelDelegate,
|
||||
EZAudioPlayerDelegate>
|
||||
|
||||
#pragma mark - Components
|
||||
/**
|
||||
The EZAudioFile representing of the currently selected audio file
|
||||
*/
|
||||
@property (nonatomic,strong) EZAudioFile *audioFile;
|
||||
@property (nonatomic, strong) EZAudioFile *audioFile;
|
||||
|
||||
/**
|
||||
The EZOutput component used to output the audio file's audio data.
|
||||
*/
|
||||
@property (nonatomic, strong) EZAudioPlayer *player;
|
||||
|
||||
/**
|
||||
The CoreGraphics based audio plot
|
||||
*/
|
||||
@property (nonatomic, weak) IBOutlet EZAudioPlot *audioPlot;
|
||||
@property (nonatomic, weak) IBOutlet EZAudioPlotGL *audioPlot;
|
||||
|
||||
#pragma mark - UI Extras
|
||||
/**
|
||||
@@ -56,7 +62,12 @@
|
||||
@property (nonatomic, weak) IBOutlet NSTextField *filePathLabel;
|
||||
|
||||
/**
|
||||
<#Description#>
|
||||
A checkbox button to that allows you to specify if the audio player should loop.
|
||||
*/
|
||||
@property (nonatomic, weak) IBOutlet NSButton *loopCheckboxButton;
|
||||
|
||||
/**
|
||||
A label to display the audio file's current position.
|
||||
*/
|
||||
@property (nonatomic, weak) IBOutlet NSTextField *positionLabel;
|
||||
|
||||
@@ -66,36 +77,36 @@
|
||||
@property (nonatomic, weak) IBOutlet NSSlider *positionSlider;
|
||||
|
||||
/**
|
||||
<#Description#>
|
||||
A label to display the value of the rolling history length of the audio plot.
|
||||
*/
|
||||
@property (nonatomic, weak) IBOutlet NSTextField *rollingHistoryLengthLabel;
|
||||
|
||||
/**
|
||||
<#Description#>
|
||||
A slider to adjust the rolling history length of the audio plot.
|
||||
*/
|
||||
@property (nonatomic, weak) IBOutlet NSSlider *rollingHistoryLengthSlider;
|
||||
|
||||
/**
|
||||
A slider to adjust the sample rate.
|
||||
A slider to adjust the volume.
|
||||
*/
|
||||
@property (nonatomic, weak) IBOutlet NSSlider *sampleRateSlider;
|
||||
@property (nonatomic, weak) IBOutlet NSSlider *volumeSlider;
|
||||
|
||||
/**
|
||||
A slider to adjust the sample rate.
|
||||
A label to display the volume of the audio plot.
|
||||
*/
|
||||
@property (nonatomic, weak) IBOutlet NSTextField *sampleRateLabel;
|
||||
@property (nonatomic, weak) IBOutlet NSTextField *volumeLabel;
|
||||
|
||||
/**
|
||||
A BOOL indicating whether or not we've reached the end of the file
|
||||
*/
|
||||
@property (nonatomic,assign) BOOL eof;
|
||||
|
||||
#pragma mark - Actions
|
||||
/**
|
||||
Changes the sampling frequency on the output unit
|
||||
The microphone pop up button (contains the menu for choosing a microphone input)
|
||||
*/
|
||||
-(IBAction)changeOutputSamplingFrequency:(id)sender;
|
||||
@property (nonatomic, weak) IBOutlet NSPopUpButton *outputDevicePopUpButton;
|
||||
|
||||
#pragma mark - Actions
|
||||
/**
|
||||
Switches the plot drawing type between a buffer plot (visualizes the current stream of audio data from the update function) or a rolling plot (visualizes the audio data over time, this is the classic waveform look)
|
||||
*/
|
||||
@@ -106,6 +117,16 @@
|
||||
*/
|
||||
- (IBAction)changeRollingHistoryLength:(id)sender;
|
||||
|
||||
/**
|
||||
Switches the loop state on the audio player regarding whether the current playing audio file should loop back to the beginning when it finishes.
|
||||
*/
|
||||
- (IBAction)changeShouldLoop:(id)sender;
|
||||
|
||||
/**
|
||||
Changes the volume of the audio coming out of the EZOutput.
|
||||
*/
|
||||
- (IBAction)changeVolume:(id)sender;
|
||||
|
||||
/**
|
||||
Prompts the file manager and loads in a new audio file into the EZAudioFile representation.
|
||||
*/
|
||||
|
||||
+172
-64
@@ -32,6 +32,15 @@
|
||||
|
||||
@implementation PlayFileViewController
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Dealloc
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Customize the Audio Plot
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -52,22 +61,107 @@
|
||||
// Mirror
|
||||
self.audioPlot.shouldMirror = YES;
|
||||
|
||||
//
|
||||
// Create EZOutput to play audio data
|
||||
//
|
||||
self.player = [EZAudioPlayer audioPlayerWithDelegate:self];
|
||||
self.player.shouldLoop = YES;
|
||||
|
||||
//
|
||||
// Reload the menu for the output device selector popup button
|
||||
//
|
||||
[self reloadOutputDevicePopUpButtonMenu];
|
||||
|
||||
//
|
||||
// Configure UI components
|
||||
//
|
||||
self.rollingHistoryLengthSlider.intValue = self.audioPlot.rollingHistoryLength;
|
||||
self.rollingHistoryLengthLabel.intValue = self.audioPlot.rollingHistoryLength;
|
||||
self.volumeSlider.floatValue = [self.player volume];
|
||||
self.volumeLabel.floatValue = [self.player volume];
|
||||
self.rollingHistoryLengthSlider.intValue = [self.audioPlot rollingHistoryLength];
|
||||
self.rollingHistoryLengthLabel.intValue = [self.audioPlot rollingHistoryLength];
|
||||
self.loopCheckboxButton.state = [self.player shouldLoop];
|
||||
|
||||
//
|
||||
// Listen for state changes to the EZAudioPlayer
|
||||
//
|
||||
[self setupNotifications];
|
||||
|
||||
//
|
||||
// Try opening the sample file
|
||||
//
|
||||
[self openFileWithFilePathURL:[NSURL fileURLWithPath:kAudioFileDefault]];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Notifications
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)setupNotifications
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(audioPlayerDidChangeAudioFile:)
|
||||
name:EZAudioPlayerDidChangeAudioFileNotification
|
||||
object:self.player];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(audioPlayerDidChangeOutputDevice:)
|
||||
name:EZAudioPlayerDidChangeOutputDeviceNotification
|
||||
object:self.player];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(audioPlayerDidChangePlayState:)
|
||||
name:EZAudioPlayerDidChangePlayStateNotification
|
||||
object:self.player];
|
||||
|
||||
// This notification will only trigger if the player's shouldLoop property is set to NO
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(audioPlayerDidReachEndOfFile:)
|
||||
name:EZAudioPlayerDidReachEndOfFileNotification
|
||||
object:self.player];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)audioPlayerDidChangeAudioFile:(NSNotification *)notification
|
||||
{
|
||||
EZAudioPlayer *player = [notification object];
|
||||
NSLog(@"Player changed audio file: %@", [player audioFile]);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)audioPlayerDidChangeOutputDevice:(NSNotification *)notification
|
||||
{
|
||||
EZAudioPlayer *player = [notification object];
|
||||
NSLog(@"Player changed output device: %@", [player device]);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)audioPlayerDidChangePlayState:(NSNotification *)notification
|
||||
{
|
||||
EZAudioPlayer *player = [notification object];
|
||||
NSLog(@"Player change play state, isPlaying: %i", [player isPlaying]);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)audioPlayerDidReachEndOfFile:(NSNotification *)notification
|
||||
{
|
||||
NSLog(@"Player did reach end of file!");
|
||||
[self.playButton setState:NSOffState];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Actions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)changedOutput:(NSMenuItem *)item
|
||||
{
|
||||
EZAudioDevice *device = [item representedObject];
|
||||
[self.player setDevice:device];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)changePlotType:(id)sender
|
||||
{
|
||||
NSInteger selectedSegment = [sender selectedSegment];
|
||||
@@ -86,13 +180,19 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)changeOutputSamplingFrequency:(id)sender
|
||||
- (void)changeShouldLoop:(id)sender
|
||||
{
|
||||
float sampleRate = ((NSSlider *)sender).floatValue;
|
||||
AudioStreamBasicDescription asbd = [[EZOutput sharedOutput] audioStreamBasicDescription];
|
||||
asbd.mSampleRate = sampleRate;
|
||||
[[EZOutput sharedOutput] setAudioStreamBasicDescription:asbd];
|
||||
self.sampleRateLabel.floatValue = sampleRate;
|
||||
NSInteger state = [(NSButton *)sender state];
|
||||
[self.player setShouldLoop:state];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)changeVolume:(id)sender
|
||||
{
|
||||
float value = [(NSSlider *)sender floatValue];
|
||||
[self.player setVolume:value];
|
||||
self.volumeLabel.floatValue = value;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -123,7 +223,7 @@
|
||||
|
||||
-(void)play:(id)sender
|
||||
{
|
||||
if (![[EZOutput sharedOutput] isPlaying])
|
||||
if (![self.player isPlaying])
|
||||
{
|
||||
if (self.eof)
|
||||
{
|
||||
@@ -133,13 +233,11 @@
|
||||
{
|
||||
self.audioPlot.plotType = EZPlotTypeRolling;
|
||||
}
|
||||
[EZOutput sharedOutput].outputDataSource = self;
|
||||
[[EZOutput sharedOutput] startPlayback];
|
||||
[self.player play];
|
||||
}
|
||||
else
|
||||
{
|
||||
[EZOutput sharedOutput].outputDataSource = nil;
|
||||
[[EZOutput sharedOutput] stopPlayback];
|
||||
[self.player pause];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +246,7 @@
|
||||
-(void)seekToFrame:(id)sender
|
||||
{
|
||||
double value = [(NSSlider*)sender doubleValue];
|
||||
[self.audioFile seekToFrame:(SInt64)value];
|
||||
[self.player seekToFrame:(SInt64)value];
|
||||
self.positionLabel.doubleValue = value;
|
||||
}
|
||||
|
||||
@@ -191,17 +289,17 @@
|
||||
//
|
||||
// Stop playback
|
||||
//
|
||||
[[EZOutput sharedOutput] stopPlayback];
|
||||
[self.player pause];
|
||||
|
||||
//
|
||||
// Clear the audio plot
|
||||
//
|
||||
// [self.audioPlot clear];
|
||||
[self.audioPlot clear];
|
||||
|
||||
//
|
||||
// Load the audio file and customize the UI
|
||||
//
|
||||
self.audioFile = [EZAudioFile audioFileWithURL:filePathURL delegate:self];
|
||||
self.audioFile = [EZAudioFile audioFileWithURL:filePathURL];
|
||||
self.eof = NO;
|
||||
self.filePathLabel.stringValue = filePathURL.lastPathComponent;
|
||||
self.positionSlider.minValue = 0.0f;
|
||||
@@ -209,88 +307,98 @@
|
||||
self.playButton.state = NSOffState;
|
||||
self.plotSegmentControl.selectedSegment = 1;
|
||||
|
||||
//
|
||||
// Set the client format from the EZAudioFile on the output
|
||||
//
|
||||
Float64 sampleRate = self.audioFile.clientFormat.mSampleRate;
|
||||
self.sampleRateSlider.floatValue = sampleRate;
|
||||
self.sampleRateLabel.floatValue = sampleRate;
|
||||
[[EZOutput sharedOutput] setAudioStreamBasicDescription:self.audioFile.clientFormat];
|
||||
|
||||
//
|
||||
// Change back to a buffer plot, but mirror and fill the waveform
|
||||
//
|
||||
self.audioPlot.plotType = EZPlotTypeBuffer;
|
||||
self.audioPlot.shouldFill = YES;
|
||||
self.audioPlot.shouldMirror = YES;
|
||||
[self.audioPlot clear];
|
||||
|
||||
//
|
||||
// Plot the whole waveform
|
||||
//
|
||||
__weak typeof (self) weakSelf = self;
|
||||
[self.audioFile getWaveformDataWithNumberOfPoints:256
|
||||
[self.audioFile getWaveformDataWithNumberOfPoints:1024
|
||||
completion:^(float **waveformData,
|
||||
int length)
|
||||
{
|
||||
[weakSelf.audioPlot updateBuffer:waveformData[0]
|
||||
withBufferSize:length];
|
||||
}];
|
||||
|
||||
//
|
||||
// Play the audio file
|
||||
//
|
||||
[self.player setAudioFile:self.audioFile];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - EZAudioFileDelegate
|
||||
|
||||
- (void)reloadOutputDevicePopUpButtonMenu
|
||||
{
|
||||
NSArray *outputDevices = [EZAudioDevice outputDevices];
|
||||
NSMenu *menu = [[NSMenu alloc] init];
|
||||
NSMenuItem *defaultOutputDeviceItem;
|
||||
for (EZAudioDevice *device in outputDevices)
|
||||
{
|
||||
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:device.name
|
||||
action:@selector(changedOutput:)
|
||||
keyEquivalent:@""];
|
||||
item.representedObject = device;
|
||||
item.target = self;
|
||||
[menu addItem:item];
|
||||
|
||||
// If this device is the same one the microphone is using then
|
||||
// we will use this menu item as the currently selected item
|
||||
// in the microphone input popup button's list of items. For instance,
|
||||
// if you are connected to an external display by default the external
|
||||
// display's microphone might be used instead of the mac's built in
|
||||
// mic.
|
||||
if ([device isEqual:[self.player device]])
|
||||
{
|
||||
defaultOutputDeviceItem = item;
|
||||
}
|
||||
}
|
||||
self.outputDevicePopUpButton.menu = menu;
|
||||
|
||||
//
|
||||
// Set the selected device to the current selection on the
|
||||
// microphone input popup button
|
||||
//
|
||||
[self.outputDevicePopUpButton selectItem:defaultOutputDeviceItem];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - EZAudioPlayerDelegate
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
-(void) audioFile:(EZAudioFile *)audioFile
|
||||
readAudio:(float **)buffer
|
||||
- (void) audioPlayer:(EZAudioPlayer *)audioPlayer
|
||||
playedAudio:(float **)buffer
|
||||
withBufferSize:(UInt32)bufferSize
|
||||
withNumberOfChannels:(UInt32)numberOfChannels
|
||||
inAudioFile:(EZAudioFile *)audioFile
|
||||
{
|
||||
if ([[EZOutput sharedOutput] isPlaying])
|
||||
{
|
||||
__weak typeof (self) weakSelf = self;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[weakSelf.audioPlot updateBuffer:buffer[0]
|
||||
withBufferSize:bufferSize];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
-(void)audioFile:(EZAudioFile *)audioFile
|
||||
updatedPosition:(SInt64)framePosition {
|
||||
__weak typeof (self) weakSelf = self;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (![weakSelf.positionSlider.cell isHighlighted])
|
||||
{
|
||||
weakSelf.positionSlider.floatValue = (float)framePosition;
|
||||
weakSelf.positionLabel.floatValue = (float)framePosition;
|
||||
}
|
||||
[weakSelf.audioPlot updateBuffer:buffer[0]
|
||||
withBufferSize:bufferSize];
|
||||
});
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - EZOutputDataSource
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
-(void) output:(EZOutput *)output
|
||||
shouldFillAudioBufferList:(AudioBufferList *)audioBufferList
|
||||
withNumberOfFrames:(UInt32)frames
|
||||
- (void)audioPlayer:(EZAudioPlayer *)audioPlayer
|
||||
updatedPosition:(SInt64)framePosition
|
||||
inAudioFile:(EZAudioFile *)audioFile
|
||||
{
|
||||
if (self.audioFile)
|
||||
{
|
||||
UInt32 bufferSize;
|
||||
[self.audioFile readFrames:frames
|
||||
audioBufferList:audioBufferList
|
||||
bufferSize:&bufferSize
|
||||
eof:&_eof];
|
||||
if (_eof)
|
||||
__weak typeof (self) weakSelf = self;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (!weakSelf.positionSlider.highlighted)
|
||||
{
|
||||
[self seekToFrame:0];
|
||||
weakSelf.positionSlider.floatValue = (float)framePosition;
|
||||
weakSelf.positionLabel.integerValue = framePosition;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
+100
-50
@@ -1,23 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7702" systemVersion="14C109" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment version="1070" identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7702"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7706"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="PlayFileViewController">
|
||||
<connections>
|
||||
<outlet property="audioPlot" destination="Lz1-Gs-1lD" id="V5w-yH-ZVR"/>
|
||||
<outlet property="checkboxButton" destination="5xb-MK-C8b" id="fx2-y9-qXH"/>
|
||||
<outlet property="filePathLabel" destination="0eT-7c-7fJ" id="IGv-mA-5Hw"/>
|
||||
<outlet property="loopCheckboxButton" destination="5xb-MK-C8b" id="Rlt-Z9-Zy8"/>
|
||||
<outlet property="outputDevicePopUpButton" destination="0LV-Bi-dGz" id="QTQ-qq-Ro8"/>
|
||||
<outlet property="playButton" destination="OQp-Lr-dlS" id="K5R-Qg-7DY"/>
|
||||
<outlet property="plotSegmentControl" destination="bZW-tA-C61" id="4ic-Ou-qh2"/>
|
||||
<outlet property="positionLabel" destination="KYm-Io-VNv" id="Fhs-Ya-szS"/>
|
||||
<outlet property="positionSlider" destination="CFP-v0-TzQ" id="EGD-qT-48R"/>
|
||||
<outlet property="rollingHistoryLengthLabel" destination="vKe-ey-hXI" id="UiN-5S-TOn"/>
|
||||
<outlet property="rollingHistoryLengthSlider" destination="vj5-qT-JkR" id="sEj-iE-yTV"/>
|
||||
<outlet property="sampleRateLabel" destination="3ul-3w-l3S" id="5CA-Au-tFa"/>
|
||||
<outlet property="sampleRateSlider" destination="rRH-oS-VV3" id="8ij-Ff-CZK"/>
|
||||
<outlet property="view" destination="Xpo-HP-Ost" id="zlj-bW-4iz"/>
|
||||
<outlet property="volumeLabel" destination="3ul-3w-l3S" id="sXM-mC-tN0"/>
|
||||
<outlet property="volumeSlider" destination="rRH-oS-VV3" id="kql-X5-amB"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
@@ -26,8 +29,8 @@
|
||||
<rect key="frame" x="0.0" y="-1" width="480" height="366"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<customView translatesAutoresizingMaskIntoConstraints="NO" id="Lz1-Gs-1lD" customClass="EZAudioPlot">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="210"/>
|
||||
<customView translatesAutoresizingMaskIntoConstraints="NO" id="Lz1-Gs-1lD" customClass="EZAudioPlotGL">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="146"/>
|
||||
</customView>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="2Ma-jj-U3z">
|
||||
<rect key="frame" x="12" y="320" width="125" height="32"/>
|
||||
@@ -74,22 +77,22 @@
|
||||
</connections>
|
||||
</segmentedControl>
|
||||
<slider verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="CFP-v0-TzQ">
|
||||
<rect key="frame" x="117" y="242" width="330" height="20"/>
|
||||
<rect key="frame" x="117" y="242" width="269" height="20"/>
|
||||
<sliderCell key="cell" continuous="YES" alignment="left" maxValue="100" doubleValue="9.3380614657210401" tickMarkPosition="above" sliderType="linear" id="gPc-pN-dmP"/>
|
||||
<connections>
|
||||
<action selector="seekToFrame:" target="-2" id="iVY-so-6X2"/>
|
||||
</connections>
|
||||
</slider>
|
||||
<slider verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="vj5-qT-JkR">
|
||||
<rect key="frame" x="117" y="217" width="330" height="20"/>
|
||||
<rect key="frame" x="117" y="217" width="269" height="20"/>
|
||||
<sliderCell key="cell" continuous="YES" alignment="left" minValue="128" maxValue="1024" doubleValue="128" tickMarkPosition="above" sliderType="linear" id="uRZ-Kf-cgJ"/>
|
||||
<connections>
|
||||
<action selector="changeRollingHistoryLength:" target="-2" id="eYD-H1-n52"/>
|
||||
</connections>
|
||||
</slider>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="7AB-VA-xL3">
|
||||
<rect key="frame" x="16" y="269" width="85" height="16"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="Sample Rate:" id="GAa-Hp-OlV">
|
||||
<rect key="frame" x="16" y="269" width="53" height="16"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="Volume:" id="GAa-Hp-OlV">
|
||||
<font key="font" metaFont="systemBold" size="12"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
@@ -112,9 +115,12 @@
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="3ul-3w-l3S">
|
||||
<rect key="frame" x="452" y="269" width="12" height="16"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="0" id="vlK-Hb-Yca">
|
||||
<numberFormatter key="formatter" formatterBehavior="custom10_4" minimumIntegerDigits="0" maximumIntegerDigits="42" id="bBU-vS-tEB">
|
||||
<rect key="frame" x="390" y="269" width="72" height="16"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="68" id="eyi-2x-AqF"/>
|
||||
</constraints>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="0.00" id="vlK-Hb-Yca">
|
||||
<numberFormatter key="formatter" formatterBehavior="custom10_4" minimumIntegerDigits="1" maximumIntegerDigits="1" minimumFractionDigits="2" maximumFractionDigits="2" id="bBU-vS-tEB">
|
||||
<metadata>
|
||||
<real key="inspectorSampleValue" value="44"/>
|
||||
</metadata>
|
||||
@@ -125,28 +131,18 @@
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<slider verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="rRH-oS-VV3">
|
||||
<rect key="frame" x="117" y="267" width="330" height="20"/>
|
||||
<sliderCell key="cell" state="on" alignment="left" minValue="8000" maxValue="88200" doubleValue="44100" tickMarkPosition="above" sliderType="linear" id="xbX-Ce-da5"/>
|
||||
<rect key="frame" x="117" y="267" width="269" height="20"/>
|
||||
<sliderCell key="cell" continuous="YES" state="on" alignment="left" maxValue="1" doubleValue="0.5" tickMarkPosition="above" sliderType="linear" id="xbX-Ce-da5"/>
|
||||
<connections>
|
||||
<action selector="changeOutputSamplingFrequency:" target="-2" id="yWM-Ei-ztA"/>
|
||||
<action selector="changeVolume:" target="-2" id="iKx-7d-34D"/>
|
||||
</connections>
|
||||
</slider>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="KYm-Io-VNv">
|
||||
<rect key="frame" x="452" y="244" width="12" height="16"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="0" id="gfS-wb-pFu">
|
||||
<numberFormatter key="formatter" formatterBehavior="custom10_4" minimumIntegerDigits="0" maximumIntegerDigits="42" id="py5-BY-fQN">
|
||||
<metadata>
|
||||
<real key="inspectorSampleValue" value="44"/>
|
||||
</metadata>
|
||||
</numberFormatter>
|
||||
<font key="font" metaFont="cellTitle"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="vKe-ey-hXI">
|
||||
<rect key="frame" x="451" y="219" width="12" height="16"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="0" id="JiA-3H-vb2">
|
||||
<rect key="frame" x="390" y="219" width="72" height="16"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="68" id="7dV-vH-IBh"/>
|
||||
</constraints>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="0" id="JiA-3H-vb2">
|
||||
<numberFormatter key="formatter" formatterBehavior="custom10_4" minimumIntegerDigits="0" maximumIntegerDigits="42" id="AYM-Tu-k5w">
|
||||
<metadata>
|
||||
<real key="inspectorSampleValue" value="44"/>
|
||||
@@ -157,45 +153,99 @@
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="0LV-Bi-dGz" userLabel="microphoneInputPopUpButton">
|
||||
<rect key="frame" x="16" y="161" width="180" height="26"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="175" id="fDF-j7-LMD"/>
|
||||
</constraints>
|
||||
<popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="a7m-V2-Mw8" id="VLU-oW-zia">
|
||||
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="menu"/>
|
||||
<menu key="menu" id="uLv-18-vra">
|
||||
<items>
|
||||
<menuItem title="Item 1" state="on" id="a7m-V2-Mw8"/>
|
||||
<menuItem title="Item 2" id="qJe-zH-SrZ"/>
|
||||
<menuItem title="Item 3" id="zlE-dQ-R4x"/>
|
||||
</items>
|
||||
</menu>
|
||||
</popUpButtonCell>
|
||||
</popUpButton>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="RRH-G6-xkQ">
|
||||
<rect key="frame" x="16" y="194" width="50" height="16"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Output:" id="2OQ-1o-1vp">
|
||||
<font key="font" metaFont="systemBold" size="12"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="KYm-Io-VNv">
|
||||
<rect key="frame" x="390" y="244" width="72" height="16"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="68" id="fOV-38-VqQ"/>
|
||||
</constraints>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="0" id="gfS-wb-pFu">
|
||||
<numberFormatter key="formatter" formatterBehavior="custom10_4" minimumIntegerDigits="0" maximumIntegerDigits="42" id="py5-BY-fQN">
|
||||
<metadata>
|
||||
<real key="inspectorSampleValue" value="44"/>
|
||||
</metadata>
|
||||
</numberFormatter>
|
||||
<font key="font" metaFont="cellTitle"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<button translatesAutoresizingMaskIntoConstraints="NO" id="5xb-MK-C8b">
|
||||
<rect key="frame" x="410" y="162" width="54" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="Loop" bezelStyle="regularSquare" imagePosition="right" state="on" inset="2" id="O83-sN-k0z">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="changeShouldLoop:" target="-2" id="lJN-Pe-JWA"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="CFP-v0-TzQ" firstAttribute="baseline" secondItem="Fw5-pm-4w0" secondAttribute="baseline" id="5Iy-Vv-CQo"/>
|
||||
<constraint firstItem="vKe-ey-hXI" firstAttribute="leading" secondItem="vj5-qT-JkR" secondAttribute="trailing" constant="8" symbolic="YES" id="7ZR-wn-RFM"/>
|
||||
<constraint firstItem="vj5-qT-JkR" firstAttribute="trailing" secondItem="CFP-v0-TzQ" secondAttribute="trailing" id="7rr-13-nCn"/>
|
||||
<constraint firstItem="vKe-ey-hXI" firstAttribute="baseline" secondItem="vj5-qT-JkR" secondAttribute="baseline" id="9n9-7Q-Uc5"/>
|
||||
<constraint firstItem="vKe-ey-hXI" firstAttribute="baseline" secondItem="vj5-qT-JkR" secondAttribute="baseline" id="03u-fe-Q2r"/>
|
||||
<constraint firstItem="vj5-qT-JkR" firstAttribute="leading" secondItem="Aa9-nc-WHJ" secondAttribute="trailing" constant="9" id="0QT-jZ-rPL"/>
|
||||
<constraint firstItem="rRH-oS-VV3" firstAttribute="baseline" secondItem="7AB-VA-xL3" secondAttribute="baseline" id="4WU-L2-5TI"/>
|
||||
<constraint firstItem="3ul-3w-l3S" firstAttribute="trailing" secondItem="bZW-tA-C61" secondAttribute="trailing" constant="-2" id="75o-B9-UmY"/>
|
||||
<constraint firstItem="vj5-qT-JkR" firstAttribute="baseline" secondItem="Aa9-nc-WHJ" secondAttribute="baseline" id="8ia-fE-3Ej"/>
|
||||
<constraint firstItem="Lz1-Gs-1lD" firstAttribute="top" secondItem="5xb-MK-C8b" secondAttribute="bottom" constant="18" id="CG6-jk-Mmj"/>
|
||||
<constraint firstAttribute="bottom" secondItem="Lz1-Gs-1lD" secondAttribute="bottom" id="Cdp-xg-Udu"/>
|
||||
<constraint firstItem="rRH-oS-VV3" firstAttribute="baseline" secondItem="3ul-3w-l3S" secondAttribute="baseline" id="E1v-Nu-5O1"/>
|
||||
<constraint firstItem="0eT-7c-7fJ" firstAttribute="leading" secondItem="2Ma-jj-U3z" secondAttribute="trailing" constant="11" id="F4y-lz-2p6"/>
|
||||
<constraint firstItem="7AB-VA-xL3" firstAttribute="top" secondItem="OQp-Lr-dlS" secondAttribute="bottom" constant="9" id="GbY-7Z-81V"/>
|
||||
<constraint firstItem="Lz1-Gs-1lD" firstAttribute="leading" secondItem="Xpo-HP-Ost" secondAttribute="leading" id="HW1-t3-mGg"/>
|
||||
<constraint firstItem="OQp-Lr-dlS" firstAttribute="leading" secondItem="2Ma-jj-U3z" secondAttribute="leading" id="Ira-0b-xzU"/>
|
||||
<constraint firstItem="7AB-VA-xL3" firstAttribute="baseline" secondItem="rRH-oS-VV3" secondAttribute="baseline" id="LQV-fR-ji0"/>
|
||||
<constraint firstItem="CFP-v0-TzQ" firstAttribute="leading" secondItem="vj5-qT-JkR" secondAttribute="leading" id="May-qJ-5nB"/>
|
||||
<constraint firstItem="3ul-3w-l3S" firstAttribute="trailing" secondItem="bZW-tA-C61" secondAttribute="trailing" id="Opz-An-TkJ"/>
|
||||
<constraint firstItem="rRH-oS-VV3" firstAttribute="baseline" secondItem="3ul-3w-l3S" secondAttribute="baseline" id="KOD-cZ-e52"/>
|
||||
<constraint firstItem="CFP-v0-TzQ" firstAttribute="baseline" secondItem="Fw5-pm-4w0" secondAttribute="baseline" id="PbC-KG-EzE"/>
|
||||
<constraint firstItem="2Ma-jj-U3z" firstAttribute="leading" secondItem="Xpo-HP-Ost" secondAttribute="leading" constant="18" id="PiQ-KC-eta"/>
|
||||
<constraint firstItem="Fw5-pm-4w0" firstAttribute="top" secondItem="7AB-VA-xL3" secondAttribute="bottom" constant="9" id="SPP-F6-chs"/>
|
||||
<constraint firstItem="KYm-Io-VNv" firstAttribute="baseline" secondItem="CFP-v0-TzQ" secondAttribute="baseline" id="agk-Cm-yAm"/>
|
||||
<constraint firstItem="vj5-qT-JkR" firstAttribute="trailing" secondItem="CFP-v0-TzQ" secondAttribute="trailing" id="URd-7z-JBO"/>
|
||||
<constraint firstAttribute="trailing" secondItem="5xb-MK-C8b" secondAttribute="trailing" constant="18" id="WdY-l2-cmp"/>
|
||||
<constraint firstItem="RRH-G6-xkQ" firstAttribute="leading" secondItem="Xpo-HP-Ost" secondAttribute="leading" constant="18" id="WiW-CU-B7N"/>
|
||||
<constraint firstAttribute="trailing" secondItem="Lz1-Gs-1lD" secondAttribute="trailing" id="ay9-Mt-iFx"/>
|
||||
<constraint firstItem="vj5-qT-JkR" firstAttribute="baseline" secondItem="Aa9-nc-WHJ" secondAttribute="baseline" id="cBS-XB-jof"/>
|
||||
<constraint firstAttribute="trailing" secondItem="KYm-Io-VNv" secondAttribute="trailing" constant="18" id="cRX-mp-xiq"/>
|
||||
<constraint firstItem="rRH-oS-VV3" firstAttribute="leading" secondItem="CFP-v0-TzQ" secondAttribute="leading" id="cWn-4f-E04"/>
|
||||
<constraint firstItem="Fw5-pm-4w0" firstAttribute="leading" secondItem="Aa9-nc-WHJ" secondAttribute="leading" id="cnU-xS-2CO"/>
|
||||
<constraint firstItem="KYm-Io-VNv" firstAttribute="leading" secondItem="3ul-3w-l3S" secondAttribute="leading" id="dac-nA-d4U"/>
|
||||
<constraint firstItem="0LV-Bi-dGz" firstAttribute="top" secondItem="RRH-G6-xkQ" secondAttribute="bottom" constant="9" id="dnZ-Rx-iiV"/>
|
||||
<constraint firstItem="Aa9-nc-WHJ" firstAttribute="top" secondItem="Fw5-pm-4w0" secondAttribute="bottom" constant="9" id="fc6-dV-Lxf"/>
|
||||
<constraint firstItem="vKe-ey-hXI" firstAttribute="leading" secondItem="vj5-qT-JkR" secondAttribute="trailing" constant="8" symbolic="YES" id="fuB-es-weU"/>
|
||||
<constraint firstItem="2Ma-jj-U3z" firstAttribute="top" secondItem="Xpo-HP-Ost" secondAttribute="top" constant="18" id="hDY-vI-eWO"/>
|
||||
<constraint firstItem="OQp-Lr-dlS" firstAttribute="trailing" secondItem="2Ma-jj-U3z" secondAttribute="trailing" id="hXB-Gp-9wN"/>
|
||||
<constraint firstAttribute="trailing" secondItem="bZW-tA-C61" secondAttribute="trailing" constant="18" id="iUL-br-ASL"/>
|
||||
<constraint firstAttribute="trailing" secondItem="vKe-ey-hXI" secondAttribute="trailing" constant="19" id="kgc-wp-ndy"/>
|
||||
<constraint firstItem="OQp-Lr-dlS" firstAttribute="top" secondItem="bZW-tA-C61" secondAttribute="top" id="kny-zR-hiF"/>
|
||||
<constraint firstItem="Lz1-Gs-1lD" firstAttribute="top" secondItem="Aa9-nc-WHJ" secondAttribute="bottom" constant="9" id="oZE-Hx-FR4"/>
|
||||
<constraint firstItem="rRH-oS-VV3" firstAttribute="trailing" secondItem="CFP-v0-TzQ" secondAttribute="trailing" id="oa1-ct-9bT"/>
|
||||
<constraint firstItem="Lz1-Gs-1lD" firstAttribute="top" secondItem="0LV-Bi-dGz" secondAttribute="bottom" constant="18" id="l6M-H0-bYA"/>
|
||||
<constraint firstItem="7AB-VA-xL3" firstAttribute="leading" secondItem="OQp-Lr-dlS" secondAttribute="leading" id="omq-Zw-Gvk"/>
|
||||
<constraint firstItem="vj5-qT-JkR" firstAttribute="leading" secondItem="Aa9-nc-WHJ" secondAttribute="trailing" constant="9" id="qa7-m8-7wP"/>
|
||||
<constraint firstAttribute="trailing" secondItem="3ul-3w-l3S" secondAttribute="trailing" constant="18" id="rtO-ix-cUt"/>
|
||||
<constraint firstItem="KYm-Io-VNv" firstAttribute="baseline" secondItem="CFP-v0-TzQ" secondAttribute="baseline" id="q8e-0e-Xqt"/>
|
||||
<constraint firstItem="0eT-7c-7fJ" firstAttribute="top" secondItem="2Ma-jj-U3z" secondAttribute="top" id="snu-Ma-cHX"/>
|
||||
<constraint firstItem="3ul-3w-l3S" firstAttribute="leading" secondItem="KYm-Io-VNv" secondAttribute="leading" id="tKc-D3-J6f"/>
|
||||
<constraint firstItem="OQp-Lr-dlS" firstAttribute="top" secondItem="2Ma-jj-U3z" secondAttribute="bottom" constant="12" symbolic="YES" id="tkR-bR-msf"/>
|
||||
<constraint firstItem="3ul-3w-l3S" firstAttribute="leading" secondItem="rRH-oS-VV3" secondAttribute="trailing" constant="9" id="udS-FO-wJL"/>
|
||||
<constraint firstItem="0LV-Bi-dGz" firstAttribute="leading" secondItem="Xpo-HP-Ost" secondAttribute="leading" constant="18" id="tmm-8d-ldM"/>
|
||||
<constraint firstItem="3ul-3w-l3S" firstAttribute="leading" secondItem="rRH-oS-VV3" secondAttribute="trailing" constant="8" id="uF6-oM-5lN"/>
|
||||
<constraint firstItem="Fw5-pm-4w0" firstAttribute="leading" secondItem="7AB-VA-xL3" secondAttribute="leading" id="vNA-c3-Gcy"/>
|
||||
<constraint firstItem="rRH-oS-VV3" firstAttribute="leading" secondItem="CFP-v0-TzQ" secondAttribute="leading" id="yJz-Qg-823"/>
|
||||
<constraint firstItem="RRH-G6-xkQ" firstAttribute="top" secondItem="Aa9-nc-WHJ" secondAttribute="bottom" constant="9" id="w92-Np-SYg"/>
|
||||
<constraint firstItem="rRH-oS-VV3" firstAttribute="trailing" secondItem="CFP-v0-TzQ" secondAttribute="trailing" id="wdS-Vt-caT"/>
|
||||
<constraint firstItem="vj5-qT-JkR" firstAttribute="leading" secondItem="CFP-v0-TzQ" secondAttribute="leading" id="wek-S9-BzW"/>
|
||||
</constraints>
|
||||
<point key="canvasLocation" x="191" y="409"/>
|
||||
</customView>
|
||||
|
||||
-6
@@ -16,7 +16,6 @@
|
||||
66755AE21B3B79230013E67E /* EZAudioPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755AC51B3B79220013E67E /* EZAudioPlayer.m */; };
|
||||
66755AE31B3B79230013E67E /* EZAudioPlot.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755AC71B3B79220013E67E /* EZAudioPlot.m */; };
|
||||
66755AE41B3B79230013E67E /* EZAudioPlotGL.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755AC91B3B79220013E67E /* EZAudioPlotGL.m */; };
|
||||
66755AE51B3B79230013E67E /* EZAudioPlotGLKViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755ACB1B3B79220013E67E /* EZAudioPlotGLKViewController.m */; };
|
||||
66755AE61B3B79230013E67E /* EZAudioUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755ACD1B3B79220013E67E /* EZAudioUtilities.m */; };
|
||||
66755AE71B3B79230013E67E /* EZMicrophone.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755ACF1B3B79230013E67E /* EZMicrophone.m */; };
|
||||
66755AE81B3B79230013E67E /* EZOutput.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755AD11B3B79230013E67E /* EZOutput.m */; };
|
||||
@@ -76,8 +75,6 @@
|
||||
66755AC71B3B79220013E67E /* EZAudioPlot.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlot.m; sourceTree = "<group>"; };
|
||||
66755AC81B3B79220013E67E /* EZAudioPlotGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGL.h; sourceTree = "<group>"; };
|
||||
66755AC91B3B79220013E67E /* EZAudioPlotGL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGL.m; sourceTree = "<group>"; };
|
||||
66755ACA1B3B79220013E67E /* EZAudioPlotGLKViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGLKViewController.h; sourceTree = "<group>"; };
|
||||
66755ACB1B3B79220013E67E /* EZAudioPlotGLKViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGLKViewController.m; sourceTree = "<group>"; };
|
||||
66755ACC1B3B79220013E67E /* EZAudioUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioUtilities.h; sourceTree = "<group>"; };
|
||||
66755ACD1B3B79220013E67E /* EZAudioUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioUtilities.m; sourceTree = "<group>"; };
|
||||
66755ACE1B3B79230013E67E /* EZMicrophone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZMicrophone.h; sourceTree = "<group>"; };
|
||||
@@ -172,8 +169,6 @@
|
||||
66755AC71B3B79220013E67E /* EZAudioPlot.m */,
|
||||
66755AC81B3B79220013E67E /* EZAudioPlotGL.h */,
|
||||
66755AC91B3B79220013E67E /* EZAudioPlotGL.m */,
|
||||
66755ACA1B3B79220013E67E /* EZAudioPlotGLKViewController.h */,
|
||||
66755ACB1B3B79220013E67E /* EZAudioPlotGLKViewController.m */,
|
||||
66755ACC1B3B79220013E67E /* EZAudioUtilities.h */,
|
||||
66755ACD1B3B79220013E67E /* EZAudioUtilities.m */,
|
||||
66755ACE1B3B79230013E67E /* EZMicrophone.h */,
|
||||
@@ -398,7 +393,6 @@
|
||||
66755AE21B3B79230013E67E /* EZAudioPlayer.m in Sources */,
|
||||
94056E74185BB44200EB94BA /* RecordViewController.m in Sources */,
|
||||
66755AE41B3B79230013E67E /* EZAudioPlotGL.m in Sources */,
|
||||
66755AE51B3B79230013E67E /* EZAudioPlotGLKViewController.m in Sources */,
|
||||
66755ADF1B3B79230013E67E /* EZAudioFile.m in Sources */,
|
||||
66755AE81B3B79230013E67E /* EZOutput.m in Sources */,
|
||||
66755AE61B3B79230013E67E /* EZAudioUtilities.m in Sources */,
|
||||
|
||||
-6
@@ -16,7 +16,6 @@
|
||||
66755B1B1B3B792A0013E67E /* EZAudioPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755AFE1B3B792A0013E67E /* EZAudioPlayer.m */; };
|
||||
66755B1C1B3B792A0013E67E /* EZAudioPlot.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755B001B3B792A0013E67E /* EZAudioPlot.m */; };
|
||||
66755B1D1B3B792A0013E67E /* EZAudioPlotGL.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755B021B3B792A0013E67E /* EZAudioPlotGL.m */; };
|
||||
66755B1E1B3B792A0013E67E /* EZAudioPlotGLKViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755B041B3B792A0013E67E /* EZAudioPlotGLKViewController.m */; };
|
||||
66755B1F1B3B792A0013E67E /* EZAudioUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755B061B3B792A0013E67E /* EZAudioUtilities.m */; };
|
||||
66755B201B3B792A0013E67E /* EZMicrophone.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755B081B3B792A0013E67E /* EZMicrophone.m */; };
|
||||
66755B211B3B792A0013E67E /* EZOutput.m in Sources */ = {isa = PBXBuildFile; fileRef = 66755B0A1B3B792A0013E67E /* EZOutput.m */; };
|
||||
@@ -76,8 +75,6 @@
|
||||
66755B001B3B792A0013E67E /* EZAudioPlot.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlot.m; sourceTree = "<group>"; };
|
||||
66755B011B3B792A0013E67E /* EZAudioPlotGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGL.h; sourceTree = "<group>"; };
|
||||
66755B021B3B792A0013E67E /* EZAudioPlotGL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGL.m; sourceTree = "<group>"; };
|
||||
66755B031B3B792A0013E67E /* EZAudioPlotGLKViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGLKViewController.h; sourceTree = "<group>"; };
|
||||
66755B041B3B792A0013E67E /* EZAudioPlotGLKViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGLKViewController.m; sourceTree = "<group>"; };
|
||||
66755B051B3B792A0013E67E /* EZAudioUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioUtilities.h; sourceTree = "<group>"; };
|
||||
66755B061B3B792A0013E67E /* EZAudioUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioUtilities.m; sourceTree = "<group>"; };
|
||||
66755B071B3B792A0013E67E /* EZMicrophone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZMicrophone.h; sourceTree = "<group>"; };
|
||||
@@ -171,8 +168,6 @@
|
||||
66755B001B3B792A0013E67E /* EZAudioPlot.m */,
|
||||
66755B011B3B792A0013E67E /* EZAudioPlotGL.h */,
|
||||
66755B021B3B792A0013E67E /* EZAudioPlotGL.m */,
|
||||
66755B031B3B792A0013E67E /* EZAudioPlotGLKViewController.h */,
|
||||
66755B041B3B792A0013E67E /* EZAudioPlotGLKViewController.m */,
|
||||
66755B051B3B792A0013E67E /* EZAudioUtilities.h */,
|
||||
66755B061B3B792A0013E67E /* EZAudioUtilities.m */,
|
||||
66755B071B3B792A0013E67E /* EZMicrophone.h */,
|
||||
@@ -398,7 +393,6 @@
|
||||
66755B1B1B3B792A0013E67E /* EZAudioPlayer.m in Sources */,
|
||||
94056E96185BCBC000EB94BA /* AppDelegate.m in Sources */,
|
||||
66755B1D1B3B792A0013E67E /* EZAudioPlotGL.m in Sources */,
|
||||
66755B1E1B3B792A0013E67E /* EZAudioPlotGLKViewController.m in Sources */,
|
||||
66755B181B3B792A0013E67E /* EZAudioFile.m in Sources */,
|
||||
66755B211B3B792A0013E67E /* EZOutput.m in Sources */,
|
||||
66755B1F1B3B792A0013E67E /* EZAudioUtilities.m in Sources */,
|
||||
|
||||
-6
@@ -16,7 +16,6 @@
|
||||
667558A81B3B604B0013E67E /* EZAudioPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 6675588B1B3B604B0013E67E /* EZAudioPlayer.m */; };
|
||||
667558A91B3B604B0013E67E /* EZAudioPlot.m in Sources */ = {isa = PBXBuildFile; fileRef = 6675588D1B3B604B0013E67E /* EZAudioPlot.m */; };
|
||||
667558AA1B3B604B0013E67E /* EZAudioPlotGL.m in Sources */ = {isa = PBXBuildFile; fileRef = 6675588F1B3B604B0013E67E /* EZAudioPlotGL.m */; };
|
||||
667558AB1B3B604B0013E67E /* EZAudioPlotGLKViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 667558911B3B604B0013E67E /* EZAudioPlotGLKViewController.m */; };
|
||||
667558AC1B3B604B0013E67E /* EZAudioUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 667558931B3B604B0013E67E /* EZAudioUtilities.m */; };
|
||||
667558AD1B3B604B0013E67E /* EZMicrophone.m in Sources */ = {isa = PBXBuildFile; fileRef = 667558951B3B604B0013E67E /* EZMicrophone.m */; };
|
||||
667558AE1B3B604B0013E67E /* EZOutput.m in Sources */ = {isa = PBXBuildFile; fileRef = 667558971B3B604B0013E67E /* EZOutput.m */; };
|
||||
@@ -73,8 +72,6 @@
|
||||
6675588D1B3B604B0013E67E /* EZAudioPlot.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlot.m; sourceTree = "<group>"; };
|
||||
6675588E1B3B604B0013E67E /* EZAudioPlotGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGL.h; sourceTree = "<group>"; };
|
||||
6675588F1B3B604B0013E67E /* EZAudioPlotGL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGL.m; sourceTree = "<group>"; };
|
||||
667558901B3B604B0013E67E /* EZAudioPlotGLKViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGLKViewController.h; sourceTree = "<group>"; };
|
||||
667558911B3B604B0013E67E /* EZAudioPlotGLKViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGLKViewController.m; sourceTree = "<group>"; };
|
||||
667558921B3B604B0013E67E /* EZAudioUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioUtilities.h; sourceTree = "<group>"; };
|
||||
667558931B3B604B0013E67E /* EZAudioUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioUtilities.m; sourceTree = "<group>"; };
|
||||
667558941B3B604B0013E67E /* EZMicrophone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZMicrophone.h; sourceTree = "<group>"; };
|
||||
@@ -161,8 +158,6 @@
|
||||
6675588D1B3B604B0013E67E /* EZAudioPlot.m */,
|
||||
6675588E1B3B604B0013E67E /* EZAudioPlotGL.h */,
|
||||
6675588F1B3B604B0013E67E /* EZAudioPlotGL.m */,
|
||||
667558901B3B604B0013E67E /* EZAudioPlotGLKViewController.h */,
|
||||
667558911B3B604B0013E67E /* EZAudioPlotGLKViewController.m */,
|
||||
667558921B3B604B0013E67E /* EZAudioUtilities.h */,
|
||||
667558931B3B604B0013E67E /* EZAudioUtilities.m */,
|
||||
667558941B3B604B0013E67E /* EZMicrophone.h */,
|
||||
@@ -370,7 +365,6 @@
|
||||
667558A81B3B604B0013E67E /* EZAudioPlayer.m in Sources */,
|
||||
94056FDE185E59D900EB94BA /* CoreGraphicsWaveformViewController.m in Sources */,
|
||||
667558AA1B3B604B0013E67E /* EZAudioPlotGL.m in Sources */,
|
||||
667558AB1B3B604B0013E67E /* EZAudioPlotGLKViewController.m in Sources */,
|
||||
667558A51B3B604B0013E67E /* EZAudioFile.m in Sources */,
|
||||
667558AE1B3B604B0013E67E /* EZOutput.m in Sources */,
|
||||
667558AC1B3B604B0013E67E /* EZAudioUtilities.m in Sources */,
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
6675591A1B3B78720013E67E /* EZAudioPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 667558FD1B3B78720013E67E /* EZAudioPlayer.m */; };
|
||||
6675591B1B3B78720013E67E /* EZAudioPlot.m in Sources */ = {isa = PBXBuildFile; fileRef = 667558FF1B3B78720013E67E /* EZAudioPlot.m */; };
|
||||
6675591C1B3B78720013E67E /* EZAudioPlotGL.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559011B3B78720013E67E /* EZAudioPlotGL.m */; };
|
||||
6675591D1B3B78720013E67E /* EZAudioPlotGLKViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559031B3B78720013E67E /* EZAudioPlotGLKViewController.m */; };
|
||||
6675591E1B3B78720013E67E /* EZAudioUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559051B3B78720013E67E /* EZAudioUtilities.m */; };
|
||||
6675591F1B3B78720013E67E /* EZMicrophone.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559071B3B78720013E67E /* EZMicrophone.m */; };
|
||||
667559201B3B78720013E67E /* EZOutput.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559091B3B78720013E67E /* EZOutput.m */; };
|
||||
@@ -75,8 +74,6 @@
|
||||
667558FF1B3B78720013E67E /* EZAudioPlot.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlot.m; sourceTree = "<group>"; };
|
||||
667559001B3B78720013E67E /* EZAudioPlotGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGL.h; sourceTree = "<group>"; };
|
||||
667559011B3B78720013E67E /* EZAudioPlotGL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGL.m; sourceTree = "<group>"; };
|
||||
667559021B3B78720013E67E /* EZAudioPlotGLKViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGLKViewController.h; sourceTree = "<group>"; };
|
||||
667559031B3B78720013E67E /* EZAudioPlotGLKViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGLKViewController.m; sourceTree = "<group>"; };
|
||||
667559041B3B78720013E67E /* EZAudioUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioUtilities.h; sourceTree = "<group>"; };
|
||||
667559051B3B78720013E67E /* EZAudioUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioUtilities.m; sourceTree = "<group>"; };
|
||||
667559061B3B78720013E67E /* EZMicrophone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZMicrophone.h; sourceTree = "<group>"; };
|
||||
@@ -164,8 +161,6 @@
|
||||
667558FF1B3B78720013E67E /* EZAudioPlot.m */,
|
||||
667559001B3B78720013E67E /* EZAudioPlotGL.h */,
|
||||
667559011B3B78720013E67E /* EZAudioPlotGL.m */,
|
||||
667559021B3B78720013E67E /* EZAudioPlotGLKViewController.h */,
|
||||
667559031B3B78720013E67E /* EZAudioPlotGLKViewController.m */,
|
||||
667559041B3B78720013E67E /* EZAudioUtilities.h */,
|
||||
667559051B3B78720013E67E /* EZAudioUtilities.m */,
|
||||
667559061B3B78720013E67E /* EZMicrophone.h */,
|
||||
@@ -374,7 +369,6 @@
|
||||
6675591A1B3B78720013E67E /* EZAudioPlayer.m in Sources */,
|
||||
9417A97C1871E88300D9D37B /* AppDelegate.m in Sources */,
|
||||
6675591C1B3B78720013E67E /* EZAudioPlotGL.m in Sources */,
|
||||
6675591D1B3B78720013E67E /* EZAudioPlotGLKViewController.m in Sources */,
|
||||
667559171B3B78720013E67E /* EZAudioFile.m in Sources */,
|
||||
667559201B3B78720013E67E /* EZOutput.m in Sources */,
|
||||
6675591E1B3B78720013E67E /* EZAudioUtilities.m in Sources */,
|
||||
|
||||
@@ -40,7 +40,10 @@
|
||||
*/
|
||||
@interface FFTViewController : UIViewController <EZMicrophoneDelegate>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Components
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
EZAudioPlot for frequency plot
|
||||
*/
|
||||
|
||||
@@ -49,6 +49,23 @@
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
//
|
||||
// Setup the AVAudioSession. EZMicrophone will not work properly on iOS
|
||||
// if you don't do this!
|
||||
//
|
||||
AVAudioSession *session = [AVAudioSession sharedInstance];
|
||||
NSError *error;
|
||||
[session setCategory:AVAudioSessionCategoryPlayAndRecord error:&error];
|
||||
if (error)
|
||||
{
|
||||
NSLog(@"Error setting up audio session category: %@", error.localizedDescription);
|
||||
}
|
||||
[session setActive:YES error:&error];
|
||||
if (error)
|
||||
{
|
||||
NSLog(@"Error setting up audio session active: %@", error.localizedDescription);
|
||||
}
|
||||
|
||||
/*
|
||||
Customizing the audio plot's look
|
||||
*/
|
||||
@@ -70,7 +87,7 @@
|
||||
Start the microphone
|
||||
*/
|
||||
self.microphone = [EZMicrophone microphoneWithDelegate:self
|
||||
startsImmediately:YES];
|
||||
startsImmediately:YES];
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7702" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="Weo-wK-GIV">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="Weo-wK-GIV">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
|
||||
-6
@@ -16,7 +16,6 @@
|
||||
667559FE1B3B78940013E67E /* EZAudioPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559E11B3B78940013E67E /* EZAudioPlayer.m */; };
|
||||
667559FF1B3B78940013E67E /* EZAudioPlot.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559E31B3B78940013E67E /* EZAudioPlot.m */; };
|
||||
66755A001B3B78940013E67E /* EZAudioPlotGL.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559E51B3B78940013E67E /* EZAudioPlotGL.m */; };
|
||||
66755A011B3B78940013E67E /* EZAudioPlotGLKViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559E71B3B78940013E67E /* EZAudioPlotGLKViewController.m */; };
|
||||
66755A021B3B78940013E67E /* EZAudioUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559E91B3B78940013E67E /* EZAudioUtilities.m */; };
|
||||
66755A031B3B78940013E67E /* EZMicrophone.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559EB1B3B78940013E67E /* EZMicrophone.m */; };
|
||||
66755A041B3B78940013E67E /* EZOutput.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559ED1B3B78940013E67E /* EZOutput.m */; };
|
||||
@@ -73,8 +72,6 @@
|
||||
667559E31B3B78940013E67E /* EZAudioPlot.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlot.m; sourceTree = "<group>"; };
|
||||
667559E41B3B78940013E67E /* EZAudioPlotGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGL.h; sourceTree = "<group>"; };
|
||||
667559E51B3B78940013E67E /* EZAudioPlotGL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGL.m; sourceTree = "<group>"; };
|
||||
667559E61B3B78940013E67E /* EZAudioPlotGLKViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGLKViewController.h; sourceTree = "<group>"; };
|
||||
667559E71B3B78940013E67E /* EZAudioPlotGLKViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGLKViewController.m; sourceTree = "<group>"; };
|
||||
667559E81B3B78940013E67E /* EZAudioUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioUtilities.h; sourceTree = "<group>"; };
|
||||
667559E91B3B78940013E67E /* EZAudioUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioUtilities.m; sourceTree = "<group>"; };
|
||||
667559EA1B3B78940013E67E /* EZMicrophone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZMicrophone.h; sourceTree = "<group>"; };
|
||||
@@ -161,8 +158,6 @@
|
||||
667559E31B3B78940013E67E /* EZAudioPlot.m */,
|
||||
667559E41B3B78940013E67E /* EZAudioPlotGL.h */,
|
||||
667559E51B3B78940013E67E /* EZAudioPlotGL.m */,
|
||||
667559E61B3B78940013E67E /* EZAudioPlotGLKViewController.h */,
|
||||
667559E71B3B78940013E67E /* EZAudioPlotGLKViewController.m */,
|
||||
667559E81B3B78940013E67E /* EZAudioUtilities.h */,
|
||||
667559E91B3B78940013E67E /* EZAudioUtilities.m */,
|
||||
667559EA1B3B78940013E67E /* EZMicrophone.h */,
|
||||
@@ -370,7 +365,6 @@
|
||||
667559FE1B3B78940013E67E /* EZAudioPlayer.m in Sources */,
|
||||
94057050185E636100EB94BA /* OpenGLWaveformViewController.m in Sources */,
|
||||
66755A001B3B78940013E67E /* EZAudioPlotGL.m in Sources */,
|
||||
66755A011B3B78940013E67E /* EZAudioPlotGLKViewController.m in Sources */,
|
||||
667559FB1B3B78940013E67E /* EZAudioFile.m in Sources */,
|
||||
66755A041B3B78940013E67E /* EZOutput.m in Sources */,
|
||||
66755A021B3B78940013E67E /* EZAudioUtilities.m in Sources */,
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7702" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="1v1-63-VYU">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="1v1-63-VYU">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
|
||||
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
|
||||
-6
@@ -17,7 +17,6 @@
|
||||
667559531B3B78790013E67E /* EZAudioPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559361B3B78790013E67E /* EZAudioPlayer.m */; };
|
||||
667559541B3B78790013E67E /* EZAudioPlot.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559381B3B78790013E67E /* EZAudioPlot.m */; };
|
||||
667559551B3B78790013E67E /* EZAudioPlotGL.m in Sources */ = {isa = PBXBuildFile; fileRef = 6675593A1B3B78790013E67E /* EZAudioPlotGL.m */; };
|
||||
667559561B3B78790013E67E /* EZAudioPlotGLKViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6675593C1B3B78790013E67E /* EZAudioPlotGLKViewController.m */; };
|
||||
667559571B3B78790013E67E /* EZAudioUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 6675593E1B3B78790013E67E /* EZAudioUtilities.m */; };
|
||||
667559581B3B78790013E67E /* EZMicrophone.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559401B3B78790013E67E /* EZMicrophone.m */; };
|
||||
667559591B3B78790013E67E /* EZOutput.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559421B3B78790013E67E /* EZOutput.m */; };
|
||||
@@ -74,8 +73,6 @@
|
||||
667559381B3B78790013E67E /* EZAudioPlot.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlot.m; sourceTree = "<group>"; };
|
||||
667559391B3B78790013E67E /* EZAudioPlotGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGL.h; sourceTree = "<group>"; };
|
||||
6675593A1B3B78790013E67E /* EZAudioPlotGL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGL.m; sourceTree = "<group>"; };
|
||||
6675593B1B3B78790013E67E /* EZAudioPlotGLKViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGLKViewController.h; sourceTree = "<group>"; };
|
||||
6675593C1B3B78790013E67E /* EZAudioPlotGLKViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGLKViewController.m; sourceTree = "<group>"; };
|
||||
6675593D1B3B78790013E67E /* EZAudioUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioUtilities.h; sourceTree = "<group>"; };
|
||||
6675593E1B3B78790013E67E /* EZAudioUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioUtilities.m; sourceTree = "<group>"; };
|
||||
6675593F1B3B78790013E67E /* EZMicrophone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZMicrophone.h; sourceTree = "<group>"; };
|
||||
@@ -161,8 +158,6 @@
|
||||
667559381B3B78790013E67E /* EZAudioPlot.m */,
|
||||
667559391B3B78790013E67E /* EZAudioPlotGL.h */,
|
||||
6675593A1B3B78790013E67E /* EZAudioPlotGL.m */,
|
||||
6675593B1B3B78790013E67E /* EZAudioPlotGLKViewController.h */,
|
||||
6675593C1B3B78790013E67E /* EZAudioPlotGLKViewController.m */,
|
||||
6675593D1B3B78790013E67E /* EZAudioUtilities.h */,
|
||||
6675593E1B3B78790013E67E /* EZAudioUtilities.m */,
|
||||
6675593F1B3B78790013E67E /* EZMicrophone.h */,
|
||||
@@ -370,7 +365,6 @@
|
||||
667559531B3B78790013E67E /* EZAudioPlayer.m in Sources */,
|
||||
9417A61E1864D4DC00D9D37B /* AppDelegate.m in Sources */,
|
||||
667559551B3B78790013E67E /* EZAudioPlotGL.m in Sources */,
|
||||
667559561B3B78790013E67E /* EZAudioPlotGLKViewController.m in Sources */,
|
||||
667559501B3B78790013E67E /* EZAudioFile.m in Sources */,
|
||||
667559591B3B78790013E67E /* EZOutput.m in Sources */,
|
||||
667559571B3B78790013E67E /* EZAudioUtilities.m in Sources */,
|
||||
|
||||
+21
-4
@@ -28,23 +28,40 @@
|
||||
// Import EZAudio header
|
||||
#import "EZAudio.h"
|
||||
|
||||
@interface PassThroughViewController : UIViewController <EZMicrophoneDelegate,EZOutputDataSource>
|
||||
@interface PassThroughViewController : UIViewController <EZMicrophoneDelegate>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Components
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
The OpenGL based audio plot
|
||||
*/
|
||||
@property (nonatomic,weak) IBOutlet EZAudioPlotGL *audioPlot;
|
||||
@property (nonatomic, weak) IBOutlet EZAudioPlotGL *audioPlot;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
The UILabel used to display whether the microphone is on or off
|
||||
*/
|
||||
@property (nonatomic, weak) IBOutlet UILabel *microphoneTextLabel;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Actions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Switches the plot drawing type between a buffer plot (visualizes the current stream of audio data from the update function) or a rolling plot (visualizes the audio data over time, this is the classic waveform look)
|
||||
*/
|
||||
-(IBAction)changePlotType:(id)sender;
|
||||
- (IBAction)changePlotType:(id)sender;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Toggles the microphone on and off. When the microphone is on it will send its delegate (aka this view controller) the audio data in various ways (check out the EZMicrophoneDelegate documentation for more details);
|
||||
*/
|
||||
-(IBAction)toggleMicrophone:(id)sender;
|
||||
- (IBAction)toggleMicrophone:(id)sender;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@end
|
||||
|
||||
+72
-45
@@ -25,22 +25,25 @@
|
||||
|
||||
#import "PassThroughViewController.h"
|
||||
|
||||
@interface PassThroughViewController (){
|
||||
TPCircularBuffer _circularBuffer;
|
||||
}
|
||||
#pragma mark - UI Extras
|
||||
@property (nonatomic,weak) IBOutlet UILabel *microphoneTextLabel;
|
||||
@end
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - PassThroughViewController (Implementation)
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@implementation PassThroughViewController
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Status Bar Style
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (UIStatusBarStyle)preferredStatusBarStyle
|
||||
{
|
||||
return UIStatusBarStyleLightContent;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Customize the Audio Plot
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
@@ -97,62 +100,86 @@
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Actions
|
||||
-(void)changePlotType:(id)sender {
|
||||
NSInteger selectedSegment = [sender selectedSegmentIndex];
|
||||
switch(selectedSegment){
|
||||
case 0:
|
||||
[self drawBufferPlot];
|
||||
break;
|
||||
case 1:
|
||||
[self drawRollingPlot];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)changePlotType:(id)sender
|
||||
{
|
||||
NSInteger selectedSegment = [sender selectedSegmentIndex];
|
||||
switch(selectedSegment)
|
||||
{
|
||||
case 0:
|
||||
[self drawBufferPlot];
|
||||
break;
|
||||
case 1:
|
||||
[self drawRollingPlot];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
-(void)toggleMicrophone:(id)sender {
|
||||
if( ![(UISwitch*)sender isOn] ){
|
||||
[[EZMicrophone sharedMicrophone] stopFetchingAudio];
|
||||
self.microphoneTextLabel.text = @"Microphone Off";
|
||||
}
|
||||
else {
|
||||
[[EZMicrophone sharedMicrophone] startFetchingAudio];
|
||||
self.microphoneTextLabel.text = @"Microphone On";
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)toggleMicrophone:(id)sender
|
||||
{
|
||||
if( ![(UISwitch*)sender isOn] )
|
||||
{
|
||||
[[EZMicrophone sharedMicrophone] stopFetchingAudio];
|
||||
self.microphoneTextLabel.text = @"Microphone Off";
|
||||
}
|
||||
else
|
||||
{
|
||||
[[EZMicrophone sharedMicrophone] startFetchingAudio];
|
||||
self.microphoneTextLabel.text = @"Microphone On";
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Action Extensions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
Give the visualization of the current buffer (this is almost exactly the openFrameworks audio input eample)
|
||||
*/
|
||||
-(void)drawBufferPlot {
|
||||
// Change the plot type to the buffer plot
|
||||
self.audioPlot.plotType = EZPlotTypeBuffer;
|
||||
// Don't mirror over the x-axis
|
||||
self.audioPlot.shouldMirror = NO;
|
||||
// Don't fill
|
||||
self.audioPlot.shouldFill = NO;
|
||||
- (void)drawBufferPlot
|
||||
{
|
||||
// Change the plot type to the buffer plot
|
||||
self.audioPlot.plotType = EZPlotTypeBuffer;
|
||||
// Don't mirror over the x-axis
|
||||
self.audioPlot.shouldMirror = NO;
|
||||
// Don't fill
|
||||
self.audioPlot.shouldFill = NO;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
Give the classic mirrored, rolling waveform look
|
||||
*/
|
||||
-(void)drawRollingPlot {
|
||||
self.audioPlot.plotType = EZPlotTypeRolling;
|
||||
self.audioPlot.shouldFill = YES;
|
||||
self.audioPlot.shouldMirror = YES;
|
||||
- (void)drawRollingPlot
|
||||
{
|
||||
self.audioPlot.plotType = EZPlotTypeRolling;
|
||||
self.audioPlot.shouldFill = YES;
|
||||
self.audioPlot.shouldMirror = YES;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - EZMicrophoneDelegate
|
||||
-(void)microphone:(EZMicrophone *)microphone
|
||||
hasAudioReceived:(float **)buffer
|
||||
withBufferSize:(UInt32)bufferSize
|
||||
withNumberOfChannels:(UInt32)numberOfChannels {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.audioPlot updateBuffer:buffer[0] withBufferSize:bufferSize];
|
||||
});
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void) microphone:(EZMicrophone *)microphone
|
||||
hasAudioReceived:(float **)buffer
|
||||
withBufferSize:(UInt32)bufferSize
|
||||
withNumberOfChannels:(UInt32)numberOfChannels
|
||||
{
|
||||
__weak typeof (self) weakSelf = self;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[weakSelf.audioPlot updateBuffer:buffer[0] withBufferSize:bufferSize];
|
||||
});
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@end
|
||||
|
||||
-6
@@ -17,7 +17,6 @@
|
||||
667558E11B3B60B80013E67E /* EZAudioPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 667558C41B3B60B80013E67E /* EZAudioPlayer.m */; };
|
||||
667558E21B3B60B80013E67E /* EZAudioPlot.m in Sources */ = {isa = PBXBuildFile; fileRef = 667558C61B3B60B80013E67E /* EZAudioPlot.m */; };
|
||||
667558E31B3B60B80013E67E /* EZAudioPlotGL.m in Sources */ = {isa = PBXBuildFile; fileRef = 667558C81B3B60B80013E67E /* EZAudioPlotGL.m */; };
|
||||
667558E41B3B60B80013E67E /* EZAudioPlotGLKViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 667558CA1B3B60B80013E67E /* EZAudioPlotGLKViewController.m */; };
|
||||
667558E51B3B60B80013E67E /* EZAudioUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 667558CC1B3B60B80013E67E /* EZAudioUtilities.m */; };
|
||||
667558E61B3B60B80013E67E /* EZMicrophone.m in Sources */ = {isa = PBXBuildFile; fileRef = 667558CE1B3B60B80013E67E /* EZMicrophone.m */; };
|
||||
667558E71B3B60B80013E67E /* EZOutput.m in Sources */ = {isa = PBXBuildFile; fileRef = 667558D01B3B60B80013E67E /* EZOutput.m */; };
|
||||
@@ -75,8 +74,6 @@
|
||||
667558C61B3B60B80013E67E /* EZAudioPlot.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlot.m; sourceTree = "<group>"; };
|
||||
667558C71B3B60B80013E67E /* EZAudioPlotGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGL.h; sourceTree = "<group>"; };
|
||||
667558C81B3B60B80013E67E /* EZAudioPlotGL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGL.m; sourceTree = "<group>"; };
|
||||
667558C91B3B60B80013E67E /* EZAudioPlotGLKViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGLKViewController.h; sourceTree = "<group>"; };
|
||||
667558CA1B3B60B80013E67E /* EZAudioPlotGLKViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGLKViewController.m; sourceTree = "<group>"; };
|
||||
667558CB1B3B60B80013E67E /* EZAudioUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioUtilities.h; sourceTree = "<group>"; };
|
||||
667558CC1B3B60B80013E67E /* EZAudioUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioUtilities.m; sourceTree = "<group>"; };
|
||||
667558CD1B3B60B80013E67E /* EZMicrophone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZMicrophone.h; sourceTree = "<group>"; };
|
||||
@@ -163,8 +160,6 @@
|
||||
667558C61B3B60B80013E67E /* EZAudioPlot.m */,
|
||||
667558C71B3B60B80013E67E /* EZAudioPlotGL.h */,
|
||||
667558C81B3B60B80013E67E /* EZAudioPlotGL.m */,
|
||||
667558C91B3B60B80013E67E /* EZAudioPlotGLKViewController.h */,
|
||||
667558CA1B3B60B80013E67E /* EZAudioPlotGLKViewController.m */,
|
||||
667558CB1B3B60B80013E67E /* EZAudioUtilities.h */,
|
||||
667558CC1B3B60B80013E67E /* EZAudioUtilities.m */,
|
||||
667558CD1B3B60B80013E67E /* EZMicrophone.h */,
|
||||
@@ -374,7 +369,6 @@
|
||||
667558E11B3B60B80013E67E /* EZAudioPlayer.m in Sources */,
|
||||
944D03ED186038A60076EF7A /* AppDelegate.m in Sources */,
|
||||
667558E31B3B60B80013E67E /* EZAudioPlotGL.m in Sources */,
|
||||
667558E41B3B60B80013E67E /* EZAudioPlotGLKViewController.m in Sources */,
|
||||
667558DE1B3B60B80013E67E /* EZAudioFile.m in Sources */,
|
||||
667558E71B3B60B80013E67E /* EZOutput.m in Sources */,
|
||||
667558E51B3B60B80013E67E /* EZAudioUtilities.m in Sources */,
|
||||
|
||||
@@ -14,20 +14,7 @@
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
// Override point for customization after application launch.
|
||||
|
||||
// Remember to configure your audio session
|
||||
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
|
||||
NSError *err = NULL;
|
||||
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:&err];
|
||||
if( err ){
|
||||
NSLog(@"There was an error creating the audio session");
|
||||
}
|
||||
[audioSession overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:NULL];
|
||||
if( err ){
|
||||
NSLog(@"There was an error sending the audio to the speakers");
|
||||
}
|
||||
|
||||
// Override point for customization after application launch.
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
+28
-6
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7702" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="scx-fQ-Cxi">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="scx-fQ-Cxi">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Play File View Controller-->
|
||||
@@ -17,14 +17,34 @@
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="kt3-hw-eFY" customClass="EZAudioPlot">
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="kt3-hw-eFY" customClass="EZAudioPlotGL">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Pcc-nf-p5k">
|
||||
<rect key="frame" x="0.0" y="435" width="600" height="165"/>
|
||||
<rect key="frame" x="0.0" y="396" width="600" height="204"/>
|
||||
<subviews>
|
||||
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.5" minValue="0.0" maxValue="1" translatesAutoresizingMaskIntoConstraints="NO" id="d3R-ct-df2">
|
||||
<rect key="frame" x="118" y="9" width="467" height="31"/>
|
||||
<color key="tintColor" red="0.93725490199999995" green="0.93725490199999995" blue="0.95686274510000002" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<connections>
|
||||
<action selector="changeVolume:" destination="scx-fQ-Cxi" eventType="valueChanged" id="zBC-Ej-fju"/>
|
||||
</connections>
|
||||
</slider>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Volume:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iS5-xf-09a">
|
||||
<rect key="frame" x="18" y="15" width="49" height="16"/>
|
||||
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="13"/>
|
||||
<color key="textColor" red="0.93725490199999995" green="0.93725490199999995" blue="0.95686274510000002" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.70000000000000007" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="165" id="CMG-37-Ji8"/>
|
||||
<constraint firstAttribute="height" constant="204" id="CMG-37-Ji8"/>
|
||||
<constraint firstItem="iS5-xf-09a" firstAttribute="leading" secondItem="Pcc-nf-p5k" secondAttribute="leading" constant="18" id="MWr-Og-OGn"/>
|
||||
<constraint firstItem="d3R-ct-df2" firstAttribute="top" secondItem="Pcc-nf-p5k" secondAttribute="top" constant="9" id="Ukk-HX-GtW"/>
|
||||
<constraint firstItem="d3R-ct-df2" firstAttribute="leading" secondItem="iS5-xf-09a" secondAttribute="trailing" constant="53" id="cE7-h4-F6T"/>
|
||||
<constraint firstItem="iS5-xf-09a" firstAttribute="top" secondItem="Pcc-nf-p5k" secondAttribute="top" constant="15" id="cFA-qs-q09"/>
|
||||
<constraint firstAttribute="trailing" secondItem="d3R-ct-df2" secondAttribute="trailing" constant="17" id="rCY-Vg-KOz"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="X0b-lY-wCz">
|
||||
@@ -129,8 +149,10 @@
|
||||
<connections>
|
||||
<outlet property="audioPlot" destination="kt3-hw-eFY" id="9mm-d1-vJk"/>
|
||||
<outlet property="filePathLabel" destination="i5r-ex-ukW" id="GRl-ld-nWi"/>
|
||||
<outlet property="framePositionSlider" destination="Oc2-kU-kAJ" id="z0M-Q9-JAb"/>
|
||||
<outlet property="positionSlider" destination="Oc2-kU-kAJ" id="ZBM-XQ-gzp"/>
|
||||
<outlet property="rollingHistorySlider" destination="2qJ-Va-Qht" id="8rE-j3-utb"/>
|
||||
<outlet property="view" destination="PED-9r-Xub" id="Xxb-En-D2X"/>
|
||||
<outlet property="volumeSlider" destination="d3R-ct-df2" id="pAW-BF-AFa"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="g7v-Xp-r3F" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
|
||||
+60
-14
@@ -16,58 +16,104 @@
|
||||
*/
|
||||
#define kAudioFileDefault [[NSBundle mainBundle] pathForResource:@"simple-drum-beat" ofType:@"wav"]
|
||||
|
||||
/**
|
||||
Using the EZOutputDataSource to provide output data to the EZOutput component.
|
||||
*/
|
||||
@interface PlayFileViewController : UIViewController <EZAudioFileDelegate,
|
||||
EZOutputDataSource>
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - PlayFileViewController
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#pragma mark - Components
|
||||
/**
|
||||
The EZAudioFile representing of the currently selected audio file
|
||||
The PlayFileViewController will demonstrate how to play an audio file and plot
|
||||
the audio data in real-time.
|
||||
*/
|
||||
@property (nonatomic,strong) EZAudioFile *audioFile;
|
||||
@interface PlayFileViewController : UIViewController <EZAudioPlayerDelegate>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Components
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
An EZAudioFile that will be used to load the audio file at the file path specified
|
||||
*/
|
||||
@property (nonatomic, strong) EZAudioFile *audioFile;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
An EZAudioPlayer that will be used for playback
|
||||
*/
|
||||
@property (nonatomic, strong) EZAudioPlayer *player;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
The CoreGraphics based audio plot
|
||||
*/
|
||||
@property (nonatomic,weak) IBOutlet EZAudioPlot *audioPlot;
|
||||
@property (nonatomic, weak) IBOutlet EZAudioPlotGL *audioPlot;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#pragma mark - UI Extras
|
||||
/**
|
||||
A label to display the current file path with the waveform shown
|
||||
*/
|
||||
@property (nonatomic,weak) IBOutlet UILabel *filePathLabel;
|
||||
@property (nonatomic, weak) IBOutlet UILabel *filePathLabel;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
A slider to indicate the current frame position in the audio file
|
||||
*/
|
||||
@property (nonatomic,weak) IBOutlet UISlider *framePositionSlider;
|
||||
@property (nonatomic, weak) IBOutlet UISlider *positionSlider;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
A BOOL indicating whether or not we've reached the end of the file
|
||||
A slider to indicate the rolling history length of the audio plot.
|
||||
*/
|
||||
@property (nonatomic,assign) BOOL eof;
|
||||
@property (nonatomic, weak) IBOutlet UISlider *rollingHistorySlider;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
A slider to indicate the volume on the audio player
|
||||
*/
|
||||
@property (nonatomic, weak) IBOutlet UISlider *volumeSlider;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Actions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Switches the plot drawing type between a buffer plot (visualizes the current stream of audio data from the update function) or a rolling plot (visualizes the audio data over time, this is the classic waveform look)
|
||||
*/
|
||||
- (IBAction)changePlotType:(id)sender;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Changes the length of the rolling history of the audio plot.
|
||||
*/
|
||||
- (IBAction)changeRollingHistoryLength:(id)sender;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Changes the volume of the audio player.
|
||||
*/
|
||||
- (IBAction)changeVolume:(id)sender;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Begins playback if a file is loaded. Pauses if the file is already playing.
|
||||
*/
|
||||
- (IBAction)play:(id)sender;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Seeks to a specific frame in the audio file.
|
||||
*/
|
||||
- (IBAction)seekToFrame:(id)sender;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@end
|
||||
|
||||
+177
-113
@@ -10,36 +10,129 @@
|
||||
|
||||
@implementation PlayFileViewController
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Dealloc
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Status Bar Style
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (UIStatusBarStyle)preferredStatusBarStyle
|
||||
{
|
||||
return UIStatusBarStyleLightContent;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Customize the Audio Plot
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
/*
|
||||
Customizing the audio plot's look
|
||||
*/
|
||||
// Background color
|
||||
self.audioPlot.backgroundColor = [UIColor colorWithRed: 0.816 green: 0.349 blue: 0.255 alpha: 1];
|
||||
// Waveform color
|
||||
self.audioPlot.color = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0];
|
||||
// Plot type
|
||||
self.audioPlot.plotType = EZPlotTypeBuffer;
|
||||
// Fill
|
||||
self.audioPlot.shouldFill = YES;
|
||||
// Mirror
|
||||
self.audioPlot.shouldMirror = YES;
|
||||
|
||||
/*
|
||||
Try opening the sample file
|
||||
*/
|
||||
[self openFileWithFilePathURL:[NSURL fileURLWithPath:kAudioFileDefault]];
|
||||
|
||||
[super viewDidLoad];
|
||||
|
||||
//
|
||||
// Setup the AVAudioSession. EZMicrophone will not work properly on iOS
|
||||
// if you don't do this!
|
||||
//
|
||||
AVAudioSession *session = [AVAudioSession sharedInstance];
|
||||
NSError *error;
|
||||
[session setCategory:AVAudioSessionCategoryPlayAndRecord error:&error];
|
||||
if (error)
|
||||
{
|
||||
NSLog(@"Error setting up audio session category: %@", error.localizedDescription);
|
||||
}
|
||||
[session setActive:YES error:&error];
|
||||
if (error)
|
||||
{
|
||||
NSLog(@"Error setting up audio session active: %@", error.localizedDescription);
|
||||
}
|
||||
|
||||
//
|
||||
// Customizing the audio plot's look
|
||||
//
|
||||
self.audioPlot.backgroundColor = [UIColor colorWithRed: 0.816 green: 0.349 blue: 0.255 alpha: 1];
|
||||
self.audioPlot.color = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0];
|
||||
self.audioPlot.plotType = EZPlotTypeBuffer;
|
||||
self.audioPlot.shouldFill = YES;
|
||||
self.audioPlot.shouldMirror = YES;
|
||||
|
||||
//
|
||||
// Create the audio player
|
||||
//
|
||||
self.player = [EZAudioPlayer audioPlayerWithDelegate:self];
|
||||
self.player.shouldLoop = YES;
|
||||
|
||||
// Override the output to the speaker
|
||||
[session overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:&error];
|
||||
if (error)
|
||||
{
|
||||
NSLog(@"Error overriding output to the speaker: %@", error.localizedDescription);
|
||||
}
|
||||
|
||||
//
|
||||
// Customize UI components
|
||||
//
|
||||
self.rollingHistorySlider.value = (float)[self.audioPlot rollingHistoryLength];
|
||||
|
||||
//
|
||||
// Listen for EZAudioPlayer notifications
|
||||
//
|
||||
[self setupNotifications];
|
||||
|
||||
/*
|
||||
Try opening the sample file
|
||||
*/
|
||||
[self openFileWithFilePathURL:[NSURL fileURLWithPath:kAudioFileDefault]];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - Notifications
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)setupNotifications
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(audioPlayerDidChangeAudioFile:)
|
||||
name:EZAudioPlayerDidChangeAudioFileNotification
|
||||
object:self.player];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(audioPlayerDidChangeOutputDevice:)
|
||||
name:EZAudioPlayerDidChangeOutputDeviceNotification
|
||||
object:self.player];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(audioPlayerDidChangePlayState:)
|
||||
name:EZAudioPlayerDidChangePlayStateNotification
|
||||
object:self.player];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)audioPlayerDidChangeAudioFile:(NSNotification *)notification
|
||||
{
|
||||
EZAudioPlayer *player = [notification object];
|
||||
NSLog(@"Player changed audio file: %@", [player audioFile]);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)audioPlayerDidChangeOutputDevice:(NSNotification *)notification
|
||||
{
|
||||
EZAudioPlayer *player = [notification object];
|
||||
NSLog(@"Player changed output device: %@", [player device]);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)audioPlayerDidChangePlayState:(NSNotification *)notification
|
||||
{
|
||||
EZAudioPlayer *player = [notification object];
|
||||
NSLog(@"Player change play state, isPlaying: %i", [player isPlaying]);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -72,50 +165,58 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)changeVolume:(id)sender
|
||||
{
|
||||
float value = [(UISlider *)sender value];
|
||||
[self.player setVolume:value];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)openFileWithFilePathURL:(NSURL *)filePathURL
|
||||
{
|
||||
// Stop playback
|
||||
[[EZOutput sharedOutput] stopPlayback];
|
||||
//
|
||||
// Create the EZAudioPlayer
|
||||
//
|
||||
self.audioFile = [EZAudioFile audioFileWithURL:filePathURL];
|
||||
|
||||
self.audioFile = [EZAudioFile audioFileWithURL:filePathURL delegate:self];
|
||||
self.eof = NO;
|
||||
//
|
||||
// Update the UI
|
||||
//
|
||||
self.filePathLabel.text = filePathURL.lastPathComponent;
|
||||
self.framePositionSlider.maximumValue = (float)self.audioFile.totalFrames;
|
||||
|
||||
// Set the client format from the EZAudioFile on the output
|
||||
[[EZOutput sharedOutput] setAudioStreamBasicDescription:self.audioFile.clientFormat];
|
||||
self.positionSlider.maximumValue = (float)self.audioFile.totalFrames;
|
||||
self.volumeSlider.value = [self.player volume];
|
||||
|
||||
//
|
||||
// Plot the whole waveform
|
||||
//
|
||||
self.audioPlot.plotType = EZPlotTypeBuffer;
|
||||
self.audioPlot.shouldFill = YES;
|
||||
self.audioPlot.shouldMirror = YES;
|
||||
|
||||
__weak typeof (self) weakSelf = self;
|
||||
[self.audioFile getWaveformDataWithCompletionBlock:^(float **waveformData,
|
||||
int length)
|
||||
{
|
||||
[weakSelf.audioPlot updateBuffer:waveformData[0]
|
||||
withBufferSize:length];
|
||||
}];
|
||||
{
|
||||
[weakSelf.audioPlot updateBuffer:waveformData[0] withBufferSize:length];
|
||||
}];
|
||||
|
||||
//
|
||||
// Play the audio file
|
||||
//
|
||||
[self.player setAudioFile:self.audioFile];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)play:(id)sender
|
||||
{
|
||||
if (![[EZOutput sharedOutput] isPlaying])
|
||||
if ([self.player isPlaying])
|
||||
{
|
||||
if (self.eof)
|
||||
{
|
||||
[self.audioFile seekToFrame:0];
|
||||
}
|
||||
[EZOutput sharedOutput].outputDataSource = self;
|
||||
[[EZOutput sharedOutput] startPlayback];
|
||||
[self.player pause];
|
||||
}
|
||||
else
|
||||
{
|
||||
[EZOutput sharedOutput].outputDataSource = nil;
|
||||
[[EZOutput sharedOutput] stopPlayback];
|
||||
[self.player play];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +224,39 @@
|
||||
|
||||
- (void)seekToFrame:(id)sender
|
||||
{
|
||||
[self.audioFile seekToFrame:(SInt64)[(UISlider *)sender value]];
|
||||
[self.player seekToFrame:(SInt64)[(UISlider *)sender value]];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - EZAudioPlayerDelegate
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void) audioPlayer:(EZAudioPlayer *)audioPlayer
|
||||
playedAudio:(float **)buffer
|
||||
withBufferSize:(UInt32)bufferSize
|
||||
withNumberOfChannels:(UInt32)numberOfChannels
|
||||
inAudioFile:(EZAudioFile *)audioFile
|
||||
{
|
||||
__weak typeof (self) weakSelf = self;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[weakSelf.audioPlot updateBuffer:buffer[0]
|
||||
withBufferSize:bufferSize];
|
||||
});
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)audioPlayer:(EZAudioPlayer *)audioPlayer
|
||||
updatedPosition:(SInt64)framePosition
|
||||
inAudioFile:(EZAudioFile *)audioFile
|
||||
{
|
||||
__weak typeof (self) weakSelf = self;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (!weakSelf.positionSlider.touchInside)
|
||||
{
|
||||
weakSelf.positionSlider.value = (float)framePosition;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -152,75 +285,6 @@
|
||||
self.audioPlot.shouldMirror = YES;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - EZAudioFileDelegate
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void) audioFile:(EZAudioFile *)audioFile
|
||||
readAudio:(float **)buffer
|
||||
withBufferSize:(UInt32)bufferSize
|
||||
withNumberOfChannels:(UInt32)numberOfChannels
|
||||
{
|
||||
__weak typeof (self) weakSelf = self;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if ([EZOutput sharedOutput].isPlaying)
|
||||
{
|
||||
if (weakSelf.audioPlot.plotType == EZPlotTypeBuffer &&
|
||||
weakSelf.audioPlot.shouldFill == YES &&
|
||||
weakSelf.audioPlot.shouldMirror == YES)
|
||||
{
|
||||
weakSelf.audioPlot.shouldFill = NO;
|
||||
weakSelf.audioPlot.shouldMirror = NO;
|
||||
}
|
||||
[weakSelf.audioPlot updateBuffer:buffer[0]
|
||||
withBufferSize:bufferSize];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void)audioFile:(EZAudioFile *)audioFile
|
||||
updatedPosition:(SInt64)framePosition
|
||||
{
|
||||
__weak typeof (self) weakSelf = self;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (!weakSelf.framePositionSlider.touchInside)
|
||||
{
|
||||
weakSelf.framePositionSlider.value = (float)framePosition;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#pragma mark - EZOutputDataSource
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (void) output:(EZOutput *)output
|
||||
shouldFillAudioBufferList:(AudioBufferList *)audioBufferList
|
||||
withNumberOfFrames:(UInt32)frames
|
||||
{
|
||||
if ( self.audioFile )
|
||||
{
|
||||
UInt32 bufferSize;
|
||||
[self.audioFile readFrames:frames
|
||||
audioBufferList:audioBufferList
|
||||
bufferSize:&bufferSize
|
||||
eof:&_eof];
|
||||
if ( _eof )
|
||||
{
|
||||
[self seekToFrame:0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
- (AudioStreamBasicDescription)outputHasAudioStreamBasicDescription:(EZOutput *)output
|
||||
{
|
||||
return self.audioFile.clientFormat;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@end
|
||||
|
||||
-6
@@ -17,7 +17,6 @@
|
||||
667559C51B3B78890013E67E /* EZAudioPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559A81B3B78890013E67E /* EZAudioPlayer.m */; };
|
||||
667559C61B3B78890013E67E /* EZAudioPlot.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559AA1B3B78890013E67E /* EZAudioPlot.m */; };
|
||||
667559C71B3B78890013E67E /* EZAudioPlotGL.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559AC1B3B78890013E67E /* EZAudioPlotGL.m */; };
|
||||
667559C81B3B78890013E67E /* EZAudioPlotGLKViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559AE1B3B78890013E67E /* EZAudioPlotGLKViewController.m */; };
|
||||
667559C91B3B78890013E67E /* EZAudioUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559B01B3B78890013E67E /* EZAudioUtilities.m */; };
|
||||
667559CA1B3B78890013E67E /* EZMicrophone.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559B21B3B78890013E67E /* EZMicrophone.m */; };
|
||||
667559CB1B3B78890013E67E /* EZOutput.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559B41B3B78890013E67E /* EZOutput.m */; };
|
||||
@@ -74,8 +73,6 @@
|
||||
667559AA1B3B78890013E67E /* EZAudioPlot.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlot.m; sourceTree = "<group>"; };
|
||||
667559AB1B3B78890013E67E /* EZAudioPlotGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGL.h; sourceTree = "<group>"; };
|
||||
667559AC1B3B78890013E67E /* EZAudioPlotGL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGL.m; sourceTree = "<group>"; };
|
||||
667559AD1B3B78890013E67E /* EZAudioPlotGLKViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGLKViewController.h; sourceTree = "<group>"; };
|
||||
667559AE1B3B78890013E67E /* EZAudioPlotGLKViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGLKViewController.m; sourceTree = "<group>"; };
|
||||
667559AF1B3B78890013E67E /* EZAudioUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioUtilities.h; sourceTree = "<group>"; };
|
||||
667559B01B3B78890013E67E /* EZAudioUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioUtilities.m; sourceTree = "<group>"; };
|
||||
667559B11B3B78890013E67E /* EZMicrophone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZMicrophone.h; sourceTree = "<group>"; };
|
||||
@@ -161,8 +158,6 @@
|
||||
667559AA1B3B78890013E67E /* EZAudioPlot.m */,
|
||||
667559AB1B3B78890013E67E /* EZAudioPlotGL.h */,
|
||||
667559AC1B3B78890013E67E /* EZAudioPlotGL.m */,
|
||||
667559AD1B3B78890013E67E /* EZAudioPlotGLKViewController.h */,
|
||||
667559AE1B3B78890013E67E /* EZAudioPlotGLKViewController.m */,
|
||||
667559AF1B3B78890013E67E /* EZAudioUtilities.h */,
|
||||
667559B01B3B78890013E67E /* EZAudioUtilities.m */,
|
||||
667559B11B3B78890013E67E /* EZMicrophone.h */,
|
||||
@@ -370,7 +365,6 @@
|
||||
667559C51B3B78890013E67E /* EZAudioPlayer.m in Sources */,
|
||||
94057105185E805900EB94BA /* RecordViewController.m in Sources */,
|
||||
667559C71B3B78890013E67E /* EZAudioPlotGL.m in Sources */,
|
||||
667559C81B3B78890013E67E /* EZAudioPlotGLKViewController.m in Sources */,
|
||||
667559C21B3B78890013E67E /* EZAudioFile.m in Sources */,
|
||||
667559CB1B3B78890013E67E /* EZOutput.m in Sources */,
|
||||
667559C91B3B78890013E67E /* EZAudioUtilities.m in Sources */,
|
||||
|
||||
@@ -14,21 +14,7 @@
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
|
||||
// Override point for customization after application launch.
|
||||
|
||||
// Remember to configure your audio session
|
||||
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
|
||||
NSError *err = NULL;
|
||||
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:&err];
|
||||
if( err ){
|
||||
NSLog(@"There was an error creating the audio session");
|
||||
}
|
||||
[audioSession overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:NULL];
|
||||
if( err ){
|
||||
NSLog(@"There was an error sending the audio to the speakers");
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
-6
@@ -17,7 +17,6 @@
|
||||
6675598C1B3B78820013E67E /* EZAudioPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 6675596F1B3B78820013E67E /* EZAudioPlayer.m */; };
|
||||
6675598D1B3B78820013E67E /* EZAudioPlot.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559711B3B78820013E67E /* EZAudioPlot.m */; };
|
||||
6675598E1B3B78820013E67E /* EZAudioPlotGL.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559731B3B78820013E67E /* EZAudioPlotGL.m */; };
|
||||
6675598F1B3B78820013E67E /* EZAudioPlotGLKViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559751B3B78820013E67E /* EZAudioPlotGLKViewController.m */; };
|
||||
667559901B3B78820013E67E /* EZAudioUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559771B3B78820013E67E /* EZAudioUtilities.m */; };
|
||||
667559911B3B78820013E67E /* EZMicrophone.m in Sources */ = {isa = PBXBuildFile; fileRef = 667559791B3B78820013E67E /* EZMicrophone.m */; };
|
||||
667559921B3B78820013E67E /* EZOutput.m in Sources */ = {isa = PBXBuildFile; fileRef = 6675597B1B3B78820013E67E /* EZOutput.m */; };
|
||||
@@ -75,8 +74,6 @@
|
||||
667559711B3B78820013E67E /* EZAudioPlot.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlot.m; sourceTree = "<group>"; };
|
||||
667559721B3B78820013E67E /* EZAudioPlotGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGL.h; sourceTree = "<group>"; };
|
||||
667559731B3B78820013E67E /* EZAudioPlotGL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGL.m; sourceTree = "<group>"; };
|
||||
667559741B3B78820013E67E /* EZAudioPlotGLKViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioPlotGLKViewController.h; sourceTree = "<group>"; };
|
||||
667559751B3B78820013E67E /* EZAudioPlotGLKViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioPlotGLKViewController.m; sourceTree = "<group>"; };
|
||||
667559761B3B78820013E67E /* EZAudioUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZAudioUtilities.h; sourceTree = "<group>"; };
|
||||
667559771B3B78820013E67E /* EZAudioUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EZAudioUtilities.m; sourceTree = "<group>"; };
|
||||
667559781B3B78820013E67E /* EZMicrophone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EZMicrophone.h; sourceTree = "<group>"; };
|
||||
@@ -163,8 +160,6 @@
|
||||
667559711B3B78820013E67E /* EZAudioPlot.m */,
|
||||
667559721B3B78820013E67E /* EZAudioPlotGL.h */,
|
||||
667559731B3B78820013E67E /* EZAudioPlotGL.m */,
|
||||
667559741B3B78820013E67E /* EZAudioPlotGLKViewController.h */,
|
||||
667559751B3B78820013E67E /* EZAudioPlotGLKViewController.m */,
|
||||
667559761B3B78820013E67E /* EZAudioUtilities.h */,
|
||||
667559771B3B78820013E67E /* EZAudioUtilities.m */,
|
||||
667559781B3B78820013E67E /* EZMicrophone.h */,
|
||||
@@ -374,7 +369,6 @@
|
||||
6675598C1B3B78820013E67E /* EZAudioPlayer.m in Sources */,
|
||||
9405706E185E69D400EB94BA /* AppDelegate.m in Sources */,
|
||||
6675598E1B3B78820013E67E /* EZAudioPlotGL.m in Sources */,
|
||||
6675598F1B3B78820013E67E /* EZAudioPlotGLKViewController.m in Sources */,
|
||||
667559891B3B78820013E67E /* EZAudioFile.m in Sources */,
|
||||
667559921B3B78820013E67E /* EZOutput.m in Sources */,
|
||||
667559901B3B78820013E67E /* EZAudioUtilities.m in Sources */,
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
#EZAudio
|
||||
A simple, intuitive audio framework for iOS and OSX.
|
||||
|
||||
*The Official EZAudio Page:*
|
||||
http://syedharisali.com/projects/EZAudio/getting-started
|
||||
|
||||
##Features
|
||||

|
||||
|
||||
@@ -78,13 +75,10 @@ Shows how to calculate the real-time FFT of the audio data coming from the `EZMi
|
||||

|
||||
|
||||
### Documentation
|
||||
The official documentation for EZAudio can be found here: http://cocoadocs.org/docsets/EZAudio/0.0.5/
|
||||
The official documentation for EZAudio can be found here: http://cocoadocs.org/docsets/EZAudio/0.6.0/
|
||||
<br>You can also generate the docset yourself using appledocs by running the appledocs on the EZAudio source folder.
|
||||
|
||||
##Getting Started
|
||||
*To see the full project page, interactive Getting Started guide, and Documentation go here:*
|
||||
http://syedharisali.com/projects/EZAudio/getting-started
|
||||
|
||||
To begin using `EZAudio` you must first make sure you have the proper build requirements and frameworks. Below you'll find explanations of each component and code snippets to show how to use each to perform common tasks like getting microphone data, updating audio waveform plots, reading/seeking through audio files, and performing playback.
|
||||
|
||||
###Build Requirements
|
||||
@@ -114,14 +108,11 @@ To begin using `EZAudio` you must first make sure you have the proper build requ
|
||||
You can add EZAudio to your project in a few ways: <br><br>1.) The easiest way to use EZAudio is via <a href="http://cocoapods.org/", target="_blank">Cocoapods</a>. Simply add EZAudio to your <a href="http://guides.cocoapods.org/using/the-podfile.html", target="_blank">Podfile</a> like so:
|
||||
|
||||
`
|
||||
pod 'EZAudio', '~> 0.1.0'
|
||||
pod 'EZAudio', '~> 0.6.0'
|
||||
`
|
||||
|
||||
2.) Alternatively, you could clone or fork this repo and just drag and drop the source into your project.
|
||||
|
||||
*For more information see main project page:*
|
||||
http://syedharisali.com/projects/EZAudio/getting-started
|
||||
|
||||
##Core Components
|
||||
`EZAudio` currently offers four components that encompass a wide range of audio functionality. In addition to the functional aspects of these components such as pulling audio data, reading/writing from files, and performing playback they also take special care to hook into the interface components to allow developers to display visual feedback (see the Interface Components below).
|
||||
|
||||
@@ -474,7 +465,6 @@ Provides an audio waveform plot that uses CoreGraphics to perform the drawing. O
|
||||
####Creating An Audio Plot
|
||||
|
||||
You can create an audio plot in the interface builder by dragging in a UIView on iOS or an NSView on OSX onto your content area. Then change the custom class of the UIView/NSView to `EZAudioPlot`.
|
||||
See full Getting Started page for how to: http://syedharisali.com/projects/EZAudio/getting-started
|
||||
|
||||
Alternatively, you can could create the audio plot programmatically
|
||||
|
||||
@@ -539,7 +529,6 @@ Provides an audio waveform plot that uses OpenGL to perform the drawing. The API
|
||||
####Creating An OpenGL Audio Plot
|
||||
|
||||
You can create an audio plot in the interface builder by dragging in a UIView on iOS or an NSOpenGLView on OSX onto your content area. Then change the custom class of the UIView/NSView to `EZAudioPlotGL`.
|
||||
See full Getting Started page for how to: http://syedharisali.com/projects/EZAudio/getting-started
|
||||
|
||||
Alternatively, you can could create the `EZAudioPlotGL` programmatically
|
||||
```objectivec
|
||||
|
||||
Reference in New Issue
Block a user