惊人的音频引擎AERecorder无法录制

3
我正在使用The Amazing Audio Engine类AERecorder从内置麦克风录制音频。我已经检查了下载的示例项目。我也实现了TAAE文档中提供的代码使用AERecorder的文档
据我所知,我拥有记录音频所需的一切。不幸的是,文件已创建,头文件已存在,但没有可用的音频数据。我想到的唯一可能是AEAudioController或Xcode项目中的某些设置存在问题。
作为参考,我的项目正在使用ARC,并且我相信我遵循了文档中添加-fno-objc-arc编译器标志到任何导入源的说明。
是否有其他人遇到过此问题,如果有,如何解决?
我本来想在TAAE论坛上提出这个问题,但我无法注册。
以下是代码,供不愿意跟随链接的人使用。 编辑:下面的代码已更新以显示先前缺少的细节。
- (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;
}
1个回答

2
我已经找到了问题,这应该是显而易见的。我在代码中没有调用[audioController start:&error]。现在它像魔法一样工作。希望对某些人有所帮助。我必须说,这是非常好的软件。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接