Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I do audio noise reduction programmatically?

I'm developing an iPhone 4 (iOS 4) application that show an level meter.

This app measures human voice. But it has a problem. When there is a lot of noise, it doesn't work. It measures also 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 any way to remove background noise?

like image 879
VansFannel Avatar asked Nov 23 '11 18:11

VansFannel


People also ask

Which algorithm is used in noise cancellation?

The LMS and NLMS algorithm has been shown to produce good results in a noise cancellation problem.

Can you edit audio to remove background noise?

The good news is that there's a free way to remove background noise from your recordings using Audacity. Audacity is a free audio editing program created by a community of audio experts.

What is the best app to remove background noise from audio?

Answer: LALAL.AI, VEED.IO, Kapwing, Notta, Noise Reduction, and Descript are the top best platforms that offer you easy-to-use tools, as well as free versions that allow you to remove background noise from an audio recording on an Android device.


1 Answers

Noise reduction usually involves sampling the sound (as raw PCM samples), and doing some non-trivial digital signal processing (DSP). One needs a well defined characterization of the noise and how it is different from the desired signal (frequency bands, time, external gating function, etc.) for this to be tractable at all.

You can't just use AVAudioRecorder metering.

like image 132
hotpaw2 Avatar answered Sep 18 '22 17:09

hotpaw2