Browse files

update a few of the deprecated property getters, todo the rest

  • Loading branch information...
1 parent 559739e commit 3315ef0e174b98e3e11c06a7ac0d5cb8d5009da2 @ndonald2 ndonald2 committed Jun 10, 2013
Showing with 39 additions and 22 deletions.
  1. +26 −19 Novocaine Mac Example/AppDelegate.mm
  2. +13 −3 Novocaine/Novocaine.m
View
45 Novocaine Mac Example/AppDelegate.mm
@@ -26,41 +26,50 @@
@implementation AppDelegate
+- (void)dealloc
+{
+ if (_ringBuffer){
+ delete _ringBuffer;
+ }
+}
+
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
self.audioManager = [Novocaine audioManager];
-// ringBuffer = new RingBuffer(32768, 2);
+ self.ringBuffer = new RingBuffer(32768, 2);
+ __weak AppDelegate * wself = self;
+
// A simple delay that's hard to express without ring buffers
// ========================================
//
-// [audioManager setInputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels) {
-// ringBuffer->AddNewInterleavedFloatData(data, numFrames, numChannels);
+// [self.audioManager setInputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels) {
+// wself.ringBuffer->AddNewInterleavedFloatData(data, numFrames, numChannels);
// }];
//
// int echoDelay = 11025;
// float *holdingBuffer = (float *)calloc(16384, sizeof(float));
-// [audioManager setOutputBlock:^(float *outData, UInt32 numFrames, UInt32 numChannels) {
+// [self.audioManager setOutputBlock:^(float *outData, UInt32 numFrames, UInt32 numChannels) {
//
// // Grab the play-through audio
-// ringBuffer->FetchInterleavedData(outData, numFrames, numChannels);
+// wself.ringBuffer->FetchInterleavedData(outData, numFrames, numChannels);
// float volume = 0.8;
// vDSP_vsmul(outData, 1, &volume, outData, 1, numFrames*numChannels);
//
//
// // Seek back, and grab some delayed audio
-// ringBuffer->SeekReadHeadPosition(-echoDelay-numFrames);
-// ringBuffer->FetchInterleavedData(holdingBuffer, numFrames, numChannels);
-// ringBuffer->SeekReadHeadPosition(echoDelay);
+// wself.ringBuffer->SeekReadHeadPosition(-echoDelay-numFrames);
+// wself.ringBuffer->FetchInterleavedData(holdingBuffer, numFrames, numChannels);
+// wself.ringBuffer->SeekReadHeadPosition(echoDelay);
//
// volume = 0.5;
// vDSP_vsmul(holdingBuffer, 1, &volume, holdingBuffer, 1, numFrames*numChannels);
// vDSP_vadd(holdingBuffer, 1, outData, 1, outData, 1, numFrames*numChannels);
// }];
-//
+
// AUDIO FILE READING COOL!
// ========================================
@@ -77,7 +86,6 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
__block int counter = 0;
- __weak AppDelegate * wself = self;
[self.audioManager setOutputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels)
{
@@ -99,19 +107,18 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
// nil];
// NSURL *outputFileURL = [NSURL fileURLWithPathComponents:pathComponents];
//
-// fileWriter = [[AudioFileWriter alloc]
-// initWithAudioFileURL:outputFileURL
-// samplingRate:audioManager.samplingRate
-// numChannels:audioManager.numInputChannels];
+// self.fileWriter = [[AudioFileWriter alloc]
+// initWithAudioFileURL:outputFileURL
+// samplingRate:self.audioManager.samplingRate
+// numChannels:self.audioManager.numInputChannels];
//
//
// __block int counter = 0;
-// audioManager.inputBlock = ^(float *data, UInt32 numFrames, UInt32 numChannels) {
-// [fileWriter writeNewAudio:data numFrames:numFrames numChannels:numChannels];
+// self.audioManager.inputBlock = ^(float *data, UInt32 numFrames, UInt32 numChannels) {
+// [wself.fileWriter writeNewAudio:data numFrames:numFrames numChannels:numChannels];
// counter += 1;
-// if (counter > 10 * audioManager.samplingRate / numChannels) { // 10 seconds of recording
-// audioManager.inputBlock = nil;
-// [fileWriter release];
+// if (counter > 10 * wself.audioManager.samplingRate / numChannels) { // 10 seconds of recording
+// wself.audioManager.inputBlock = nil;
// }
// };
View
16 Novocaine/Novocaine.m
@@ -329,18 +329,28 @@ - (void)setupAudio
UInt32 size = sizeof(AudioDeviceID);
if(self.defaultInputDeviceID == kAudioDeviceUnknown)
- {
+ {
+ AudioObjectPropertyAddress propertyAddress;
+ propertyAddress.mSelector = kAudioHardwarePropertyDefaultInputDevice;
+ propertyAddress.mScope = kAudioObjectPropertyScopeGlobal;
+ propertyAddress.mElement = kAudioObjectPropertyElementMaster;
+
AudioDeviceID thisDeviceID;
UInt32 propsize = sizeof(AudioDeviceID);
- CheckError(AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &propsize, &thisDeviceID), "Could not get the default device");
+ CheckError(AudioObjectGetPropertyData(kAudioObjectSystemObject, &propertyAddress, 0, NULL, &propsize, &thisDeviceID), "Could not get the default device");
self.defaultInputDeviceID = thisDeviceID;
}
if (self.defaultOutputDeviceID == kAudioDeviceUnknown)
{
+ AudioObjectPropertyAddress propertyAddress;
+ propertyAddress.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
+ propertyAddress.mScope = kAudioObjectPropertyScopeGlobal;
+ propertyAddress.mElement = kAudioObjectPropertyElementMaster;
+
AudioDeviceID thisDeviceID;
UInt32 propsize = sizeof(AudioDeviceID);
- CheckError(AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &propsize, &thisDeviceID), "Could not get the default device");
+ CheckError(AudioObjectGetPropertyData(kAudioObjectSystemObject, &propertyAddress, 0, NULL, &propsize, &thisDeviceID), "Could not get the default device");
self.defaultOutputDeviceID = thisDeviceID;
}

0 comments on commit 3315ef0

Please sign in to comment.