# How to pad a windowed sinc filter in the frequency domain

I'm creating windowed sinc filters to apply them to certain signals that I'm dealing with. To design the filters, I'm using the approach described in the book "The Scientist and Engineer's Guide to DSP". Here's a brief resuming:

$h[i] = \left\{ \begin{matrix} Kw(i)\frac{\sin(2\pi f_c(i - \frac{M}{2}))}{i - M/2} & 0\le i \le (M+1)\\ \\ 0 & \text{otherwise} \end{matrix} \right.$ $w(i): \text{A window function}\\ K: \text{DC gain}\\ f_c: \text{The cut frequency expressed as a fraction of the signal sampling rate}$

After calculating the filter kernel, I obtain the frequency response of the filter by taking the FFT of h[i] using an algorithm that approach the filter length to the nearest power of two(to get better performance). The same procedure it's also applied to the input signal in order to get its frequency response.

To my understanding, the next step would be multiply the two frequency responses to get the filtered signal in the frequency domain, but the problem is that both signals are not the same size and I haven't found an explanation on how to deal with this problem. So people, how should I pad the filter signal to make this point-wise multiplication? Should I fill the end of the filter with zeros to match with the signal size or should I do it symmetrically putting zeros to the left and right of the filter response?

Thanks in advance!

## 2 Answers

You don't pad it in the frequency domain, you pad it in the time domain (i.e. before you calculate the FFT). You can put the zeros either symmetrically or after the filter. Either way works, it just results in a shift in the output.

• Thanks @Jim Clay, actually I have found that this is known as the shifting rule: "A shift in the time domain by n results in a multiplication by a phase factor in the frequency domain" – dryleh Oct 28 '14 at 7:53

You will have to pad both $h[i]$ and the signal $x[i]$ with zeros so that both their lengths are atleast $M+N+1$ where $N$ is the length of $x[i]$. You can pad more so that the length of the padded vectors are powers of $2$.

This has to be done to ensure that circular convolution behaves like linear convolution.

• Why the downvote? The answer is correct!!! – Karthik Upadhya Oct 15 '14 at 8:42