简体   繁体   English

在iPhone中为录制的音频实现噪声滤波算法

[英]Implement a noise filter algorithm for recorded audio in iPhone

I am developing an application like TomCat. 我正在开发像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. 我已经改变了AVAudioRecorder的设置,但是在我玩的时候会有一些噪音或扭曲。

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. 我知道如何将分贝转换为振幅,或者如果频率太高则使用LowPassFilter Block。 The HighPassFilter blocks if the frequencies are too low. 如果频率太低,HighPassFilter会阻止。 How do I implement this in Objective-C? 我如何在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. 如果您希望确保遵守奈奎斯特采样标准,则需要在ADC之前实现滤波器,即如果采样频率接近您要记录的频谱,则需要在硬件中实现。

If you do have an appropriate LPF and still hear funny noises, I suggest to you that your input audio levels are too high. 如果你有一个合适的LPF并且仍能听到有趣的声音,我建议你输入的音频电平太高了。 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"... 很多事情都可能出错导致“噪音或扭曲”......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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