diff --git a/EZAudio/Core-Components/EZRecorder.h b/EZAudio/Core-Components/EZRecorder.h
index 9ffc6ec..30c8d64 100644
--- a/EZAudio/Core-Components/EZRecorder.h
+++ b/EZAudio/Core-Components/EZRecorder.h
@@ -25,8 +25,8 @@
/**
Creates a new instance of an EZRecorder using a destination file path URL and the source format of the incoming audio.
- @param url An NSURL specifying the file path location of where the audio file should be written to.
- @param sourceFormat The AudioStreamBasicDescription for the incoming audio that will be written to the file.
+ @param url An NSURL specifying the file path location of where the audio file should be written to.
+ @param sourceFormat The AudioStreamBasicDescription for the incoming audio that will be written to the file.
@return The newly created EZRecorder instance.
*/
-(EZRecorder*)initWithDestinationURL:(NSURL*)url
@@ -40,8 +40,8 @@
/**
Class method to create a new instance of an EZRecorder using a destination file path URL and the source format of the incoming audio.
- @param url An NSURL specifying the file path location of where the audio file should be written to.
- @param sourceFormat The AudioStreamBasicDescription for the incoming audio that will be written to the file.
+ @param url An NSURL specifying the file path location of where the audio file should be written to.
+ @param sourceFormat The AudioStreamBasicDescription for the incoming audio that will be written to the file.
@return The newly created EZRecorder instance.
*/
+(EZRecorder*)recorderWithDestinationURL:(NSURL*)url
diff --git a/EZAudio/Core-Components/EZRecorder.m b/EZAudio/Core-Components/EZRecorder.m
index 5a9a2f0..628b7af 100644
--- a/EZAudio/Core-Components/EZRecorder.m
+++ b/EZAudio/Core-Components/EZRecorder.m
@@ -51,7 +51,7 @@ typedef struct {
+(AudioStreamBasicDescription)defaultDestinationFormat {
AudioStreamBasicDescription destinationFormat;
destinationFormat.mFormatID = kAudioFormatLinearPCM;
- destinationFormat.mChannelsPerFrame = 2;
+ destinationFormat.mChannelsPerFrame = 1;
destinationFormat.mBitsPerChannel = 16;
destinationFormat.mBytesPerPacket = destinationFormat.mBytesPerFrame = 2 * destinationFormat.mChannelsPerFrame;
destinationFormat.mFramesPerPacket = 1;
@@ -69,12 +69,12 @@ typedef struct {
// Create the extended audio file
[EZAudio checkResult:ExtAudioFileCreateWithURL(_destinationFileURL,
- kAudioFileCAFType,
- &_destinationFormat,
- NULL,
- kAudioFileFlags_EraseFile,
- &_destinationFile)
- operation:"Failed to create ExtendedAudioFile reference"];
+ kAudioFileCAFType,
+ &_destinationFormat,
+ NULL,
+ kAudioFileFlags_EraseFile,
+ &_destinationFile)
+ operation:"Failed to create ExtendedAudioFile reference"];
// Set the client format
_clientFormat = _destinationFormat;
@@ -83,7 +83,6 @@ typedef struct {
numberOfChannels:_destinationFormat.mChannelsPerFrame
interleaved:YES];
}
-
UInt32 propertySize = sizeof(_clientFormat);
[EZAudio checkResult:ExtAudioFileSetProperty(_destinationFile,
kExtAudioFileProperty_ClientDataFormat,
@@ -96,7 +95,7 @@ typedef struct {
operation:"Failed to initialize with ExtAudioFileWriteAsync"];
// Setup the audio converter
- [EZAudio checkResult:AudioConverterNew(&_sourceFormat, &_destinationFormat, &_audioConverter)
+ [EZAudio checkResult:AudioConverterNew(&_sourceFormat, &_clientFormat, &_audioConverter)
operation:"Failed to create new audio converter"];
}
@@ -107,7 +106,7 @@ typedef struct {
// Setup output buffers
UInt32 outputBufferSize = 32 * 1024; // 32 KB
- AudioBufferList *convertedData = (AudioBufferList*)malloc(sizeof(AudioBufferList));
+ AudioBufferList *convertedData = [EZAudio audioBufferList];
convertedData->mNumberBuffers = 1;
convertedData->mBuffers[0].mNumberChannels = _clientFormat.mChannelsPerFrame;
convertedData->mBuffers[0].mDataByteSize = outputBufferSize;
diff --git a/EZAudioExamples/OSX/EZAudioPlayFileExample/EZAudioPlayFileExample.xcodeproj/project.pbxproj b/EZAudioExamples/OSX/EZAudioPlayFileExample/EZAudioPlayFileExample.xcodeproj/project.pbxproj
index 0f2072f..dfd721d 100644
--- a/EZAudioExamples/OSX/EZAudioPlayFileExample/EZAudioPlayFileExample.xcodeproj/project.pbxproj
+++ b/EZAudioExamples/OSX/EZAudioPlayFileExample/EZAudioPlayFileExample.xcodeproj/project.pbxproj
@@ -183,9 +183,9 @@
94056F0C185BD83400EB94BA /* AppDelegate.h */,
94056F0D185BD83400EB94BA /* AppDelegate.m */,
94056F2E185BD86D00EB94BA /* PlayFileViewController.h */,
+ 94056F2F185BD86D00EB94BA /* PlayFileViewController.m */,
94056F30185BD86D00EB94BA /* PlayFileViewController.xib */,
94056F0F185BD83400EB94BA /* MainMenu.xib */,
- 94056F2F185BD86D00EB94BA /* PlayFileViewController.m */,
94056F12185BD83400EB94BA /* Images.xcassets */,
94056F01185BD83400EB94BA /* Supporting Files */,
);
diff --git a/EZAudioExamples/OSX/EZAudioPlayFileExample/EZAudioPlayFileExample/PlayFileViewController.h b/EZAudioExamples/OSX/EZAudioPlayFileExample/EZAudioPlayFileExample/PlayFileViewController.h
index 75c83a9..68ee31e 100644
--- a/EZAudioExamples/OSX/EZAudioPlayFileExample/EZAudioPlayFileExample/PlayFileViewController.h
+++ b/EZAudioExamples/OSX/EZAudioPlayFileExample/EZAudioPlayFileExample/PlayFileViewController.h
@@ -30,7 +30,7 @@
/**
The CoreGraphics based audio plot
*/
-@property (nonatomic,weak) IBOutlet EZAudioPlot *audioPlot;
+@property (nonatomic,weak) IBOutlet EZAudioPlotGL *audioPlot;
#pragma mark - UI Extras
/**
@@ -38,6 +38,11 @@
*/
@property (nonatomic,weak) IBOutlet NSTextField *filePathLabel;
+/**
+ A slider to indicate the current frame position in the audio file
+ */
+@property (nonatomic,weak) IBOutlet NSSlider *framePositionSlider;
+
/**
A BOOL indicating whether or not we've reached the end of the file
*/
@@ -59,4 +64,9 @@
*/
-(IBAction)play:(id)sender;
+/**
+ Seeks to a specific frame in the audio file.
+ */
+-(IBAction)seekToFrame:(id)sender;
+
@end
diff --git a/EZAudioExamples/OSX/EZAudioPlayFileExample/EZAudioPlayFileExample/PlayFileViewController.m b/EZAudioExamples/OSX/EZAudioPlayFileExample/EZAudioPlayFileExample/PlayFileViewController.m
index 74b7368..070f6a3 100644
--- a/EZAudioExamples/OSX/EZAudioPlayFileExample/EZAudioPlayFileExample/PlayFileViewController.m
+++ b/EZAudioExamples/OSX/EZAudioPlayFileExample/EZAudioPlayFileExample/PlayFileViewController.m
@@ -16,6 +16,7 @@
@synthesize audioFile;
@synthesize audioPlot;
@synthesize eof = _eof;
+@synthesize framePositionSlider;
#pragma mark - Initialization
-(id)init {
@@ -110,6 +111,10 @@
}
}
+-(void)seekToFrame:(id)sender {
+ [self.audioFile seekToFrame:(SInt64)[(NSSlider*)sender doubleValue]];
+}
+
#pragma mark - Action Extensions
/*
Give the visualization of the current buffer (this is almost exactly the openFrameworks audio input example)
@@ -140,17 +145,15 @@
// Stop playback
[[EZOutput sharedOutput] stopPlayback];
- self.audioFile = [EZAudioFile audioFileWithURL:filePathURL];
- self.audioFile.audioFileDelegate = self;
- self.eof = NO;
- self.filePathLabel.stringValue = filePathURL.lastPathComponent;
+ self.audioFile = [EZAudioFile audioFileWithURL:filePathURL andDelegate:self];
+ self.eof = NO;
+ self.filePathLabel.stringValue = filePathURL.lastPathComponent;
+ self.framePositionSlider.minValue = 0.0f;
+ self.framePositionSlider.maxValue = (double)self.audioFile.totalFrames;
// Plot the whole waveform
- // Plot type
self.audioPlot.plotType = EZPlotTypeBuffer;
- // Fill
self.audioPlot.shouldFill = YES;
- // Mirror
self.audioPlot.shouldMirror = YES;
[self.audioFile getWaveformDataWithCompletionBlock:^(float *waveformData, UInt32 length) {
[self.audioPlot updateBuffer:waveformData withBufferSize:length];
@@ -173,6 +176,15 @@
}
}
+-(void)audioFile:(EZAudioFile *)audioFile
+ updatedPosition:(SInt64)framePosition {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ if( ![self.framePositionSlider.cell isHighlighted] ){
+ self.framePositionSlider.floatValue = (float)framePosition;
+ }
+ });
+}
+
#pragma mark - EZOutputDataSource
-(AudioBufferList *)output:(EZOutput *)output
needsBufferListWithFrames:(UInt32)frames
@@ -204,7 +216,6 @@
[self.audioFile seekToFrame:0];
return nil;
}
-
return bufferList;
}
return nil;
diff --git a/EZAudioExamples/OSX/EZAudioPlayFileExample/EZAudioPlayFileExample/PlayFileViewController.xib b/EZAudioExamples/OSX/EZAudioPlayFileExample/EZAudioPlayFileExample/PlayFileViewController.xib
index bf64ad5..fea861f 100644
--- a/EZAudioExamples/OSX/EZAudioPlayFileExample/EZAudioPlayFileExample/PlayFileViewController.xib
+++ b/EZAudioExamples/OSX/EZAudioPlayFileExample/EZAudioPlayFileExample/PlayFileViewController.xib
@@ -9,6 +9,7 @@
+
@@ -18,8 +19,8 @@
-
-
+
+
+
-
+
+
+
+
diff --git a/EZAudioExamples/OSX/EZAudioRecordExample/EZAudioRecordExample/RecordViewController.m b/EZAudioExamples/OSX/EZAudioRecordExample/EZAudioRecordExample/RecordViewController.m
index a508d20..0d02e11 100644
--- a/EZAudioExamples/OSX/EZAudioRecordExample/EZAudioRecordExample/RecordViewController.m
+++ b/EZAudioExamples/OSX/EZAudioRecordExample/EZAudioRecordExample/RecordViewController.m
@@ -111,7 +111,6 @@ withNumberOfChannels:(UInt32)numberOfChannels {
// We can initialize the recorder with this ASBD
self.recorder = [EZRecorder recorderWithDestinationURL:[NSURL fileURLWithPath:kAudioFilePath]
- destinationFormat:[EZRecorder defaultDestinationFormat]
andSourceFormat:audioStreamBasicDescription];
}
diff --git a/EZAudioExamples/OSX/EZAudioWaveformFromFileExample/EZAudioWaveformFromFileExample/WaveformFromFileViewController.m b/EZAudioExamples/OSX/EZAudioWaveformFromFileExample/EZAudioWaveformFromFileExample/WaveformFromFileViewController.m
index e99aaf8..ef23ab8 100644
--- a/EZAudioExamples/OSX/EZAudioWaveformFromFileExample/EZAudioWaveformFromFileExample/WaveformFromFileViewController.m
+++ b/EZAudioExamples/OSX/EZAudioWaveformFromFileExample/EZAudioWaveformFromFileExample/WaveformFromFileViewController.m
@@ -90,41 +90,13 @@
self.eof = NO;
self.filePathLabel.stringValue = filePathURL.lastPathComponent;
- // The EZAudioFile provides convenience methods to optimize the waveform drawings. It will choose a proper window to iterate through the file that will generate roughly ~2048 buffers and so 2048 points on the waveform graph. This ensures that we get a good looking plot for both very small and very large files
- UInt32 frameRate = [self.audioFile recommendedDrawingFrameRate];
- UInt32 buffers = [self.audioFile minBuffersWithFrameRate:frameRate];
-
- // Check if we have allocated a read buffer
- if( readBuffer == NULL ){
- readBuffer = (AudioBufferList*)malloc(sizeof(AudioBufferList));
- }
-
- // Take a snapshot of each buffer through the audio file to form the waveform
- __block float rms;
- float data[buffers];
- for( int i = 0; i < buffers; i++ ){
-
- // Allocate a buffer list to hold the audio file's data
- UInt32 bufferSize;
- BOOL eof;
-
- // Read some data from the audio file (the audio file internally maintains the seek position you're at). You can manually seek to whatever position in the audio file using the seekToFileOffset: function on the EZAudioFile.
- [self.audioFile readFrames:frameRate
- audioBufferList:readBuffer
- bufferSize:&bufferSize
- eof:&eof];
-
- // Get the RMS of the buffeer
- rms = [EZAudio RMS:readBuffer->mBuffers[0].mData length:bufferSize];
- data[i] = rms;
-
- }
-
- // Since we malloc'ed, we should cleanup
- [EZAudio freeBufferList:readBuffer];
-
- // Update the audio plot once all the snapshots have been taken
- [self.audioPlot updateBuffer:data withBufferSize:buffers];
+ // Plot the whole waveform
+ self.audioPlot.plotType = EZPlotTypeBuffer;
+ self.audioPlot.shouldFill = YES;
+ self.audioPlot.shouldMirror = YES;
+ [self.audioFile getWaveformDataWithCompletionBlock:^(float *waveformData, UInt32 length) {
+ [self.audioPlot updateBuffer:waveformData withBufferSize:length];
+ }];
}
diff --git a/EZAudioExamples/iOS/EZAudioPlayFileExample/EZAudioPlayFileExample/PlayFileViewController.h b/EZAudioExamples/iOS/EZAudioPlayFileExample/EZAudioPlayFileExample/PlayFileViewController.h
index 04d9da2..cc661a5 100644
--- a/EZAudioExamples/iOS/EZAudioPlayFileExample/EZAudioPlayFileExample/PlayFileViewController.h
+++ b/EZAudioExamples/iOS/EZAudioPlayFileExample/EZAudioPlayFileExample/PlayFileViewController.h
@@ -33,13 +33,16 @@
@property (nonatomic,weak) IBOutlet EZAudioPlotGL *audioPlot;
#pragma mark - UI Extras
-@property (nonatomic,weak) IBOutlet UISlider *framePositionSlider;
-
/**
A label to display the current file path with the waveform shown
*/
@property (nonatomic,weak) IBOutlet UILabel *filePathLabel;
+/**
+ A slider to indicate the current frame position in the audio file
+ */
+@property (nonatomic,weak) IBOutlet UISlider *framePositionSlider;
+
/**
A BOOL indicating whether or not we've reached the end of the file
*/
diff --git a/EZAudioExamples/iOS/EZAudioPlayFileExample/EZAudioPlayFileExample/PlayFileViewController.m b/EZAudioExamples/iOS/EZAudioPlayFileExample/EZAudioPlayFileExample/PlayFileViewController.m
index 13c6692..a93ea3b 100644
--- a/EZAudioExamples/iOS/EZAudioPlayFileExample/EZAudioPlayFileExample/PlayFileViewController.m
+++ b/EZAudioExamples/iOS/EZAudioPlayFileExample/EZAudioPlayFileExample/PlayFileViewController.m
@@ -139,6 +139,10 @@
self.framePositionSlider.maximumValue = (float)self.audioFile.totalFrames;
// Plot the whole waveform
+ // Plot the whole waveform
+ self.audioPlot.plotType = EZPlotTypeBuffer;
+ self.audioPlot.shouldFill = YES;
+ self.audioPlot.shouldMirror = YES;
[self.audioFile getWaveformDataWithCompletionBlock:^(float *waveformData, UInt32 length) {
[self.audioPlot updateBuffer:waveformData withBufferSize:length];
}];
@@ -191,7 +195,7 @@ withNumberOfChannels:(UInt32)numberOfChannels {
// Reached the end of the file on the last read
if( eof ){
- free(bufferList);
+ [EZAudio freeBufferList:bufferList];
[self.audioFile seekToFrame:0];
return nil;
}
diff --git a/EZAudioExamples/iOS/EZAudioWaveformFromFileExample/EZAudioWaveformFromFileExample/WaveformFromFileViewController.m b/EZAudioExamples/iOS/EZAudioWaveformFromFileExample/EZAudioWaveformFromFileExample/WaveformFromFileViewController.m
index 876e0d3..bf2ef15 100644
--- a/EZAudioExamples/iOS/EZAudioWaveformFromFileExample/EZAudioWaveformFromFileExample/WaveformFromFileViewController.m
+++ b/EZAudioExamples/iOS/EZAudioWaveformFromFileExample/EZAudioWaveformFromFileExample/WaveformFromFileViewController.m
@@ -52,38 +52,13 @@
self.eof = NO;
self.filePathLabel.text = filePathURL.lastPathComponent;
- // The EZAudioFile provides convenience methods to optimize the waveform drawings. It will choose a proper window to iterate through the file that will generate roughly ~2048 buffers and so 2048 points on the waveform graph. This ensures that we get a good looking plot for both very small and very large files
- UInt32 frameRate = [self.audioFile recommendedDrawingFrameRate];
- UInt32 buffers = [self.audioFile minBuffersWithFrameRate:frameRate];
-
- // Take a snapshot of each buffer through the audio file to form the waveform
- __block float rms;
- float data[buffers];
- for( int i = 0; i < buffers; i++ ){
-
- // Allocate a buffer list to hold the audio file's data
- // Check if we have allocated a read buffer
- readBuffer = (AudioBufferList*)malloc(sizeof(AudioBufferList));
- UInt32 bufferSize;
- BOOL eof;
-
- // Read some data from the audio file (the audio file internally maintains the seek position you're at). You can manually seek to whatever position in the audio file using the seekToFileOffset: function on the EZAudioFile.
- [self.audioFile readFrames:frameRate
- audioBufferList:readBuffer
- bufferSize:&bufferSize
- eof:&eof];
-
- // Get the RMS of the buffeer
- rms = [EZAudio RMS:readBuffer->mBuffers[0].mData length:bufferSize];
- data[i] = rms;
-
- // Since we malloc'ed, we should cleanup
- [EZAudio freeBufferList:readBuffer];
-
- }
-
- // Update the audio plot once all the snapshots have been taken
- [self.audioPlot updateBuffer:data withBufferSize:buffers];
+ // Plot the whole waveform
+ self.audioPlot.plotType = EZPlotTypeBuffer;
+ self.audioPlot.shouldFill = YES;
+ self.audioPlot.shouldMirror = YES;
+ [self.audioFile getWaveformDataWithCompletionBlock:^(float *waveformData, UInt32 length) {
+ [self.audioPlot updateBuffer:waveformData withBufferSize:length];
+ }];
}
diff --git a/docset-installed.txt b/docset-installed.txt
new file mode 100644
index 0000000..e42f6f9
--- /dev/null
+++ b/docset-installed.txt
@@ -0,0 +1,4 @@
+Documentation set was installed to Xcode!
+
+Path: /Users/syedali/Library/Developer/Shared/Documentation/DocSets/com.sha.EZAudio.docset
+Time: 2013-12-19 00:21:27 +0000
\ No newline at end of file