将我的应用程序生成的所有声音录制在audio文件中(而不是从麦克风)

我有一个像一个乐器的屏幕。 有播放声音文件的button。

我想logging用户在单个audio文件中按下button播放的声音,以便我可以将该文件保存为mp4或其他audio格式。

你能指导我如何以简单的方式来实现这一点?

我可以用AVAudioRecorder录制麦克风

正如我所想,录音方法使用麦克风作为来源,但我希望它使用我的应用程序的“audio输出”等同于作为来源。

你可以尝试使用惊人的audio引擎 。 你可以通过Cocoapods进行安装

 pod 'TheAmazingAudioEngine' 

或通过git克隆

 git clone --depth=1 https://github.com/TheAmazingAudioEngine/TheAmazingAudioEngine.git 

声音可以logging到一个文件的帮助下。

所以,如果你想logging的应用程序输出只需使用一个输出接收器 :

 @property (nonatomic, strong) AEAudioController *audioController; @property (nonatomic, strong) AERecorder *recorder; ... self.audioController = [[AEAudioController alloc] initWithAudioDescription:[AEAudioController nonInterleaved16BitStereoAudioDescription] inputEnabled:YES]; ... //start the recording - (void) beginRecording{ self.recorder = [[AERecorder alloc] initWithAudioController:self.audioController]; NSString *documentsFolder = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]; //the path to record to NSString *filePath = [documentsFolder stringByAppendingPathComponent:@"AppOutput.aiff"]; //start recording NSError *error = NULL; if ( ![_recorder beginRecordingToFileAtPath:filePath fileType:kAudioFileAIFFType error:&error] ) { //an error occured return; } [self.audioController addOutputReceiver:self.recorder]; } ... //end the recording - (void)endRecording { [self.audioController removeOutputReceiver:self.recorder]; [self.recorder finishRecording]; } 

使用屏幕录像机,如CamtasiaFraps 。 当你想要的时候,你可以停止logging,并以多种格式提取声音,并且不需要使用麦克风…还有一些开放源代码…