簡體   English   中英

在音頻文件中記錄我的應用程序生成的所有聲音(而不是從麥克風)

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

我有一個像儀器一樣的屏幕。 有按鈕播放聲音文件。

我想記錄當用戶按下單個音頻文件中的按鈕時播放的聲音,以便我可以將該文件保存為mp4或其他音頻格式。

能否指導我如何以簡單的方式實現這一目標?

我可以用AVAudioRecorder使用麥克風進行AVAudioRecorder

我認為,錄音方法使用麥克風作為源,但我希望它使用我的應用程序的“音頻輸出”等效作為源。

您可以嘗試使用The Amazing Audio Engine 您可以通過Cocoapods安裝它

pod 'TheAmazingAudioEngine'

或通過git克隆

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

借助於聲音,聲音可以記錄到文件中。

因此,如果您想記錄應用輸出,只需使用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];
}

使用屏幕錄像機,如CamtasiaFraps 如果你願意,你可以停止錄制並以多種格式提取聲音,而且不需要使用麥克風...還有一些開源...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM