Permalink
Browse files

AudioFileReader interface cleanup

  • Loading branch information...
1 parent dfcfffe commit 524812995d528c126f1db7461fc636cceb39769b @ndonald2 ndonald2 committed Jun 10, 2013
@@ -29,10 +29,10 @@
@interface AppDelegate : NSObject <NSApplicationDelegate>
-@property (nonatomic, assign) RingBuffer *ringBuffer;
@property (nonatomic, strong) Novocaine *audioManager;
@property (nonatomic, strong) AudioFileReader *fileReader;
@property (nonatomic, strong) AudioFileWriter *fileWriter;
+@property (nonatomic, assign) RingBuffer * ringBuffer;
@property (nonatomic, weak) IBOutlet NSWindow *window;
@@ -37,13 +37,14 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
self.audioManager = [Novocaine audioManager];
+
self.ringBuffer = new RingBuffer(32768, 2);
__weak AppDelegate * wself = self;
// A simple delay that's hard to express without ring buffers
// ========================================
-//
+
// [self.audioManager setInputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels) {
// wself.ringBuffer->AddNewInterleavedFloatData(data, numFrames, numChannels);
// }];
@@ -67,7 +68,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
// vDSP_vsmul(holdingBuffer, 1, &volume, holdingBuffer, 1, numFrames*numChannels);
// vDSP_vadd(holdingBuffer, 1, outData, 1, outData, 1, numFrames*numChannels);
// }];
-
+//
// AUDIO FILE READING COOL!
// ========================================
@@ -94,8 +95,6 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
}];
-
-
// AUDIO FILE WRITING YEAH!
// ========================================
@@ -30,7 +30,6 @@
@interface ViewController : UIViewController
-@property (nonatomic, assign) RingBuffer *ringBuffer;
@property (nonatomic, strong) Novocaine *audioManager;
@property (nonatomic, strong) AudioFileReader *fileReader;
@property (nonatomic, strong) AudioFileWriter *fileWriter;
@@ -26,10 +26,17 @@
@interface ViewController ()
+@property (nonatomic, assign) RingBuffer *ringBuffer;
+
@end
@implementation ViewController
+- (void)dealloc
+{
+ delete self.ringBuffer;
+}
+
- (void)viewDidLoad
{
[super viewDidLoad];
@@ -28,14 +28,19 @@
@interface AudioFileReader : NSObject
+// ----- Read-write ------
+
@property (nonatomic, assign, getter=getCurrentTime, setter=setCurrentTime:) float currentTime;
-@property (nonatomic, assign, readonly, getter=getDuration) float duration;
-@property (nonatomic, assign) float samplingRate;
-@property (nonatomic, assign) UInt32 numChannels;
-@property (nonatomic, assign) float latency;
@property (nonatomic, copy) NSURL *audioFileURL;
@property (nonatomic, copy) NovocaineInputBlock readerBlock;
-@property (nonatomic, assign) BOOL playing;
+
+// ----- Read-only ------
+
+@property (nonatomic, assign, readonly, getter=getDuration) float duration;
+@property (nonatomic, assign, readonly) float samplingRate;
+@property (nonatomic, assign, readonly) UInt32 numChannels;
+@property (nonatomic, assign, readonly) float latency;
+@property (nonatomic, assign, readonly) BOOL playing;
- (id)initWithAudioFileURL:(NSURL *)urlToAudioFile samplingRate:(float)thisSamplingRate numChannels:(UInt32)thisNumChannels;
@@ -32,6 +32,13 @@ @interface AudioFileReader ()
RingBuffer *ringBuffer;
}
+// redeclaration as readwrite in class continuation
+@property (nonatomic, assign, readwrite, getter=getDuration) float duration;
+@property (nonatomic, assign, readwrite) float samplingRate;
+@property (nonatomic, assign, readwrite) UInt32 numChannels;
+@property (nonatomic, assign, readwrite) float latency;
+@property (nonatomic, assign, readwrite) BOOL playing;
+
@property (nonatomic, assign) AudioStreamBasicDescription outputFormat;
@property (nonatomic, assign) ExtAudioFileRef inputFile;
@property (nonatomic, assign) UInt32 outputBufferSize;
@@ -47,7 +54,6 @@ - (void)bufferNewAudio;
@end
-
@implementation AudioFileReader
@@ -79,7 +85,6 @@ - (id)initWithAudioFileURL:(NSURL *)urlToAudioFile samplingRate:(float)thisSampl
// Zero-out our timer, so we know we're not using our callback yet
self.callbackTimer = nil;
-
// Open a reference to the audio file
self.audioFileURL = urlToAudioFile;
CFURLRef audioFileRef = (__bridge CFURLRef)self.audioFileURL;

0 comments on commit 5248129

Please sign in to comment.