Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reduce recording noise when recording with audio sessions?

I got some recording code working, but the recorded audio (from the iPod touch internal microphone) is very noisy.

This is my configuration:

    AVAudioSession *audioSession = [AVAudioSession sharedInstance];
    NSError *err = nil;
    [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:&err];
    if (err) {
        NSLog(@"audioSession: %@ %d %@", [err domain], [err code], [[err userInfo] description]);
        return;
    }
    [audioSession setActive:YES error:&err];
    err = nil;
    if (err) {
        NSLog(@"audioSession: %@ %d %@", [err domain], [err code], [[err userInfo] description]);
        return;
    }

    recordSetting = [[NSMutableDictionary alloc] init];

    // We can use kAudioFormatAppleIMA4 (4:1 compression) or kAudioFormatLinearPCM for nocompression
    [recordSetting setValue:[NSNumber kAudioFormatLinearPCM] forKey:AVFormatIDKey];

    // We can use 44100, 32000, 24000, 16000 or 12000 depending on sound quality
    [recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];

    // We can use 2 (if using additional h/w) or 1 (iPhone only has one microphone)
    [recordSetting setValue:[NSNumber numberWithInt:1] forKey:AVNumberOfChannelsKey];

    // These settings are used if we are using kAudioFormatLinearPCM format
    [recordSetting setValue:[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey];
    [recordSetting setValue:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey];
    [recordSetting setValue:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey];

Do I have bad config here or is there a different way to reduce noise in the recorded audio? There are some voice recorder apps out there that are noise free as far as I can tell.

like image 606
Proud Member Avatar asked Aug 19 '12 19:08

Proud Member


1 Answers

To do this you would have to do some Digital Signal Processing. You would have to create a characterization of the noise you hear while nothing is going into the mic. In other words, you would have to specify the white noise that is being recorded or picked up. You would do all of these characterizations with Digital Sound Processing (DSP). Then you can record your audio and subtract the white noise that you characterized earlier.

like image 88
Craig Avatar answered Nov 20 '22 06:11

Craig