title:Calculate fir coefficients with C
keywords:c,linux,fir,dsp,octave
# Calculate fir coefficients with C
## Intro
FIR filter's is probably ones of fascinating parts when you want to do with DSP,
its kind of too simple from first glance and they works. As before I have learned
about FIR and IIR
and was able to use them just from tools that take as input parameters and
give as output coefficients. Now time came just to calculate FIR from ground up.
Also C is perfect to do stuff without abstraction levels hiding details, and can
be ported to other languages and platforms. Lets calculate filter coefficients
with windows method. There is few more but those for later.
## Implementation
Low pass ideal impulse response
Ideal impulse response of the filter
$$2f_c\frac{sin(n \omega_c)}{n \omega_c}$$
```c
for (i=0;i-1.0E-5 && x < 1.0E-5) return (1.0);
return sin(x)/x;
}
```
Rectangular window for low pass filter
```c
for (i=0;i