简体   繁体   中英

Implement a noise filter algorithm for recorded audio in iPhone

I am developing an application like TomCat. I have recorded audio with a funny voice and playing it with Audio Queue Services. I have changed the settings of AVAudioRecorder, But while i am playing there is some noise or distortions.

NSMutableDictionary *settings = [[NSMutableDictionary alloc] init]; 
[settings setValue:[NSNumber numberWithInt:kAudioFormatLinearPCM] forKey:AVFormatIDKey]; 
[settings setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey]; 
[settings setValue:[NSNumber numberWithInt:1] forKey:AVNumberOfChannelsKey]; 
[settings setValue:[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey]; 
[settings setValue:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey]; 
[settings setValue:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey]; 


self.recorder = [[AVAudioRecorder alloc] initWithURL:[NSURL fileURLWithPath:self.audioPath] settings:settings error:nil];

self.recorder = [self.recorder retain];
[self.recorder prepareToRecord]; 
[self.recorder record]; 

I know how to covert the decibels to amplitude, or use LowPassFilter Blocks if the frequencies are too high. The HighPassFilter blocks if the frequencies are too low. How do I implement this in Objective-C?

//convert decibels to amp
const double ALPHA = 0.05;
double peakPowerForChannel = pow(10, (0.05 * [audioMonitor peakPowerForChannel:0]));
double audioMonitorResults;
audioMonitorResults= ALPHA * peakPowerForChannel + (1.0 - ALPHA) *audioMonitorResults;

Your question is not clear. In case you are looking to ensure you adhere to the Nyquist sampling criteria, your filter needs to be implemented BEFORE the ADC ie, in hardware if your sampling frequency is close to the spectrum you intend to record.

If you do have an appropriate LPF and still hear funny noises, I suggest to you that your input audio levels are too high. This is again a hardware issue; bring down your input volume.

Another source of noise might be that your record does not really consists of one continuous sample block without interruptions. Alternatively, this could be a playback issue also.

Lots of things can go wrong that lead to "noise or distortions"...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM