# How can I load a wav file, split it in frames, apply different filters do different frames and then recombine the filtered frames into a single file?

I'm working on a wav audio file using MATLAB. What i would like to do is:

• load a wav file and divide it into frames of the same dimension
• filter these frames (with a different filter for each different frame) using, for instance, iirnotch
• put all the filtered frames together again without having discontinuities between them

I already wrote a script using the overlap-and-add technique using a "Hann" window and it works quite well but between the different frames I'm not able to avoid the discontinuities so that when I listen to the wav file (made by adding these frames together again) I hear an annoying glitch disturbance.

Anyone know how to avoid this problem?

• Can you post some code or exemplary plots of frames to be overlapped and which are causing you some problems? Smart way of averaging could be solution. How long is your window? Please provide more data. – jojek Jun 13 '14 at 16:59
• Are you doing FFT filtering or time-domain filtering on the frames? – endolith Jun 13 '14 at 20:52
• I'm using iirnotch on the time-domain frames – user10202 Jun 16 '14 at 10:28
• Ok, so time-domain IIR filtering – endolith Jun 16 '14 at 13:49

## 1 Answer

add technique using ann "hann" window and it works quite well but between the different frames I'm not able to avoid the discontinuities

That's probably because the filtering has tails that extend beyond the frame. The window is supposed to taper the signal to 0 at the edges, but after filtering it is no longer 0 at the edges, which introduces discontinuities.

Are you zero-padding before filtering to keep these response tails?

I believe you need to apply a sqrt(window) before filtering ("analysis window"), and then another sqrt(window) after filtering ("synthesis window"), so the combination is a normal window, and the tails are tapered to 0, and then overlap the windows by the appropriate amount so that they sum back to unity. Maybe also need to zero-pad before filtering so that the filtering tails don't wrap around, if you're doing FFT filtering, for instance. More information here: http://www.dsprelated.com/dspbooks/sasp/Weighted_Overlap_Add.html

(If you're doing positive-phase time-domain filtering, it might be sufficient to use a regular window, zero-pad before filtering, and then instead of windowing again, just keep the entire zero-pad region with the tail in it when you sum back together, but I haven't tried it so I'm not sure.)

• Hi, first of all: thanks a lot. Then: I tried to zero-padding and to apply a squared Hanning window before filtering and a squared Hanning window after filtering. The sound improves a lot but I have two problems: -lower in volume (but still present) discontinuities between frames; -very slow computational time (maybe is because I zero-pad too much?). Any other tips? – user10202 Jun 16 '14 at 10:23
• 1. You can zero-pad to a power of 2 size to improve computation time. 2. It should be sqrt(Hann), not Hann^2. 3. Even with Hann^2 window applied after filtering you should not have discontinuities, though. You need to plot the signal at each step of your process and see where the discontinuities are coming from. – endolith Jun 16 '14 at 14:11
• The problem was successfully solved using a power of 2 zero-padding, a sqrt(hann) window before filtering and a sqrt(hann) window after filtering. Thank you very much endolith! – user10202 Jun 17 '14 at 8:58