Reputation: 393
I am using The Amazing Audio Engine class AERecorder to record audio from the built-in microphone. I have inspected the sample project that comes with the download. I have also implemented the code presented in the TAAE documentation for using the AERecorder.
As far as I can tell, I have everything needed to record audio. Alas, the file is created, the header is there, but there is no audio data to be had. All I can figure is that there is something wrong with the AEAudioController or some setting in my Xcode project.
For reference, my project is using ARC, and I believe I followed the instructions in the documentation for adding the -fno-objc-arc
compiler flags to any sources imported.
Has anyone else encountered this issue, and if so, how was it resolved?
I would have tried to ask this question on TAAE forum, but I am unable to sign up.
Here is the code for anyone not willing to following the link.
EDIT: Code below is updated to show what detail was previously lacking.
- (void)viewDidLoad
{
[super viewDidLoad]
self.audioController = [[AEAudioController alloc]
initWithAudioDescription:[AEAudioController nonInterleavedFloatStereoAudioDescription]
inputEnabled:YES];
//************************
// This is the crucial bit of code that was missing
NSError *error;
[audioController start:&error];
//************************
}
- (void)beginRecording {
// Init recorder
self.recorder = [[AERecorder alloc] initWithAudioController:_audioController];
NSString *documentsFolder = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)
objectAtIndex:0];
NSString *filePath = [documentsFolder stringByAppendingPathComponent:@"Recording.aiff"];
// Start the recording process
NSError *error = NULL;
if ( ![_recorder beginRecordingToFileAtPath:filePath
fileType:kAudioFileAIFFType
error:&error] ) {
// Report error
return;
}
// Receive both audio input and audio output. Note that if you're using
// AEPlaythroughChannel, mentioned above, you may not need to receive the input again.
[_audioController addInputReceiver:_recorder];
[_audioController addOutputReceiver:_recorder];
}
-(void)stopRecording
{
[_recorder finishRecording];
[_audioController removeInputReceiver:_recorder];
[_audioController removeOutputReceiver:_recorder];
self.recorder = nil;
}
Upvotes: 3
Views: 956
Reputation: 393
I have figured out the problem, which should have been obvious. I was not calling the [audioController start:&error]
anywhere in my code. Now it works like a charm. Hope this helps someone. I have to say, this is some very good software.
Upvotes: 2