views:

501

answers:

2

Hi all,

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 filter.

Any help would be greatly appreciated! Thanks!

+2  A: 

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
Skilldrick
+1  A: 

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.

Paul R