# How to get rid of discontinuities at the start of a signal caused by the filter

I'm processing an audio signal using an overlap add method.Everything at the block boundaries is fine. However I have a discontinuity at the very start of the first block and I'm not sure how to (or if I can) get rid of this.Zero padding the start seems to make no difference as the discontinuity is obviously "triggered" when the filter first encounters the non-zero signal.

• You are seeing the filter's transient response. Short of designing a new filter with a smaller transient, the best approach is to ignore the transient and only keep the rest of the signal. – MBaz Sep 29 '20 at 12:44
• So what determines the filter's transient response? If I ignore the transient the signal is then shorter than the original. – Molem7b5 Sep 29 '20 at 20:36

If you are post processing you can instead use a "zero-phase" filter which passes the signal through the filter twice in the forward and reverse direction, resulting in an output that is completely aligned with the input as would be expected with a filter with no delay, and with a significant reduction in start-up deviations (this is a non-causal filter hence the restriction on postprocessing).

Such a filter is available in MATLAB, Octave and Python scipy.signal as filtfilt which has further documentation on its use.

I demonstrate this as shown with the plot below using a traditional 91 tap FIR low pass filter for an in-band cosine signal and again with the same coefficients with filfilt (in red). Notice there are no transients or delay.

As far as any residual transient as @MBaz astutely points out, below is the plot zoomed in on the first 4 samples showing the filtered output as (+) and the original signal as (o). The line plot simply connects the output samples. This is due to the fractional cycle remaining at the end of the sampled data where I did worst case with a 1/2 cycle residual in the capture; if done with an integer number of cycles there would be no such mismatch.

And the same portion of the waveform later in the sequence showing close alignment.

However in comparison to the blue line in the first plot even in this worst case condition, we do see the significant reduction in the start-up transient due to the use of the zero-phase filter (limited to post-processing applications). The alignment of the input and output is also a huge plus for analysis applications where we many otherwise have to go through additional efforts to offset our waveforms for the delay when comparing input to output.

• That would solve the lag but not the transient problem. I think the poster has a transient problem caused by their high-order FIR filter. – Ben Sep 29 '20 at 20:42
• @Ben see my plot confirming no transient with filtfilt with a 91 tap FIR filter. – Dan Boschen Sep 29 '20 at 20:55
• @Ben we are all here to question / challenge / confirm and all better for it so no bad-- but if I'm right I at least deserve an upvote ;) Also see my related question just asked inspired by this as to the actual frequency domain equivalent of filtfilt, perhaps you know of it off hand? I could go through the effort to derive it but curious if it is already well known, established, worked out... – Dan Boschen Sep 29 '20 at 21:12
• I'd say there's still a transient... just a very small one. – MBaz Sep 29 '20 at 21:43
• @MBaz see my additional plots quantifying that (for this case). – Dan Boschen Sep 29 '20 at 21:56