1
$\begingroup$

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.

enter image description here

$\endgroup$
2
  • 2
    $\begingroup$ 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. $\endgroup$ – MBaz Sep 29 '20 at 12:44
  • $\begingroup$ So what determines the filter's transient response? If I ignore the transient the signal is then shorter than the original. $\endgroup$ – Molem7b5 Sep 29 '20 at 20:36
0
$\begingroup$

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.

Result

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.

Start-up

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

later in sequence

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.

$\endgroup$
7
  • $\begingroup$ 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. $\endgroup$ – Ben Sep 29 '20 at 20:42
  • 1
    $\begingroup$ @Ben see my plot confirming no transient with filtfilt with a 91 tap FIR filter. $\endgroup$ – Dan Boschen Sep 29 '20 at 20:55
  • 1
    $\begingroup$ @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... $\endgroup$ – Dan Boschen Sep 29 '20 at 21:12
  • 1
    $\begingroup$ I'd say there's still a transient... just a very small one. $\endgroup$ – MBaz Sep 29 '20 at 21:43
  • 1
    $\begingroup$ @MBaz see my additional plots quantifying that (for this case). $\endgroup$ – Dan Boschen Sep 29 '20 at 21:56

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.