% Here is another method that gives the exact zeros. Scaled as decimation filter (DC Gain=1.0). Middle tap of 0.5. Equiripple error. M=2 ; % 1, 2, 3, 4, ... for length N=4*M+3... M!=0 for this script fp=0.1 ; % fraction of input sample rate F=[0 fp]; A=[0.5 0.5]; h0=firpm(2*(M+1)-1,F*4,A); % aka remez() h1=zeros(2,2*(M+1)); h1(1,:)=h0; h=reshape(h1,1,4*(M+1)); h(4*(M+1))=[]; h(2*M+2)=0.5 N=length(h); Enjoy, Dirk

# Halfband filter True or false?

Started by ●March 8, 2005

Reply by ●March 9, 20052005-03-09

Reply by ●March 9, 20052005-03-09

Symon wrote:> The inverse DFT of a brick wall filter is a sinc function. Unfortunately > this exists for all time so it's tricky to make a filter from it. You can > window the sinc function to limit it to a certain time period, depending on > how many taps you want. This gives you an approximation to a brick wall > filter. I wouldn't use this method, I like that Parks McCellan thingy. > Cheers, Syms.Syms, Have you tried to design a half-band filter using a Parks-McClellan program not specialized for it? The supposedly zero terms usually have small values, often large enough to disturb the filter's response if they are zeroed. Windowed-sync design is a quick fix that rarely needs more than an additional pair of taps to equal a constrained P-M design. ... Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������

Reply by ●March 9, 20052005-03-09

"Jerry Avins" <jya@ieee.org> wrote in message news:d_qdnYL5Jv1X27LfRVn-3g@rcn.net...> Syms, > > Have you tried to design a half-band filter using a Parks-McClellan > program not specialized for it? The supposedly zero terms usually have > small values, often large enough to disturb the filter's response if they > are zeroed. Windowed-sync design is a quick fix that rarely needs more > than an additional pair of taps to equal a constrained P-M design. >Hi Jerry, A while ago, I transcribed the Fortran program in Rabiner & Gold's book into Perl. (OK, I know that's mad, but at least I recognise it's mad!) I increased the accuracy of the variables and haven't looked back since, no problems with zero coeffs in half-band filters, they work great. (The Perl program is useful for tampering with the weighting function, IIRC I couldn't do that with MatLab) I should add that a lot of my DSP work is in FPGAs with high sample rates but with fixed point, typically 16 bit accuracy and maybe 19 or 20 tap filters. (39 taps with half band filters!) So, my accuracy isn't the greatest, any small inaccuracies from Parks-McClellan are not too important for my app. Having said all that, and now you've made me think about it properly, I must agree with you; the sinc method guarantees a half-band design with the zero coeffs exactly zero. Next time I need long filters and more accurate taps (which can cause P-M algorithms problems) I'll think about this thread. Thanks. Cheers, Syms. p.s. Half band FIR filters always have an odd number of taps, correct? p.p.s. OT, but that Perl/Fortran madness thing reminded me of Salvador Dali, "The only difference between me & a madman is that I am not mad."

Reply by ●March 9, 20052005-03-09

Symon wrote: ...> Hi Jerry, > A while ago, I transcribed the Fortran program in Rabiner & Gold's book into > Perl. (OK, I know that's mad, but at least I recognise it's mad!) I > increased the accuracy of the variables and haven't looked back since, no > problems with zero coeffs in half-band filters, they work great. (The Perl > program is useful for tampering with the weighting function, IIRC I couldn't > do that with MatLab) > I should add that a lot of my DSP work is in FPGAs with high sample rates > but with fixed point, typically 16 bit accuracy and maybe 19 or 20 tap > filters. (39 taps with half band filters!) So, my accuracy isn't the > greatest, any small inaccuracies from Parks-McClellan are not too important > for my app. > Having said all that, and now you've made me think about it properly, I must > agree with you; the sinc method guarantees a half-band design with the zero > coeffs exactly zero. Next time I need long filters and more accurate taps > (which can cause P-M algorithms problems) I'll think about this thread. > Thanks. > Cheers, Syms. > > p.s. Half band FIR filters always have an odd number of taps, correct?Yes.> p.p.s. OT, but that Perl/Fortran madness thing reminded me of Salvador Dali, > "The only difference between me & a madman is that I am not mad."That would make a good sig for you. I can't use it because I can't vouch for the last four words. You might modify your Perl code to force the zero taps while optimizing the rest. Windowed sinc is just a work-around for those who don't have that. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������

Reply by ●March 9, 20052005-03-09

"Symon" <symon_brewer@hotmail.com> wrote in message news:3990olF5v573eU1@individual.net...> "Jerry Avins" <jya@ieee.org> wrote in message > news:d_qdnYL5Jv1X27LfRVn-3g@rcn.net... >> Syms, >> >> Have you tried to design a half-band filter using a Parks-McClellan >> program not specialized for it? The supposedly zero terms usually have >> small values, often large enough to disturb the filter's response if they >> are zeroed. Windowed-sync design is a quick fix that rarely needs more >> than an additional pair of taps to equal a constrained P-M design. >> > Hi Jerry, > A while ago, I transcribed the Fortran program in Rabiner & Gold's book > into Perl. (OK, I know that's mad, but at least I recognise it's mad!) I > increased the accuracy of the variables and haven't looked back since, no > problems with zero coeffs in half-band filters, they work great. (The Perl > program is useful for tampering with the weighting function, IIRC I > couldn't do that with MatLab) > I should add that a lot of my DSP work is in FPGAs with high sample rates > but with fixed point, typically 16 bit accuracy and maybe 19 or 20 tap > filters. (39 taps with half band filters!) So, my accuracy isn't the > greatest, any small inaccuracies from Parks-McClellan are not too > important for my app. > Having said all that, and now you've made me think about it properly, I > must agree with you; the sinc method guarantees a half-band design with > the zero coeffs exactly zero. Next time I need long filters and more > accurate taps (which can cause P-M algorithms problems) I'll think about > this thread. Thanks. > Cheers, Syms. > > p.s. Half band FIR filters always have an odd number of taps, correct? > > p.p.s. OT, but that Perl/Fortran madness thing reminded me of Salvador > Dali, "The only difference between me & a madman is that I am not mad."In case you get lazy, you can get my program. It's much like the P-M and does halfband filters exactly out to around length 250 or so as I recall: ftp://ftp.mission-systems-inc.com/outgoing/Halfband/ Fred

Reply by ●March 9, 20052005-03-09

in article d_qdnYL5Jv1X27LfRVn-3g@rcn.net, Jerry Avins at jya@ieee.org wrote on 03/09/2005 13:56:> Have you tried to design a half-band filter using a Parks-McClellan > program not specialized for it? The supposedly zero terms usually have > small values, often large enough to disturb the filter's response if > they are zeroed. Windowed-sync design is a quick fix that rarely needs > more than an additional pair of taps to equal a constrained P-M design.i haven't fiddled that much with half-band P-M (using the MATLAB remez()) function, but i do have an implementation of it (you have to make sure that the filter spec and weighting factors are precisely symmetrical about half Nyquist). my experience with it the coefficients that aren't zero are so damn close that when i do force them to zero, it apparently changes nothing. if you have MATLAB, Jerry, i could send this to you. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."

Reply by ●March 9, 20052005-03-09

in article 3990olF5v573eU1@individual.net, Symon at symon_brewer@hotmail.com wrote on 03/09/2005 14:23:> The Perl > program is useful for tampering with the weighting function, IIRC I couldn't > do that with MatLab)dunno when that was, but the MATLAB remez() function (or firls()) that i have seen for a decade has a weighting vector as an argument. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."

Reply by ●March 9, 20052005-03-09

robert bristow-johnson wrote:> in article d_qdnYL5Jv1X27LfRVn-3g@rcn.net, Jerry Avins at jya@ieee.org wrote > on 03/09/2005 13:56: > > >>Have you tried to design a half-band filter using a Parks-McClellan >>program not specialized for it? The supposedly zero terms usually have >>small values, often large enough to disturb the filter's response if >>they are zeroed. Windowed-sync design is a quick fix that rarely needs >>more than an additional pair of taps to equal a constrained P-M design. > > > i haven't fiddled that much with half-band P-M (using the MATLAB remez()) > function, but i do have an implementation of it (you have to make sure that > the filter spec and weighting factors are precisely symmetrical about half > Nyquist). my experience with it the coefficients that aren't zero are so > damn close that when i do force them to zero, it apparently changes nothing. > > if you have MATLAB, Jerry, i could send this to you.I don't have Matlab and I haven't tried it in Scilab. The program I did use wasn't ad good as you describe. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������

Reply by ●March 10, 20052005-03-10

> SBA = 80; (stop band attenuation in dB) > t = linspace(-(N-1)/4, (N-1)/4, N); > h = (0.5*sinc(t)) .* kaiser(N, 0.1102*(SBA-8.7))'; % kaiser windowedsinc()> clear t;it's nice to have an exact form for Halfband filter rather than using a quite complex optimisation method. BTW i should have remembered the principles, they are in my school book => Proakis chapter 8.2.2 Design of Linear-phase FIR filter using Windows :-) thanks, Julien

Reply by ●March 10, 20052005-03-10

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. So, maybe I'm not quite so mad after all? (Yeah, right!) Cheers, Syms. "robert bristow-johnson" <rbj@audioimagination.com> wrote in message news:BE551367.51C8%rbj@audioimagination.com...> in article 3990olF5v573eU1@individual.net, Symon at > symon_brewer@hotmail.com > wrote on 03/09/2005 14:23: > >> The Perl >> program is useful for tampering with the weighting function, IIRC I >> couldn't >> do that with MatLab) > > dunno when that was, but the MATLAB remez() function (or firls()) that i > have seen for a decade has a weighting vector as an argument. >