Forums

Halfband filter True or false?

Started by jfgagne March 8, 2005
in article 39agtlF60h5mrU1@individual.net, Symon at symon_brewer@hotmail.com
wrote on 03/10/2005 04:05:

> Hi Robert, > So in Matlab there's a function gremez. > From the help:- > b = gremez(n,f,a,w) returns a length n+1 linear phase FIR filter which has > the best approximation to the desired frequency response described by f and > a in the minimax sense. w is a vector of weights, one per band. When you > omit w, all bands are weighted equally. > > One weight per band was no good to me, I wanted to change the weights > gradually over the whole frequency grid. You _can_ get gremez to call a > function to generate an arbitrary frequency response, but not for the > weighting function.
my old MATLAB doesn't have gremez() that i know of. i have used the regular remez() to split up a band and apply a set of differing magnitudes and weights to different frequencies and it has worked pretty well. i can't really tell what is the difference between the two remezs, with or without the g. what, explicitly, is the difference? -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
"robert bristow-johnson" <rbj@audioimagination.com> wrote in message 
news:BE55CC7D.51FC%rbj@audioimagination.com...
> > my old MATLAB doesn't have gremez() that i know of. i have used the > regular > remez() to split up a band and apply a set of differing magnitudes and > weights to different frequencies and it has worked pretty well. i can't > really tell what is the difference between the two remezs, with or without > the g. what, explicitly, is the difference?
Hi Robert, gremez, or generalised remez, has a few extra bells and whistles to do stuff like fix the gain at a frequency point. If you want more info, I could email you the manual page, just let me know. There's also a cremez. For "Complex and nonlinear phase equiripple FIR filter design". Best, Syms
On Tue, 08 Mar 2005 15:23:06 -0500, robert bristow-johnson
<rbj@audioimagination.com> wrote:



  (snipped)

Hi,
  this crappy Usenet software!!

I know Jean-Frederic personally, and I cannot 
see his original post!  Darn.

I sent Jean-Frederic some MATLAB software that 
I hopes helps a little.

[-Rick-]

in article 4231ae3a.264906781@news.sf.sbcglobal.net, Rick Lyons at
r.lyons@_BOGUS_ieee.org wrote on 03/11/2005 09:43:

> On Tue, 08 Mar 2005 15:23:06 -0500, robert bristow-johnson > <rbj@audioimagination.com> wrote: >
???
> > (snipped) > > Hi, > this crappy Usenet software!! > > I know Jean-Frederic personally, and I cannot > see his original post! Darn.
there's always Google Groups. http://groups-beta.google.com/group/comp.dsp/msg/2301df2a77f59c6c how did you extrapolate "Jean-Frederic" from jfgagne <jfgagne@amphitech.com> without seeing his post?
> I sent Jean-Frederic some MATLAB software that > I hopes helps a little.
wunnerful. if i had heard him request it, i could have done the same. or post it here. all you really need to do is specify a perfectly symmetrical frequency response (odd symmetry about Nyquist/4), with symmetrical weighting, to remez() or firls() and it designs it. because of numerical issues, the "zero" taps won't be exactly zero, so just kill them. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
On Fri, 11 Mar 2005 10:34:26 -0500, robert bristow-johnson
<rbj@audioimagination.com> wrote:

>in article 4231ae3a.264906781@news.sf.sbcglobal.net, Rick Lyons at >r.lyons@_BOGUS_ieee.org wrote on 03/11/2005 09:43: > >> On Tue, 08 Mar 2005 15:23:06 -0500, robert bristow-johnson >> <rbj@audioimagination.com> wrote: >> >??? >> >> (snipped) >> >> Hi, >> this crappy Usenet software!! >> >> I know Jean-Frederic personally, and I cannot >> see his original post! Darn. > >there's always Google Groups. >http://groups-beta.google.com/group/comp.dsp/msg/2301df2a77f59c6c
Hi R B-J, thanks. I'll use that "Google Groups" when I think I've missed an important post.
>how did you extrapolate "Jean-Frederic" from jfgagne <jfgagne@amphitech.com> >without seeing his post?
Well, I was at his company in Canada, and met him, last January. He's a good guy. He sent me a private E-mail about halfband filters, but he didn't send any frequency specs that *might* have allowed me to detect his problem of not specifying the center of the transition band exactly at Fs/4. [-Rick-]
"jfgagne" <jfgagne@amphitech.com> wrote in message 
news:Kr6dnfRfTtopZbDfRVn-sw@giganews.com...
> Hello everyone, > > I would like to confirm that even with a large number of coefficients it > is not possible to make a Halfband filter with narrow transition > bandwidth? > Ex.: Fpass=7MHz(-1dB tolerated), Fstop=8.125MHz with Astop=80dB > using Fsampling = 32.5 MHz > > I tried a few software tools and I couldn't calculate this filter. It > seems to me that I have to make it using a polyphase FIR. > > My goal was to use Halfband in order to minimize FPGA ressources!
JF, You got some good responses and perhaps some good private correspondence as well. In order to minimize FPGA resources I've built "halfband" filters using sums of powers of two coefficients. So, no multiplies, just shifts and adds. Ours were relatively short filters for video and there may be things in the FPGAs today that make multiplies cheaper... We simply started with halfband filter coefficients and quantized them. The center coefficient was always 0.5 or 1.0 (so no quantization) and we went from there accepting the errors in filter response that quantization caused. Of course, these filters were halfband exactly by definition*. And, one of the advantages is that almost half of the coefficients are zero and they are symmetric. *If you are wondering why that would be the case: Every pair of coefficients equidistant from the center of the filter provides an odd cosine term in the frequency response. All of these are zero at fs/4. Imagine the filter response F' without the center coefficient (which provides a constant term in frequency). Then the filter is antisymmetric around zero and fs/4 (it goes negative at fs/4 and goes positive again at 3fs/4 and looks like a zero-average "square wave" in frequency). The frequency response at f=0 is the sum of the coefficients. So F'(0) is the sum of the coefficients yeilding F'. If the constant coefficient is added that is equal to the sum of the other coefficients then it "raises" the frequency response by F'(0) so that the new response F(0) is 2*F'(0) and the response at fs/4 is F'(0) and the response at fs/2 is -F(fs/2) = [F'(0) + F'(0)] = 0 which is a nice way to define a halfband filter. Note that it isn't necessary that F(fs/2) be exactly zero. In fact, in minimax design it would be normal for the value at f=0 to be not 1.0 (if that is the passband criterion) but equal to one of the peaks of the error. Then, if the filter is antisymmetric as it should be, the value at fs/2 will be away from zero by the same amount. So, the process mentioned above doesn't generate the very best minimax filter - only a pretty good minimax filter because the end points are unecessarily constrained. A better minimax design will result if we allow the response at f=0 to differ from the desired response. Fred