Reduce noise when recording users Voice in iphone application?

I am trying to record the voice of users with background music. I can establish a session and play the background and record at the same time using AVAudioSessionCategoryPlayAndRecord . But he records a lot of noise,

Does anyone have an idea how to reduce noise?

+4
source share
1 answer
 #define DOCUMENTS [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] #define PATH_ARQUIVO [DOCUMENTS stringByAppendingPathComponent:@"gravacao.ma4"] -(IBAction) recordAudio:(UIButton *)sender { NSURL* urlArquivo = [[NSURL alloc] initFileURLWithPath:PATH_ARQUIVO]; NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:AVAudioQualityMin], AVEncoderAudioQualityKey, [NSNumber numberWithInt:16], AVEncoderBitRateKey, [NSNumber numberWithInt:2], AVNumberOfChannelsKey, [NSNumber numberWithFloat:44.1], AVSampleRateKey, nil]; NSError* error; self.audioRecorder = [[AVAudioRecorder alloc] initWithURL:urlArquivo settings:dic error:&error]; if (error) { NSLog(@"error: %@", [erro localizedDescription]); } else { //buffering [self.audioRecorder prepareToRecord]; //recording [self.audioRecorder record]; } } -(IBAction) stopRecorder:(UIButton *)sender { if ([self.audioRecorder isRecording]) { [self.audioRecorder stop]; } } -(IBAction) PlayAudio:(UIButton *)sender { NSURL* urlArquivo = [[NSURL alloc] initFileURLWithPath:PATH_ARQUIVO]; NSError* error; self.audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:urlArquivo error:&error]; if (erro) { NSLog(@"error %@", [error localizedDescription]); } else { self.audioPlayer.numberOfLoops = HUGE_VALF; self.audioPlayer.enableRate = YES; [self.audioPlayer prepareToPlay]; [self.audioPlayer play]; } } -(IBAction) stopPlaying:(UIButton *)sender { if ([self.audioPlayer isPlaying]) { [self.audioPlayer stop]; } } -(IBAction) changeRate:(UISlider *)sender { self.audioPlayer.rate = sender.value * 2; /* it a UISlider, max value = 1, min = 0 */ } 
+1
source

Source: https://habr.com/ru/post/1383042/


All Articles