iPhone microphone high-pass filter
In my app, I am using the AVAudioRecorder to detect input from the microphone. However, I need to create a high-pass filter so that I only register higher-pitched sounds. I've looked into FFT, but I can't figure out how to implement it. So, now I'm looking to kind-of fudge an FFT with a high-pass f开发者_JAVA百科ilter.
Any help would be greatly appreciated! Thanks!
Have a look at Wikipedia's article on High-pass filters, especially the section on algorithmic implementation of one.
For the lazy, here's the pseudocode implementation:
// Return RC high-pass filter output samples, given input samples,
// time interval dt, and time constant RC
function highpass(real[0..n] x, real dt, real RC)
var real[0..n] y
var real α := RC / (RC + dt)
y[0] := x[0]
for i from 1 to n
y[i] := α * y[i-1] + α * (x[i] - x[i-1])
return y
Using an FFT would be a sledgehammer solution in this case. A simple FIR or IIR filter should suffice, but you need to decide on the design parameters for the filter first, i.e. cut-off frequency (-3 dB point), pass-band ripple, stop-band gain, and whether you care about phase response or not.
精彩评论