1
$\begingroup$

I'm trying to create a basic digital signal processing pipeline, to manipulate a WAV file. Nothing fancy, I'm just looking to apply some filtering.

My first attempt was to divide the input signal to N rectangular windows (which do not overlap), convert each window to the frequency domain, apply the filtering of my choice to the spectrum, convert it back to the time domain and insert the resulting window in place of the original one.

(By rectangular window, I mean rectangular in the time domain.)

This worked, however, the only downside was that there was a discontinuity at the edges of each window, severe enough to distort the overall signal and introduce harmonics of significant amplitude.

My attempt to resolve this was to replace the rectangular windows with Hann windows, and apply the same process. With non-overlapping windows, the obvious result was that the output signal became a set of Hann "pulses", which is as bad as the discontinuities.

I seem to be missing a very basic part of digital signal processing.

I understand the windows should overlap, but how exactly? Should the overlapping portions be averaged? How do we ensure that the amplitude of the resulting signal is unchanged despite Hann window overlapping/averaging?

$\endgroup$
4
  • $\begingroup$ Read up on "overlap add convolution". In general filtering in the frequency domain is pretty tricky especially if it's time variant. If you can do it in the time domain, that's frequently the easier solution. $\endgroup$
    – Hilmar
    Mar 30, 2020 at 16:30
  • $\begingroup$ i realize it might be a little formal, mathematically, but i try to spell out what the overlapping complementary windows, like Hann, are supposed to be $\endgroup$ Mar 30, 2020 at 17:18
  • $\begingroup$ See the section in this paper on overlap correlation web.mit.edu/xiphmont/Public/windows.pdf $\endgroup$ Mar 30, 2020 at 18:21
  • $\begingroup$ @WantsToLearn, Whenever you have multiple, overlapping fft frames that you want to convert back to a time domain signal, you should use the overlap-add technique even when no filtering is applied at all. $\endgroup$
    – dsp_user
    Mar 31, 2020 at 13:51

3 Answers 3

0
$\begingroup$

If you convert your signal into the frequency domain you will get complex numbers. When you manipulate these values, you must know, how this changed the phase of your signal. This phase offset must be added N-times to the Nth block of your processing in oder to reconstruct your time signal without the distortion of the discontinuation.

If you apply a window like Hann this might help only if you are interested in an (averaged) spectrum view of the signal. This would not help to reconstruct your signal.

Typically filtering of signals can be done directly in the time domain (FIR, IIR). You can describe the behaviour in the frequency domain (e.g. low pass, band pass, high pass) and calculate the filter coefficient out of this.

$\endgroup$
0
$\begingroup$

When you filter a finite length signal, the filtered output will have a larger length, either you implement the filter in time domain or frequency domain. Your desired continuity comes from this excess part which must be added to the result of next segment or window.

For example when you take N samples of a signal and filter it with a filter of length M, the result has a length of N+M-1, where the M-1 excessive samples must be added to the next segment. To do so you have to find your filter response in time domain which has a length of M samples, then zero-pad both your signal and filter to N+M-1 samples then take N+M-1 point FT of both and multiply them.

$\endgroup$
2
  • $\begingroup$ The freq.domain filter I'm using is simply the same size as the fft of the N samples. Why can't the resulting time-domain window theoretically be of the same size as the input window? $\endgroup$ Mar 30, 2020 at 21:55
  • $\begingroup$ @WantsToLearn there are 2 methods, overlap-save and overlap-add, the method which I explained is overlap-add, in this method the segments of signal don't overlap. In overlap-save method the segments of signal must have an overlap about the length of filter, but the excessive part of result is ignored. $\endgroup$
    – Mohammad M
    Mar 31, 2020 at 18:52
0
$\begingroup$

50% overlapped Von Hann windows have constant gain when simply summed together. No “pulsing”.

However if you filter each window separately, and don’t use zero-padding plus overlap add-save convolution, any filtering in the frequency domain will most likely not perform as you intend, as, depending on the impulse response of the filtering, changes to data in the window should affect and be affected by the data in other windows. (e.g. the effects of any frequency filtering tend to be more global, not just point local.)

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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