I need to apply low-pass filter to PCM files. There are several methods such as FIR filters, IIR (butterworth-chebyshev..) filters but it seems to me applying Fast Fourier transform and eliminating higher frequencies is the closest way to an ideal filter.

What is the fastest and closest to ideal filtering method?

It is required for anti-aliasing before changing the sampling rate of sound.(Fcutoff=Fs/2) And will be applied every block of 1 sec. data. The main requirement is, after changing the sample rate, the new audio quality must be close as possible to original audio quality. (Not noisy.)


  • 4
    $\begingroup$ You should probably explain why you want to filter this data and what your requirements are from the filtering (i.e. what is your filter specification ?). $\endgroup$ – Paul R Mar 29 '12 at 8:49
  • $\begingroup$ What are your requirements in terms of stopband attenuation, slope, ripple in passband etc...? How much do you care about latency (For example, if we follow your FFT approach, a block of N samples must be available before we can even write the first output sample)? $\endgroup$ – pichenettes Mar 29 '12 at 8:54
  • $\begingroup$ It is required for anti-aliasing after changing the sampling rate of sound. And will be applied every block of 1 sec. data. The main requirement is, after changing the sample rate, the new audio quality must be close as possible to original audio quality. (Not noisy) $\endgroup$ – Mete Mar 29 '12 at 9:07
  • $\begingroup$ Note: for re-sampling you need to apply the filter before changing the sample rate (via decimation or whatever). $\endgroup$ – Paul R Mar 29 '12 at 10:01
  • $\begingroup$ What are the before and after sample rates ? Are they fixed ? Are they always an integer ratio (e.g. 44.1 kHz => 22.05 kHz) ? $\endgroup$ – Paul R Mar 29 '12 at 10:55

The best choice of filter depends on your specific application requirements. There are two basic choices: FIR and IIR. IIR will be much more efficient however, it will results in phase distortions. The phase distortions are completely inaudible (unless it's a bizarre outlier case) but clearly measurable. So it depends whether you can tolerate this our not.

In either case you need to decide how close you need to get to the new Nyquist frequency and how much aliasing noise you can tolerate. A typical example would be that you want the passband to extend to 90% of the new Nyquist frequency and that you would like your aliasing products to be below -80dB. Based on these specifications you can then design the appropriate filter. Other considerations include how much pass band ripple you can accept and if you have any constraints on maximum group delay and/or latency.

Here is an example: Let's say you want to downsample from 44.1 kHz to 32 kHz and the new Nyquist frequency is 16kHz. Going to 90% Nyquist (14400 Hz), with 0.1dB pass band ripple and 80 dB of attenuation at 16 kHz could be done with an elliptical filter of 9th order.

As nibot has pointed out, zeroing FFT bins is a poor choice for a low pass filter since the resulting low pass has very big side lobes and aliasing rejection will be quite poor. It would also require a proper implementation of an overlap-add or overlap-save algorithm to deal with a continuous signal.

  • 1
    $\begingroup$ Is the phase distortion really inaudible? Has it been shown so in experiments? $\endgroup$ – endolith Mar 29 '12 at 14:23
  • 1
    $\begingroup$ There is a large body of scientific work on the topic. The human ear is fairly insensitive to monoaural phase shifts (but VERY sensitive to binaural phase). In this case any phase distortions would be close to the cross over at high frequencies where there is little energy to start with. Unless it's extreme it's unlikely to make an audible difference $\endgroup$ – Hilmar Mar 29 '12 at 16:20
  • $\begingroup$ Right, so it's audible. :) It's really a matter of how badly you can distort it before humans notice, not a binary audible/inaudible thing. So a really poor filter design could be audible, especially if it's operating on stereo data, which is almost always true. $\endgroup$ – endolith Mar 29 '12 at 18:02
  • $\begingroup$ @endolith: not really - phase distortion would typically be the same on both left and right channels at any given frequency, so there would be no perceivable binaural phase distortion, which is what the brain is good at detecting (it's a big part of how we localise sound). We don't perceive monaural phase distortion because it has no evolutionary value. $\endgroup$ – Paul R Mar 29 '12 at 20:21
  • 1
    $\begingroup$ Human perception is rarely black and white. Here is an interesting overview of monaural phase perception research music.princeton.edu/~john/monauralphaseexperiments.htm . My point was that the human ear is not very sensitive to monaural phase and that the kind of phase or group delay introduced by an anti-aliasing filter is unlikely to be audible. $\endgroup$ – Hilmar Mar 30 '12 at 12:38

There is no simple "best" or "ideal". There are only trade-offs better matching your specific requirements or priorities (and thus being a worse match for others.)

In the case of anti-aliasing, the requirements might include max ripple, transition width, phase linearity, allowance for pre-ringing, max latency, compute cycle or energy requirements or limitations, memory limitations, specific notch frequencies, and etc.

Zeroing FFT bins is excellent at providing steep transitions and sharp notches, and one of the worse possible solutions for meeting any stop-band ripple specification (plus it might ring in the pass-band). What do you want?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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