Why do I see ringing in the output of a digital filter with a narrow transition band?

I am doing some 'extreme' eq for spectral mangling type effects with audio. Im using brick wall filters, and very narrow band pass and reject filters (vst plugins), and I'd like to know if there's anything I can do about the pre/post 'ring' with the linear phase /minimal phase filters Im using. Unfortunately I must use steep eq slopes . Im prepared to use minimum phase as it avoids pre-ring.

Specifically, Im wondering:

1. What exactly causes the oscilliations in the impulse response just after the input, in a a minimum phase filter?

2. Are these osccilations what causes the audible pre and post 'ringing' sound which is added to the passband with with steep slope filtering?

3. Are the oscilliations, and thus the ringing frequency always the same frequency, or does the ringing frequency depend in some way on the input signal?

Thanks very much for your expertise. I look forward to any responses. Dale.

• I've merged your accounts, so you should be able to comment under the answers here. I've also appended your latest post as an edit. Please remove the parts of it that are actually comments to some of the answerers and comment accordingly (now that you can do so) Apr 25, 2012 at 21:32

Edited in response to revised question and additional comments by the OP.

I disagree with @JasonR's assertion that filter ringing is due to Gibbs phenomenon.

As described in the Wikipedia article linked to in Jason's answer, the Gibbs phenomenon is an observation about the asymptotic behavior of the truncated sum (first $n$ terms) of the Fourier series of a periodic but discontinuous signal such as a square wave or sawtooth wave. The Wikipedia article illustrates an example of the square wave, showing that as more and more terms are taken ($n$ gets large), the truncated Fourier sum becomes closer and closer to the square wave. There are oscillations that occur around the switching instants where the square wave transitions from high to low or vice versa, but these become smaller and smaller as $n$ gets large. As Jason correctly points out, the amplitude of the oscillations becomes smaller, the frequency increases, and the (observed) duration also becomes smaller. Overall, it looks like the truncated Fourier sum is converging to the square wave in the limit as $n \to \infty$.

The Gibbs phenomenon is the observation that even in the limit as $n$ goes to $\infty$, the Fourier series sum does not converge to the high value or the low value at the switching instants where the square wave changes value abruptly. (Convergence does occur at all other time instants). This has nothing to do with filtering per se, except in the sense that the truncated Fourier sum can be thought of as the output of an ideal brick wall low-pass filter with square wave input. If the filter cut-off is such that the first $n$ harmonics are passed through unchanged and higher harmonics are blocked, the output is the truncated Fourier sum of the first $n$ terms. But in the limit, which is when the Gibbs phenomenon occurs, there is no filter: all the harmonics are passed through to the output without any change. For this reason, I do not agree that filter ringing is due to the Gibbs phenomenon.

So why does ringing occur? All (nontrivial) filters ring, regardless of whether they are brick-wall or not, regardless of the shape of the input signal, and regardless of whether the input is continuous or has sharp transitions. The reason is that if the input has energy in the frequency bands that are stopped (whether wholly or in substantial part), that energy is effectively stored internally in the filter and released slowly as in-band energy as time progresses. Most of the time this release is not noticed very much because it is drowned out by the response to the in-band signal that is present. However, if the in-band signal changes (or ceases) relatively suddenly, that energy stored from previous times still has to be released, and this is the ringing that is observed after the in-band signal has disappeared. In DSP terms, the FIR filter buffer continues to empty out even after the signal has ended, and so the output continues even after the signal ends. Since sharp-cutoff filters have long buffers (many biquad sections if you will), this emptying takes a long time and is much more noticeable than with a more easy-going filter which empties out quite quickly.

• Thanks Dilip. I cant see what it is that you disagree with Jason R's post. As I understand it, you have both said that the Gibbs Phenomenon does cause ringing. Is it that you disagree on the relative importance/contribution of the Gibbs phenomenon as a cause of ringing compared with other causes of ringing? Apr 26, 2012 at 13:21
• See my revised answer. Apr 26, 2012 at 14:10
• Dilip is right in that you can get ringing from a filter from other sources than the Gibbs phenomenon. If you truncate the spectrum of a periodic, discontinuous function, the oscillations in the time domain of the resulting signal are the Gibbs phenomenon. Most lowpass filters will yield a similar effect, because their impulse response often resembles a sinc function, which has the same form as the Gibbs phenomenon oscillations. When you convolve a signal with an impulse response that looks sinc-like, you can often see ringing due to the impulse response's sidelobes. Apr 26, 2012 at 14:37
• @Dilip: I'm not sure that I would say that all nontrivial filters ring. Yes, all non-trivial filters will have an impulse response that is wider than an impulse, so there will be some spreading of energy from the input signal over time. However, that doesn't mean that you will see oscillations in the output; take a Gaussian lowpass filter as an example. Apr 26, 2012 at 14:39
• @Dilip: I don't think I disagree with you at all regarding the Gibbs portion of this question. I concur that your answer is more precise with regard to the OP's issue. And, I've only heard the term "ringing" used in the context of oscillation, similar to the Gibbs effect. I would probably call non-oscillatory effects just "overshoot", "undershoot", or "filter transients." It's just nomenclature, though; I don't think one interpretation is objectively correct. Apr 26, 2012 at 15:44

Your observations are an example of the Gibbs phenomenon. When you apply a filter with a very sharp transition band, you will observe oscillations in the filter output (or "ringing") near any sharp transitions in the input signal (e.g. boundaries of pulsed waveforms). The apparent "frequency" of the oscillations is dependent upon the bandwidth of the filter; as you increase the filter's cutoff frequency, the oscillations will become more localized in time (i.e. "higher in frequency"), but the peak overshoot does not change. The Wikipedia article linked above has a good explanation halfway through or so.

1. As Jason pointed out there a basic "uncertainty principle": everything that's very narrow in frequency is wide in time and vice versa.
2. If you use minimum filters, there should be no pre-ringing, only post ringing. Pre-ringing only happens for linear phase filters. Pre-ringing is much more audible than post-ringing, so minimum filters tend to be the better choice here. It may look bad on a measurement but unless it's extreme, post ringing is not very audible because of some masking properties of the human auditory system
3. They ringing is typically exactly at the corner frequencies of your filter. I.e. a 2 kHz lowpass filter will produce 2 kHz ringing, so the frequency is a function of the filter, not the content. The content will excite it differently though. If the content as little or no 2 kHz it won't excite the ringing very much.

A bandpass filter with steep transitions and a flat passband approaches a rectangular shape.

A rectangle in one FT domain is a Sinc function in the other domain. This is true for a rectangular window in the time domain creating spectral "leakage" in the frequency domain. Or for a rectangular window in the frequency domain creating a spiral packet in the time domain. The narrower the rectangle (bandwidth) the wider the Sinc. (And a Sinc function "rings" on both sides). For a given width in one domain, the only way to get something narrower in energy extent than a Sinc in the other domain is to use something that looks closer to a Gaussian than a rectangle, e.g. no steep edges.

Now consider shifting that rectangle in one domain (e.g. changing the passband frequency of the bandpass filter). A circular shift in one DFT domain is a linear phase rotation in the other domain. Sum with a complex conjugate to get a real response, and two oppositely and rapidly rotating complex exponential spiral packets become a ringing time domain response. The rapidity of the ringing will be related to the bandpass center frequency and the length of the ringing will be related to the narrowness of bandwidth and transition steepness. If the spiral rotates more than one half turn before the envelope dies out, there will be ringing. The way to make that envelope die out faster in one domain is to use a wider rounder function in the other domain.

Part 2:

If you are using Remez or Parks-McClellen tool to design your filters, you will end up with an equi-ripple response. A sinusoid in one FT domain is an impulse in the other. Therefore equi-ripple in the frequency domain will be an impulse, or "tick" in the time domain. That "tick" will be displaced from the center of the impulse response by the "frequency" of the ripple in the frequency domain. The flatter the Remez-designed filter, the faster the ripple gets, the more the "tick" is displaced from the impulse response. That's part of the pre-ring. Use a less agressive filter design methodology to avoid it.

• Thanks Hotpaw. I understand your explanation only to a very surerficial level, as my understanding of DSP is at this moment very basic. I dont know about the tools and kits fro making digital filters, and Im lost regarding the spiral packets and complex conjugates as I dont yet have the math skills. Apr 26, 2012 at 20:22
• I would like to ask though: You say the rapidity of the ringing is related to the centre frequency of the filter. Does this mean you disagree with Hilmars assertion that ringing occurs at the corner frequencies? Or is there ringing at both those frequencies? Apr 26, 2012 at 20:26
• The corners of a rectangle can also be defined in terms of the rectangle's center and width. Apr 26, 2012 at 23:56