Record all sounds generated by my app in a audio file (not from mic)

有些话、适合烂在心里 提交于 2019-11-30 09:13:44

You could try using The Amazing Audio Engine. You can install it via Cocoapods

pod 'TheAmazingAudioEngine'

or clone via git

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

The sound could be recorded to a file with the help of this.

So if you want to record the apps output simply use a Outputreceiver:

@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];
}

Use a Screen Recorder, like Camtasia or Fraps. When you want, you can stop the record and extract the sound in multiple formats, and there's no need to use microphone... There are some open-source too...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!