我的应用程序涉及创建和录制您在应用程序中发出的声音。我尝试了多种录音方式,如AVAudioRecord。到目前为止,这些只提供了通过麦克风录制的方式,但我想记录应用程序内的实际声音。我到底如何实现这一目标。我已经在这几天了,有人可以帮助我,谢谢!
我还在我的应用程序中使用Audio unit进行播放。
这是我到目前为止使用的AVAudioRecord:
_audioController = [[AEAudioController alloc] initWithAudioDescription:[AEAudioController nonInterleavedFloatStereoAudioDescription] inputEnabled:YES];
- (void)beginRecording {
// Init recorder
self.recorder = [[AERecorder alloc] initWithAudioController:_audioController];
NSString *documentsFolder = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)
objectAtIndex:0];
NSString *filePath = [documentsFolder stringByAppendingPathComponent:@"Myaudio.aiff"];
NSLog(@"%@", filePath);
// 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];
}