Low Pass Filter Artifacts I have created a Low Pass filter (I am trying to understand the topic of DSP, and it's hard.. But moving along with samples, books and a nice post on Stack Overflow).

I am saving the 'output' to a file, and I hear a constant clicking noise (very rapid, medium-pitch). The volume (intensity) of the 'clicking' gets louder as there is more intensity (in the passband of my filter).

I have been reading something about possible Artifacts when designing filters (FIR), but I am wondering if this is the constant clicking noise I hear ? It's not bad for my system, because I try to measure the intensity of the 0..100Hz band, and the clicking increases when the low sound increases. But I am just wondering if it's bad, or a possible symptom of a flaw in my filter ?

Thanks!

My Filter (of-course the getLPCoefficientsButterworth2Pole() is called first):

double ax[3];
double by[3];
double xv[3];
double yv[3];

void getLPCoefficientsButterworth2Pole(const int samplerate, const double cutoff, double* const ax, double* const by)
{
double PI = M_PI;
double sqrt2 = sqrt(2);

double QcRaw  = (2 * PI * cutoff) / samplerate; // Find cutoff frequency in [0..PI]
double QcWarp = tan(QcRaw); // Warp cutoff frequency

double gain = 1 / ( 1 + sqrt2 / QcWarp + 2 / ( QcWarp * QcWarp ) );

by[2] = ( 1 - sqrt2 / QcWarp + 2 / ( QcWarp * QcWarp ) ) * gain;
by[1] = ( 2 - 2 * 2 / ( QcWarp * QcWarp ) ) * gain;
by[0] = 1;

ax[0] = 1 * gain;
ax[1] = 2 * gain;
ax[2] = 1 * gain;
}

void process(MTAudioProcessingTapRef tap, CMItemCount numberFrames,
         MTAudioProcessingTapFlags flags, AudioBufferList *bufferListInOut,
         CMItemCount *numberFramesOut, MTAudioProcessingTapFlags *flagsOut)
{
OSStatus err = MTAudioProcessingTapGetSourceAudio(tap, numberFrames, bufferListInOut,
                                                  flagsOut, NULL, numberFramesOut);

if (err)
    NSLog(@"Error from GetSourceAudio: %ld", err);

float leftVolume, rightVolume;

NSLog(@"Test: %f", xv[1]);

for (CMItemCount i = 0; i &lt; bufferListInOut-&gt;mNumberBuffers; i++) {
    AudioBuffer *pBuffer = &amp;bufferListInOut-&gt;mBuffers[i];
    int cSamples = numberFrames * pBuffer-&gt;mNumberChannels;

    float *pData = (float *)pBuffer-&gt;mData;
    float rms = 0.0f;

    for (int j = 0; j &lt; cSamples; j++) {

        xv[2] = xv[1];
        xv[1] = xv[0];

        xv[0] = pData[j];
        yv[2] = yv[1];
        yv[1] = yv[0];

        yv[0] =   (ax[0] * xv[0] + ax[1] * xv[1] + ax[2] * xv[2]
                   - by[1] * yv[0]
                   - by[2] * yv[1]);

        pData[j] = 20 * yv[0];
        rms += yv[0] * yv[0];

    }

    if (cSamples &gt; 0) {
        rms = sqrtf(rms / cSamples);
    }

    if (0 == i) {
        leftVolume = rms;
    }

    if (1 == i || (0 == i &amp;&amp; 1 == bufferListInOut-&gt;mNumberBuffers)) {
        rightVolume = rms;
    }
}
}
From the audio clip posted on soundcloud, it looks like there's a discontinuity in the output every ~2060th sample. I suspect that you process your audio stream by blocks and that you do not save/restore the state variables of your filter between each call to the filtering function - so every time you process a new chunk of audio it is as if it was preceded by zeros - which is not the case obviously.

Related question.