Reply by jim June 29, 20052005-06-29

Andor wrote:
> > Karin, > > you are right, antisymmetric FIR filters are also linear phase. I > looked it up [1]: the characterizing condition (if and only if) for > linear phase response of an FIR filter with impulse response h[n] of > order N, with h[0] =/= 0 =/= h[N], is given by > > h[n] = d h*[N-n], (1) > > where d is a complex number of length 1 ( |d| = 1 ). If you want real > coefficients, then condition (1) reduces to > > h[n] = +/- h[N-n],
well, not quite, that would be sloppy and could be misleading. It still would be h[n] = d * h[N-n] where d = 1 or -1 d has to be the same value for all n. -jim ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Reply by Karin Dressler June 29, 20052005-06-29
Wow, thank you! Again I've learned something!
Karin

"Andor" <an2or@mailcircuit.com> schrieb im Newsbeitrag 
news:1120046220.795848.195950@g44g2000cwa.googlegroups.com...
> Karin, > > you are right, antisymmetric FIR filters are also linear phase. I > looked it up [1]: the characterizing condition (if and only if) for > linear phase response of an FIR filter with impulse response h[n] of > order N, with h[0] =/= 0 =/= h[N], is given by > > h[n] = d h*[N-n], (1) > > where d is a complex number of length 1 ( |d| = 1 ). If you want real > coefficients, then condition (1) reduces to > > h[n] = +/- h[N-n], > > ie. symmetric or antisymmetric impulse response. > > Regards, > Andor > > [1] Vaidyanathan, "Multirate Systems and Filter Banks", see chapter > "Linear Phase Filters" >
Reply by Karin Dressler June 29, 20052005-06-29
Yes, this is also a linear phase condition like Andor pointed out correctly.

Sorry, if I put you on the wrong way in my first post... but I corrected it 
here:

"Karin Dressler" <muncho@web.de> schrieb im Newsbeitrag 
news:d9ttqs$cg4$1@online.de...
> Uff, I guess you are right. To be honest, I have copied + pasted this one > sentence from the web page http://www.dspguru.com/info/faqs/fir/props.htm > :-( I should be more carefull doing that! > Of course an FIR is also linear phase if it satisfies : h[n] = - h[L-n-1] > for n = 0...L-1 Then it is called antisymmetric, isn't it? But in the end > it looks also like a kind of symmetry to me ;-) > > Karin
PS: regarding your code, it is always safe to convert i to float or double before using it in your formula. Don't know about compiler behaviour in this special case, but if you put ( double ) i it is clear. Karin <aine_canby@yahoo.com> schrieb im Newsbeitrag news:1120045207.647633.311640@g47g2000cwa.googlegroups.com...
> Cheers everyone, > > What about a high pass filter? For an odd number of taps I worked out > that you could just change the sign of every second coef.The first > being even the second odd etc. But what about an even number of taps? > You end up with - > > b[n] = -b[ L-n-1] rather than b[n] = b[ L-n-1] > > Does this give linear phase? The remez plot suggests it does, but I'm > still not sure. Here's my code for the lowpass and thanks again. > > #include <stdio.h> > #include <stdlib.h> > #include <math.h> > > double sinc(double t); > > #define PI ( 3.141592653589793 ) > #define L 1024 > #define R 5 > > int main() > { > FILE *Fp; > > Fp = fopen("coef.dat", "w"); > > for(int i=0;i<L;i++) > { > > fprintf(Fp,"%lf\t", > 1/double(R)*sinc((i-((L-1)/2.0))/double(R))*(0.54-0.46*cos(2*PI*i/double(L-1))) > ); > } > return EXIT_SUCCESS; > } > > double sinc(double t) > { > if(t) > return sin(PI*t)/(PI*t); > else > return 1; > } >
Reply by Andor June 29, 20052005-06-29
Karin,

you are right, antisymmetric FIR filters are also linear phase. I
looked it up [1]: the characterizing condition (if and only if)  for
linear phase response of an FIR filter with impulse response h[n] of
order N, with h[0] =/= 0 =/= h[N], is given by

h[n] = d h*[N-n],                    (1)

where d is a complex number of length 1 ( |d| = 1 ). If you want real
coefficients, then condition (1) reduces to

h[n] = +/- h[N-n],

ie. symmetric or antisymmetric impulse response.

Regards,
Andor

[1] Vaidyanathan, "Multirate Systems and Filter Banks",  see chapter
"Linear Phase Filters"

Reply by June 29, 20052005-06-29
Cheers everyone,

What about a high pass filter? For an odd number of taps I worked out
that you could just change the sign of every second coef.The first
being even the second odd etc. But what about an even number of taps?
You end up with -

b[n] = -b[ L-n-1] rather than b[n] = b[ L-n-1]

Does this give linear phase? The remez plot suggests it does, but I'm
still not sure. Here's my code for the lowpass and thanks again.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

double sinc(double t);

#define PI ( 3.141592653589793 )
#define L 1024
#define R 5

int main()
{
   FILE *Fp;

   Fp = fopen("coef.dat", "w");

	for(int i=0;i<L;i++)
	{

		fprintf(Fp,"%lf\t",
1/double(R)*sinc((i-((L-1)/2.0))/double(R))*(0.54-0.46*cos(2*PI*i/double(L-1)))
   );
	}
	return EXIT_SUCCESS;
}

double sinc(double t)
{
	if(t)
		return sin(PI*t)/(PI*t);
	else
		return 1;
}

Reply by Karin Dressler June 29, 20052005-06-29
Uff, I guess you are right. To be honest, I have copied + pasted this one 
sentence from the web page http://www.dspguru.com/info/faqs/fir/props.htm 
:-( I should be more carefull doing that!
Of course an FIR is also linear phase if it satisfies : h[n] = - h[L-n-1] 
for n = 0...L-1  Then it is called antisymmetric, isn't it? But in the end 
it looks also like a kind of symmetry to me ;-)

Karin

"Andor" <an2or@mailcircuit.com> schrieb im Newsbeitrag 
news:1120036884.916167.293210@g44g2000cwa.googlegroups.com...
> Karin wrote: > >> A FIR filter is linear-phase if (and only if) its coefficients are >> symmetrical >> around the center coefficient, that is, the first coefficient is the same >> as >> the last; the second is the same as the next-to-last, etc. > > Hello Karin, I'm not sure about that second "if". I think hermitian > symmetric FIRs are also linear-phase ... > > Regards, > Andor >
Reply by Karin Dressler June 29, 20052005-06-29
Hi Andor!
Uff, I guess you are right. To be honest, I have copied + pasted this one 
sentence from the web page http://www.dspguru.com/info/faqs/fir/props.htm 
:-( I should be more carefull doing that!
Of course an FIR is also linear phase if it satisfies :  . Then it is called 
antisymmetric, isn't it? But in the end it looks also like a kind of 
symmetry to me ;-)

Regards,
Karin

"Andor" <an2or@mailcircuit.com> schrieb im Newsbeitrag 
news:1120036884.916167.293210@g44g2000cwa.googlegroups.com...
> Karin wrote: > >> A FIR filter is linear-phase if (and only if) its coefficients are >> symmetrical >> around the center coefficient, that is, the first coefficient is the same >> as >> the last; the second is the same as the next-to-last, etc. > > Hello Karin, I'm not sure about that second "if". I think hermitian > symmetric FIRs are also linear-phase ... > > Regards, > Andor >
begin 666 9.2_7.gif M1TE&.#EA=@`/`( ``````/___RP`````=@`/```"GHR/J<OM#Z.<M-J+L]Z\ M>P0`22@NY'>$HQJ<AAN5&MR.D(SBM9U.+"?3[1Q"H$+(*A(]P5;S)?H-/]%G MKZ1L9!DJ:3#:2X'#(!(M-I[6L)4M-SUDOT!S,L5,DZO92#RNZ/=7-Z@G..5V M4<@#%V.AM_/XI-.'=S=X2->FN5?W(VE(!44&@[A2&N:U]'"ZP8IR0R15YIIQ +]MHF>ZN[JU$``#L` ` end
Reply by Rune Allnor June 29, 20052005-06-29

aine_canby@yahoo.com wrote:
> Thanks Jerry. > > As part of my class project, I have to produce the coefs myself. > > I'm happy enough now with what I have, just wondering though about the > implementation of a 256 tap filter. Should I simply calculate for 255 > taps and then leave the last tap empty, or is there a version the > following equation for even numbered taps - > > h[n] = (1/R)sinc(n/R) n =-16 to 16
Here you hit n/R = 0 for n = 127 or so. For even numbers of taps, displace the sinc slightly: h[n]= 1/R sinc((n-0.5)/R) (it could be that the sign should be "+" instead of "-"...) This should give you an even symmetric sinc pulse where h[n] = h[N-n], n=0,...,N/2. Rune
Reply by Andor June 29, 20052005-06-29
Karin wrote:

> A FIR filter is linear-phase if (and only if) its coefficients are symmetrical > around the center coefficient, that is, the first coefficient is the same as > the last; the second is the same as the next-to-last, etc.
Hello Karin, I'm not sure about that second "if". I think hermitian symmetric FIRs are also linear-phase ... Regards, Andor
Reply by Karin Dressler June 29, 20052005-06-29
Hi Ann!

Your FIR filter should be designed to be linear-phase. A FIR filter is 
linear-phase if (and only if) its coefficients are symmetrical around the 
center coefficient, that is, the first coefficient is the same as the last; 
the second is the same as the next-to-last, etc. (A linear-phase FIR filter 
having an odd number of coefficients will have a single coefficient in the 
center which has no mate.)   b[n] = b[ L-n-1]! So it's not a good idea to 
just throw one coefficient away to get an even numbered filter! If your two 
functions fullfill the abovementioned criterium, you are on a good way:

So you may write for your window function: 0.54 + 0.46 * sin( 2*PI*n/ 
(L-1) ) ( since n = 0.... L-1 )

or in C++ pseudo code: w[n] =  0.54 + 0.46 * sin (2. * PI * (float) n / 
float( L - 1) ;

And your low pass filter should be: (1/R) * sinc (  (n - ( L-1)/2)   /R )

or in pseudo C++ code:

float m = ( float ) n - float( L-1) /2.f;

 h[n] = (1/R) * sin ( m/R ) / (m/R) ;

Whether the filter length L is odd or even does not matter for those 
formulas ( if I didn't make errors -  Please remember, that I am no filter 
expert ). Just set L = 255 or L = 256 !

Yours Karin



<aine_canby@yahoo.com> schrieb im Newsbeitrag 
news:1119965921.445942.226820@g43g2000cwa.googlegroups.com...

> Hi again, > > I need to design a FIR filter with an even number of coefficients. I > was wondering if the following formula is correct for calculating the > coefficients for a lowpass filter with hamming window - > > for(n=0;n<L;n++) > b[n] = (1/R)sinc(n/R){0.54+0.46*sin(2*pi*n/L) > > where R = Nyquist f / cutoff f > L = filter length > > Thanks for your help once more, > > Ann. >