If you were designing a FIR filter to pass as narrow a band as possible how would that be done? A DFT seems to be essentially a bank of band pass filters (with decimation) and use various sine wave as the filter coefficients. Is this optimal? Is there a better way to calculate the coefficients for a narrow band pass filter of a fixed length? Rick
DFT vs Bandpass Filter
Started by ●January 14, 2013
Reply by ●January 14, 20132013-01-14
rickman <gnuarm@gmail.com> wrote:> If you were designing a FIR filter to pass as narrow a band as possible > how would that be done? A DFT seems to be essentially a bank of band > pass filters (with decimation) and use various sine wave as the filter > coefficients. Is this optimal? Is there a better way to calculate the > coefficients for a narrow band pass filter of a fixed length?Without going too far into it, I think it depends on what you mean by optimal. Ideally, the DFT should be the full length of the input, but that is usually not convenient. Otherwise, you have to consider aliasing and windows and such, and if you don't, it seems to me that it is less than ideal. As well as I understand it (maybe not so well) the optimal (narrowest for the filter length) is Gaussian. Well, put another way, sharp corners in the response function will require a longer filter, and the optimal positive peak function, for narrow width and not so sharp edge, is Gaussian. Not that I have ever tried to build one. -- glen
Reply by ●January 14, 20132013-01-14
"rickman" <gnuarm@gmail.com> wrote in message news:kd26u6$hk1$1@dont-email.me...> If you were designing a FIR filter to pass as narrow a band as possible > how would that be done?There is approximately bazillion of ways depending on what and how.> A DFT seems to be essentially a bank of band pass filters (with > decimation) and use various sine wave as the filter coefficients. Is this > optimal?Optimal in which sense?> Is there a better way to calculate the coefficients for a narrow band pass > filter of a fixed length?Sure. Actually, there are two ways: do it yourself or ask someone who has a clue. Or is that bleat again about WWWB thing? VLV
Reply by ●January 14, 20132013-01-14
On 1/14/13 7:49 PM, Vladimir Vassilevsky wrote:> "rickman"<gnuarm@gmail.com> wrote in message > news:kd26u6$hk1$1@dont-email.me... >> If you were designing a FIR filter to pass as narrow a band as possible >> how would that be done? > > There is approximately bazillion of ways depending on what and how. > >> A DFT seems to be essentially a bank of band pass filters (with >> decimation) and use various sine wave as the filter coefficients. Is this >> optimal? > > Optimal in which sense? > >> Is there a better way to calculate the coefficients for a narrow band pass >> filter of a fixed length? > > Sure. Actually, there are two ways: do it yourself or ask someone who has a > clue. > > Or is that bleat again about WWWB thing? >Vlad's being a meanie again. one way that the DFT is a filter bank is with something called the "dirichet kernel". when a single bin is 1 and all the other bins are zero, and if your filter bank output is bandlimited to Nyquist, then there are non-zero ripples between your zero bins. that is what the BPF is for a single bin in the DFT. another way a DFT is a bank of BPFs is, if you're gonna be absolutely glitch free, is when the DFT or FFT is doing "fast convolution". that is implementing a linear, time-invariant system. *and* it's an FIR. simple enough. when used for any of these "time-frequency" applications like a phase vocoder or some kinda sinusoidal modeling, then the DFT is doing something other than an FIR. but when the DFT is used to implement an FIR by use of fast convolution, then you got the order of design wrong, methinks. first the FIR coefficients are determined (like the impulse response of the interior of a cathedral or something). but it *could* be a very sharp BPF designed using the Parks-McClellan alg or something like that. then you DFT it for the frequency-domain and see what it is, but the DFT is -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Reply by ●January 15, 20132013-01-15
On Monday, January 14, 2013 4:11:48 PM UTC-8, rickman wrote: 1) >If you were designing a FIR filter to pass as narrow a band as possible how would that be done? That depends on all of the fine detail in the complete specification of the filter and what you need to be able to do with the filter output. You haven't given anywhere near enough information to get a meaningful answer. 2) >A DFT seems to be essentially a bank of band pass filters (with decimation) and use various sine wave as the filter coefficients. An N point DFT can calculate a single time domain sample for each of N bandpass filters, equally spaced from DC up at spacing of Fs/N with the filter center frequencies shifted to DC and a filter shape that is the frequency response of the window coefficients. If the window is smaller than N, fill up to N with zeros. If the windowed data is larger than N, break it into contiguous N point blocks and sum the blocks before performing the N point DFT. The decimation is the number of samples you slide the window along the data before applying the window to the data again to repeat the process for the next time domain sample from all the filters with the next DFT. 3) > Is this optimal? Optimal has no meaning without an answer to "With respect to what?". Minimal number of arithmetic operations? Minimal memory locations used by data and code in a particular hardware implementation? Fewest blocks in the block diagram? Least DSP design time for a particular engineer? Do you mean "Is the DFT implementation good?". Maybe if you need to use enough of the filters calculated. If you only need 1 filter you can do better by only making the calculation for a single DFT bin, if that produces a useful result. Whether you can do better than that depends on the missing fine detail from 1). 4) > Is there a better way to calculate the coefficients for a narrow band pass filter of a fixed length? If you have a fixed length, it should be given as part of item 1).> RickIf you can't come up with the detail to define an meaningful question, try explaining the application, performance and the intended implementation environment. Dale B. Dalrymple
Reply by ●January 15, 20132013-01-15
On Mon, 14 Jan 2013 19:11:48 -0500, rickman wrote:> If you were designing a FIR filter to pass as narrow a band as possible > how would that be done?Make it really long. A FIR filter's bandwidth is roughly inversely proportional to its length.> A DFT seems to be essentially a bank of band > pass filters (with decimation) and use various sine wave as the filter > coefficients. Is this optimal?For what? The DFT can be viewed as a bank of bandpass filters, yes. But they're basically bandpass-ized boxcar filters, and the boxcar filter isn't usually the best filter in the world.> Is there a better way to calculate the > coefficients for a narrow band pass filter of a fixed length?Yes. Start with what you really need and with the constraints that you really have, then find a filter that delivers the first while staying within the latter. Or, at least show that any filter that stays within the latter is going to fail to deliver the first. A bandpass filter design method that generally works is to design a lowpass filter that matches the envelope of the bandpass filter that you desire, then to multiply the coefficients of of that lowpass prototype by a sine wave at the desired filter center frequency. Note, however, that the higher your ratio of carrier frequency to bandwidth gets, the less efficient it is to retain the same sampling rate throughout -- the narrower your filter gets, the more redundant your samples get. At some point your overall system will be less complex (or at least less large) if you heterodyne, roughly filter, and decimate. And note: the heterodyne, filter, and decimate process is going to be mathematically equivalent to bandpass filter + decimate: it's just going to use fewer computational resources on your processor or FPGA. -- My liberal friends think I'm a conservative kook. My conservative friends think I'm a liberal kook. Why am I not happy that they have found common ground? Tim Wescott, Communications, Control, Circuits & Software http://www.wescottdesign.com
Reply by ●January 15, 20132013-01-15
On 1/15/2013 12:22 PM, Tim Wescott wrote:> On Mon, 14 Jan 2013 19:11:48 -0500, rickman wrote: > >> If you were designing a FIR filter to pass as narrow a band as possible >> how would that be done? > > Make it really long. A FIR filter's bandwidth is roughly inversely > proportional to its length.Sorry that the question doesn't have more info. I'm just trying to understand some of the issues, not solve a problem... at least not directly. I understand that the length of the filter limits the frequency resolution of the filter. Let's say the filter is 1000 samples long. A DFT for the bin that is 1/4 of Fs would consist of coefficients of 1, 0, -1, 0,... This could be viewed as a FIR filter with the same coefficients with decimation by 1000.>> A DFT seems to be essentially a bank of band >> pass filters (with decimation) and use various sine wave as the filter >> coefficients. Is this optimal? > > For what? The DFT can be viewed as a bank of bandpass filters, yes. But > they're basically bandpass-ized boxcar filters, and the boxcar filter > isn't usually the best filter in the world.Not sure what that term means, "bandpass-ized". If you wanted to get the sharpest bandpass possible within the constraints of the sample rate and filter length, is there a better set of coefficients? If so, why aren't they used in the DFT? I understand the theory behind the Fourier transform... at least at and initial level. But a DFT is not really the same as the Fourier is it? It is really a filter bank, no? Why not optimize the filters?>> Is there a better way to calculate the >> coefficients for a narrow band pass filter of a fixed length? > > Yes. Start with what you really need and with the constraints that you > really have, then find a filter that delivers the first while staying > within the latter. Or, at least show that any filter that stays within > the latter is going to fail to deliver the first. > > A bandpass filter design method that generally works is to design a > lowpass filter that matches the envelope of the bandpass filter that you > desire, then to multiply the coefficients of of that lowpass prototype by > a sine wave at the desired filter center frequency. > > Note, however, that the higher your ratio of carrier frequency to > bandwidth gets, the less efficient it is to retain the same sampling rate > throughout -- the narrower your filter gets, the more redundant your > samples get. At some point your overall system will be less complex (or > at least less large) if you heterodyne, roughly filter, and decimate. > > And note: the heterodyne, filter, and decimate process is going to be > mathematically equivalent to bandpass filter + decimate: it's just going > to use fewer computational resources on your processor or FPGA.Really? Seems to me it would be the same amount of processing, that is if you consider the decimation when you do the filtering. In fact, that is what started me thinking about this. It seems to me all three are equivalent mathematically, FIR(sine wave for coefficients)+decimate, Downconvert+decimate, one bin of a DFT(which incorporates the decimation). That's what made me ask about the FIR filter for the narrow bandpass. Would there be coefficients that give a sharper bandpass than a sine wave of the center frequency? I guess this assumes the FIR filter coefficients are complex. Rick
Reply by ●January 16, 20132013-01-16
On Tue, 15 Jan 2013 18:55:21 -0500, rickman wrote:> On 1/15/2013 12:22 PM, Tim Wescott wrote: >> On Mon, 14 Jan 2013 19:11:48 -0500, rickman wrote: >> >>> If you were designing a FIR filter to pass as narrow a band as >>> possible how would that be done? >> >> Make it really long. A FIR filter's bandwidth is roughly inversely >> proportional to its length. > > Sorry that the question doesn't have more info. I'm just trying to > understand some of the issues, not solve a problem... at least not > directly. > > I understand that the length of the filter limits the frequency > resolution of the filter. Let's say the filter is 1000 samples long. A > DFT for the bin that is 1/4 of Fs would consist of coefficients of 1, 0, > -1, 0,... This could be viewed as a FIR filter with the same > coefficients with decimation by 1000.See my comments below on the DFT and decimation.>>> A DFT seems to be essentially a bank of band pass filters (with >>> decimation) and use various sine wave as the filter coefficients. Is >>> this optimal? >> >> For what? The DFT can be viewed as a bank of bandpass filters, yes. >> But they're basically bandpass-ized boxcar filters, and the boxcar >> filter isn't usually the best filter in the world. > > Not sure what that term means, "bandpass-ized".It's what I'm talking about below. If you view the process of getting to each bin in a DFT as a bandpass filter, then that bandpass filter can be arrived at with a moving-average ("boxcar") filter that's been multiplied by the band center frequency.> If you wanted to get > the sharpest bandpass possible within the constraints of the sample rate > and filter length, is there a better set of coefficients?"Sharpest" in this case is misleading. If you wanted to get the best- behaved filter within the constraints of sample rate and filter length, yes there are better sets of coefficients.> If so, why aren't they used in the DFT?Because then it wouldn't be the DFT. It would just be a bank of filters.> I understand the theory behind the Fourier transform... at least at and > initial level. But a DFT is not really the same as the Fourier is it?No, a DFT is not "the same as the" Fourier. The DFT is _one of_ the four flavors of Fourier transform. Study up on more Fourier, you'll get to it.> It is really a filter bank, no?It is really a filter bank, yes. But it is really not _just_ a filter bank. It is a specific mathematical transform that, if you hold it up to the light just right _happens to be_ a filter bank, too.> Why not optimize the filters?Because (a) there is no global optimal filter, just an optimal filter for the problem at hand, and (b) because it would lose a whole bunch of the qualities that make it a useful tool for frequency-domain analysis.>>> Is there a better way to calculate the coefficients for a narrow band >>> pass filter of a fixed length? >> >> Yes. Start with what you really need and with the constraints that you >> really have, then find a filter that delivers the first while staying >> within the latter. Or, at least show that any filter that stays within >> the latter is going to fail to deliver the first. >> >> A bandpass filter design method that generally works is to design a >> lowpass filter that matches the envelope of the bandpass filter that >> you desire, then to multiply the coefficients of of that lowpass >> prototype by a sine wave at the desired filter center frequency. >> >> Note, however, that the higher your ratio of carrier frequency to >> bandwidth gets, the less efficient it is to retain the same sampling >> rate throughout -- the narrower your filter gets, the more redundant >> your samples get. At some point your overall system will be less >> complex (or at least less large) if you heterodyne, roughly filter, and >> decimate. >> >> And note: the heterodyne, filter, and decimate process is going to be >> mathematically equivalent to bandpass filter + decimate: it's just >> going to use fewer computational resources on your processor or FPGA. > > Really? Seems to me it would be the same amount of processing, that is > if you consider the decimation when you do the filtering. In fact, that > is what started me thinking about this. It seems to me all three are > equivalent mathematically, FIR(sine wave for coefficients)+decimate, > Downconvert+decimate, one bin of a DFT(which incorporates the > decimation).The DFT does not incorporate the decimation. If you happen to do your DFTs on adjoint but disjoint sample sets then decimation is happening, but it is happening because _you_ made it happen that way. There's no reason you can't do a DFT, shift a new sample in and an old sample out, then do it again. Your three options are all similar, and with the decimation the computational load becomes similar.> That's what made me ask about the FIR filter for the narrow bandpass. > Would there be coefficients that give a sharper bandpass than a sine > wave of the center frequency? I guess this assumes the FIR filter > coefficients are complex.If you are processing real data, then your FIR bandpass filter can have real values. You must be careful in how you perform the decimation, however -- at some point you may find it convenient to sample in quadrature. -- My liberal friends think I'm a conservative kook. My conservative friends think I'm a liberal kook. Why am I not happy that they have found common ground? Tim Wescott, Communications, Control, Circuits & Software http://www.wescottdesign.com
Reply by ●January 16, 20132013-01-16
Lets construct a practical case. Assume you have a sine-wave buried in white noise, and you are asked to design a filter that will give the best snr with a given length filter. Further assume that the sine wave is in the middle of an fft bin. I THINK the answer is the simple un-windowed dft cosine/sin filter. Filters that have better attenuation will all have a wider main lobe, which lets in more noise power than you gain from the improved attenuation. Bob
Reply by ●January 16, 20132013-01-16
On Wed, 16 Jan 2013 06:43:41 -0800, Robert Adams wrote:> Lets construct a practical case. Assume you have a sine-wave buried in > white noise, and you are asked to design a filter that will give the > best snr with a given length filter. Further assume that the sine wave > is in the middle of an fft bin. I THINK the answer is the simple > un-windowed dft cosine/sin filter. Filters that have better attenuation > will all have a wider main lobe, which lets in more noise power than you > gain from the improved attenuation.Well, yes. But you can take just about any arbitrary linear filter and fairly easily construct an infinite number of cases for which that filter is optimal. The fact that a simple boxcar-bandpass filter happens to be optimal in a simple case is interesting, but not earth-shaking. In this case I'm almost certain that your "one FFT bin" is optimal. But in a lot of other practical cases (most notably radio, where you can expect a quiet band around your desired signal with unpredictably large noise outside of that) it most certainly won't be. -- My liberal friends think I'm a conservative kook. My conservative friends think I'm a liberal kook. Why am I not happy that they have found common ground? Tim Wescott, Communications, Control, Circuits & Software http://www.wescottdesign.com






