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 ?


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 < bufferListInOut->mNumberBuffers; i++) {
    AudioBuffer *pBuffer = &bufferListInOut->mBuffers[i];
    int cSamples = numberFrames * pBuffer->mNumberChannels;

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

    for (int j = 0; j < 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 > 0) {
        rms = sqrtf(rms / cSamples);

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

    if (1 == i || (0 == i && 1 == bufferListInOut->mNumberBuffers)) {
        rightVolume = rms;
  • 1
    $\begingroup$ Please post a plot of the output. $\endgroup$
    – Peter K.
    Mar 28, 2013 at 15:54
  • $\begingroup$ "plot of the output" ? Remember that I am a newbie :) $\endgroup$ Mar 28, 2013 at 15:54
  • $\begingroup$ Can you graph the output samples you are saving to a file? $\endgroup$
    – Peter K.
    Mar 28, 2013 at 15:56
  • 1
    $\begingroup$ No, I mean a screenshot of the time-domain signal. The clicking noise you are hearing is time-domain, so we need to see what is happening there not in the spectrum. Can you upload the audio file somewhere to share? $\endgroup$
    – Peter K.
    Mar 28, 2013 at 15:59
  • 1
    $\begingroup$ soundcloud.com/niek-van-der-steen/low-pass-filter-sample Maybe you can hear it's the first few seconds of the Sintel movie :) $\endgroup$ Mar 28, 2013 at 16:01

2 Answers 2


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.

  • $\begingroup$ As you can see, my filter vars are 'global' and thus saved. Am I missing something here ? (added my filter code right now) $\endgroup$ Mar 29, 2013 at 16:14
  • $\begingroup$ You were right. I forgot (of-course) that I also have a left and right channel, and those were mixing up now... But I still have a lot of high sounds left in my sound now.... So it doesn't look like my filter's working ? $\endgroup$ Mar 29, 2013 at 16:43

Common causes of clicking sounds in filter output are clipping and accumulator overflow (the numbers your filter is summing together are integers and go larger than the largest possible integer stored on your device).

Having a plot (or the actual samples) of the output would help identify which issue (of these or others not mentioned) it is.

EDIT: Thanks for uploading!

It's not clear why these are happening, but it seems like your filter implementation is inducing the clicks. This plot shows a zoomed-in look towards the start of the signal. There are many tiny glitches that I do not believe should be there and these are the clicks that can be heard.

Is it possible to share you low pass filter implementation?

enter image description here

  • 1
    $\begingroup$ I've posted the sample on SoundCloud. soundcloud.com/niek-van-der-steen/low-pass-filter-sample (it's the first few seconds of the Sintel movie) $\endgroup$ Mar 28, 2013 at 16:02
  • 1
    $\begingroup$ @NiekvanderSteen What does the data look like before it goes into the filter? $\endgroup$
    – Jim Clay
    Mar 28, 2013 at 17:27
  • 2
    $\begingroup$ Another common source of issues like this is the incorrect handling of filter state between blocks when performing block-oriented processing. I would guess that's the problem. $\endgroup$
    – Jason R
    Mar 28, 2013 at 19:54
  • $\begingroup$ or off-by-one errors in your block sizes? $\endgroup$
    – endolith
    Mar 28, 2013 at 20:43
  • 1
    $\begingroup$ Thanks for the help. I am looking into my Block interpretation right now, I updated my original question with the filter I use. What tool do you use to analyse the audio like that ? $\endgroup$ Mar 29, 2013 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.