I have the following sourcecode. For all I know, it should be a Bessel LPF at 10Hz. Is there a way to get the sampling frequence out of this?

double LPF(register double value) { 
    static double buf[4];
    register double tmp, fir, iir;
    tmp= buf[0]; memmove(buf, buf+1, 3*sizeof(double));
    iir= val * 1.865660386328251e-06;
    iir -= 0.9048452950692862*tmp; fir= tmp;
    iir -= -1.898666438223082*buf[0]; fir += buf[0]+buf[0];
    fir += iir;
    tmp= buf[1]; buf[1]= iir; val= fir;
    iir= val;
    iir -= 0.8712702520352774*tmp; fir= tmp;
    iir -= -1.866439169696869*buf[2]; fir += buf[2]+buf[2];
    fir += iir;
    buf[3]= iir; val= fir;
    return val;
  • 2
    $\begingroup$ If you believe that the code implements a Bessel filter with a cutoff of 10 Hz, you can extract the filter coefficients from the above code, plot the response on a normalized frequency axis, then work out what the sample rate must be in order to get that cutoff frequency. It's hard to deduce the structure from the code, shown, however (looks like the component named fir is calculated from feedback through the filter, which doesn't seem to make sense). Also, you haven't shown what val is; the above function wouldn't compile. And, the input argument value isn't referenced anywhere. $\endgroup$
    – Jason R
    Commented Nov 6, 2012 at 13:27
  • $\begingroup$ Doesn't make sense to me too, thats why I am asking ;) It looks nowhere like the filters I'Ve seen and/or used. Concerning value/val, I suppose it means the sa me and is just a typo. Thanks for noting it anyway. I will try the ploting way. $\endgroup$
    – hwi
    Commented Nov 6, 2012 at 13:46

2 Answers 2


In digital signal processing, everything is normalized to and therefore independent of the sampling frequency. The sampling frequency is not defined before the digital signal is converted to an analogue signal.

Suppose a digital lowpass filter has a 3dB cutoff frequency of 0.2 and the filtered signal is converted to an analogue signal with a rate of 50 samples/s. Then you will see the cutoff frequency of the analogue signal at 10 Hz.

So in your case, if you look at the whole system including DSP and digital-to-analogue conversion, you can calculate the sampling frequency if you know the cutoff frequency of the analogue signal and the normalized cutoff frequency of the digital filter. But with the source code alone, the sampling frequency cannot be determined.


I don't think Deve's answer is correct. The coefficient determine the transfer function in normalized frequency. You can determine at what relative frequency the transfer function hits -3dB. Let's say it's 0.01. Since you know this is corresponds to 10 Hz you can infer that the sample rate is indeed 1000Hz. This code is difficult to read and there isn't a single line of comment in it, nor is there any explanation of what the state variables so it's difficult exactly which number is what coefficient (b0,b1,b2, a0,a1, a2 etc) but it is in principle possible to infer the sample rate.

  • $\begingroup$ That's what I'm saying in my answer. $\endgroup$
    – Deve
    Commented Nov 7, 2012 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.