DSPRelated.com
Forums

Why not just make FIRs by hand?

Started by mavavilj August 17, 2016
I'm looking to use the overlap-add FFT technique for doing FIR filtering
and many of the examples I've seen use some more known FIR design method
such as the window method for designing the FIR that will be convolved
with the input.

However,

To me it seems like in the overlap-add FFT technique it should be possible
to define the FIR by hand by simply drawing the frequency response as
values in the range [0,1] into an array of FFT length (or shorter if the
array is then padded with zeros to match FFT length).

So a lowpass filter could look like:

[... 1 1 ... 0.999 0.998 ... 0.02 0.01 0 0 ...]

So why doesn't one then create all such FIRs applied by the overlap-add
FFT technique by this way, rather than using some of the more technical
methods?
---------------------------------------
Posted through http://www.DSPRelated.com
mavavilj wrote:
> I'm looking to use the overlap-add FFT technique for doing FIR filtering > and many of the examples I've seen use some more known FIR design method > such as the window method for designing the FIR that will be convolved > with the input. > > However, > > To me it seems like in the overlap-add FFT technique it should be possible > to define the FIR by hand by simply drawing the frequency response as > values in the range [0,1] into an array of FFT length (or shorter if the > array is then padded with zeros to match FFT length). > > So a lowpass filter could look like: > > [... 1 1 ... 0.999 0.998 ... 0.02 0.01 0 0 ...] > > So why doesn't one then create all such FIRs applied by the overlap-add > FFT technique by this way, rather than using some of the more technical > methods? > --------------------------------------- > Posted through http://www.DSPRelated.com >
The elements of an FIR are not the same thing as the sliders on a graphic EQ. Frequency domain and time domain are different. -- Les Cargill
This question seems to come up on comp.dsp more often than any other question. Someone should really write a short paper that we can point people to. 

When you design an fft-based filter, you must choose the "hop size", which is how many new samples come into your input buffer before you trigger the fft. Each real and imaginary fft bin output is equivalent to a decimated FIR filter where the fir coefficients are the cos and sin values for that bin and the decimation factor is equal to the hop size. Since this new signal is at a lower sample-rate, it will have spectral images relative to the original sample-rate.  

When you perform the inverse fft and the overlap-add reconstruction, the images that were created by the decimation cancel out if you have not modified any of the bin values. If you do modify the bin values according to a filter you drew, then the images only cancel out IF YOU MEET CERTAIN CONDITIONS that were outlined by RBJ here a few months ago. I suggest you read his post. But in general a "drawn " curve will not meet these conditions , which means that when you enter a sine wave into your filter , you will get extra frequencies appearing at the output. 
Of course you could always set the hop size to 1 sample , but that would destroy the computational efficiency of the fft filter approach. 

Bob
On Wednesday, August 17, 2016 at 9:56:29 AM UTC-4, radam...@gmail.com wrote:
> This question seems to come up on comp.dsp more often than any other question. Someone should really write a short paper that we can point people to. > > When you design an fft-based filter, you must choose the "hop size", which is how many new samples come into your input buffer before you trigger the fft. Each real and imaginary fft bin output is equivalent to a decimated FIR filter where the fir coefficients are the cos and sin values for that bin and the decimation factor is equal to the hop size. Since this new signal is at a lower sample-rate, it will have spectral images relative to the original sample-rate. > > When you perform the inverse fft and the overlap-add reconstruction, the images that were created by the decimation cancel out if you have not modified any of the bin values. If you do modify the bin values according to a filter you drew, then the images only cancel out IF YOU MEET CERTAIN CONDITIONS that were outlined by RBJ here a few months ago. I suggest you read his post. But in general a "drawn " curve will not meet these conditions , which means that when you enter a sine wave into your filter , you will get extra frequencies appearing at the output. > Of course you could always set the hop size to 1 sample , but that would destroy the computational efficiency of the fft filter approach. >
i dunno where that post is. but the crux of the Overlap-Add or Overlap-Save is that the length of the FIR (which i call "L") and the length of the frame hop (which i call "H") must not add to more than 1 more than the length of the FFT (which i call "N"), otherwise time aliasing occurs in using the circular convolution (which is the only kinda convolution you can do with the FFT) and you have trouble applying that to linear convolution. so L + H <= N+1 or L <= N - H + 1 and as Bob sez, drawing any old arbitrary frequency response does not guarantee that the above inequality holds. what you *can* do is draw any old arbitrary frequency response, iFFT it, window that impulse response to the length L and take your lumps as to how the frequency response gets changed. good windows (like Kaiser) might do better than bad windows and your resulting frequency response might look a lot like what you originally drew in. r b-j
On 17.08.16 10.25, mavavilj wrote:
> I'm looking to use the overlap-add FFT technique for doing FIR filtering > and many of the examples I've seen use some more known FIR design method > such as the window method for designing the FIR that will be convolved > with the input. > > However, > > To me it seems like in the overlap-add FFT technique it should be possible > to define the FIR by hand by simply drawing the frequency response as > values in the range [0,1] into an array of FFT length (or shorter if the > array is then padded with zeros to match FFT length). > > So a lowpass filter could look like: > > [... 1 1 ... 0.999 0.998 ... 0.02 0.01 0 0 ...]
It won't work. Note that the FIR kernel length is less than the FFT length and the iFFT of the design function *must not* return non zero values outside the FIR length. So you can draw your design function this way, but within the frequency domain of an FIR length transformation. After that you need to transform your design function into an FFT of the final FFT length. This is basically an iFT followed by padding with zeros and finally by an FFT. The result may still be poor because of window effects. I.e. if your target response has too large dH/domega (change of transfer amplitude over frequency) or dphi/domega (group delay) relative to the FIR kernels bin size in the frequency domain than the filter will have aliasing artifacts in the transfer function, e.g. ringing. So in fact you need at least a rectangular window to avoid that the non-zero values of the iFT of your target response that exceed the FIR kernel length wrap around to the other side of the kernel.
> So why doesn't one then create all such FIRs applied by the overlap-add > FFT technique by this way, rather than using some of the more technical > methods?
Because it doesn't work. Marcel
On Wednesday, August 17, 2016 at 8:41:08 PM UTC+3, robert bristow-johnson wrote:
> what you *can* do is draw any old arbitrary frequency response, iFFT it, window that impulse response to the length L and take your lumps as to how the frequency response gets changed. good windows (like Kaiser) might do better than bad windows and your resulting frequency response might look a lot like what you originally drew in. > > r b-j
What's this FIR design method called?
On Wednesday, August 17, 2016 at 8:41:08 PM UTC+3, robert bristow-johnson wrote:
> what you *can* do is draw any old arbitrary frequency response, iFFT it, window that impulse response to the length L and take your lumps as to how the frequency response gets changed. good windows (like Kaiser) might do better than bad windows and your resulting frequency response might look a lot like what you originally drew in. > > r b-j
What's this FIR design method called? Are there some other "arbitrary response" FIR filter design methods suited to be applied using the overlap-add method?
On Thursday, August 18, 2016 at 6:11:20 AM UTC-5, mavavil...@gmail.com wrote:

> What's this FIR design method called?
First principles.
> Are there some other "arbitrary response" FIR filter design methods suited to be applied using the overlap-add method?
You can implement any arbitrary response FIR filter using overlap-and-add, if you adhere to the circular-convolution constraints outlined by RB-J.
On Thu, 18 Aug 2016 04:10:58 -0700, mavaviljggroup wrote:

> On Wednesday, August 17, 2016 at 8:41:08 PM UTC+3, robert > bristow-johnson wrote: >> what you *can* do is draw any old arbitrary frequency response, iFFT >> it, window that impulse response to the length L and take your lumps as >> to how the frequency response gets changed. good windows (like Kaiser) >> might do better than bad windows and your resulting frequency response >> might look a lot like what you originally drew in. >> >> r b-j > > What's this FIR design method called? > > Are there some other "arbitrary response" FIR filter design methods > suited to be applied using the overlap-add method?
I think it's called the "Bristow-Johnson". At least it is now, here. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com I'm looking for work -- see my website!
On Thursday, August 18, 2016 at 10:20:50 PM UTC+3, Tim Wescott wrote:
> On Thu, 18 Aug 2016 04:10:58 -0700, mavaviljggroup wrote: > > > On Wednesday, August 17, 2016 at 8:41:08 PM UTC+3, robert > > bristow-johnson wrote: > >> what you *can* do is draw any old arbitrary frequency response, iFFT > >> it, window that impulse response to the length L and take your lumps as > >> to how the frequency response gets changed. good windows (like Kaiser) > >> might do better than bad windows and your resulting frequency response > >> might look a lot like what you originally drew in. > >> > >> r b-j > > > > What's this FIR design method called? > > > > Are there some other "arbitrary response" FIR filter design methods > > suited to be applied using the overlap-add method? > > I think it's called the "Bristow-Johnson". At least it is now, here. > > -- > > Tim Wescott > Wescott Design Services > http://www.wescottdesign.com > > I'm looking for work -- see my website!
I think the method is also described here: http://www.dspguide.com/ch17/1.htm