Search code examples
iphoneaudiofiltermicrophoneavaudiorecorder

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

Any help would be greatly appreciated! Thanks!


Solution

  • 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