How to remove sound noise programmatically?

I am developing an iPhone 4 application (iOS 4) that shows a level meter.

This application measures the human voice. But this is a problem. When there is a lot of noise, it does not work. It also measures background noise.

To measure sound, I use this:

- (void) initWithPattern:(Pattern *)pattern { mode = figureMode; [self showFigureMeter]; patternView.pattern = pattern; NSURL *url = [NSURL fileURLWithPath:@"/dev/null"]; NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithFloat: 44100.0], AVSampleRateKey, [NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey, [NSNumber numberWithInt: 2], AVNumberOfChannelsKey, [NSNumber numberWithInt: AVAudioQualityMax], AVEncoderAudioQualityKey, nil]; NSError *error; if (recorder == nil) recorder = [[AVAudioRecorder alloc] initWithURL:url settings:settings error:&error]; if (recorder) { [recorder prepareToRecord]; recorder.meteringEnabled = YES; [recorder record]; levelTimer = [NSTimer scheduledTimerWithTimeInterval: 0.03 target: self selector: @selector(levelTimerCallback:) userInfo: nil repeats: YES]; } } - (void)levelTimerCallback:(NSTimer *)timer { [recorder updateMeters]; float peakPower = [recorder peakPowerForChannel:0]; if (mode == figureMode) { if (peakPower < -40) { ; } else if ((peakPower > -40) && (peakPower < -30)) { ; } else if ((peakPower > -30) && (peakPower < -20)) { ; } else if ((peakPower > -20) && (peakPower < -10)) { ; } else if (peakPower > -10) { ; } } } 

Is there a way to remove background noise?

+6
source share
2 answers

Noise reduction typically involves sampling the sound (as raw PCM samples) and performing some non-trivial digital signal processing (DSP). It is necessary to clearly define the noise characteristic and how it differs from the desired signal (frequency bands, time, external gating function, etc.) so that this is acceptable at all.

You cannot just use the AVAudioRecorder dimension.

+1
source

You can measure the noise level when no one is talking (ask for silence or just select the lowest measured level) and then subtract from the instantaneous level.

Or you can use FFT to try to filter out background noise by selecting only β€œvoice” frequencies (guaranteed success is not guaranteed).

0
source

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


All Articles