From a8f7d139b814d6da2b95c6731ae9b0da1785c705 Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Sun, 11 Jul 2021 12:11:14 +0100 Subject: Update calculate fir --- md/writeup/calculate_fir_coefficients_with_c.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/md/writeup/calculate_fir_coefficients_with_c.md b/md/writeup/calculate_fir_coefficients_with_c.md index c8c9552..e364eb4 100644 --- a/md/writeup/calculate_fir_coefficients_with_c.md +++ b/md/writeup/calculate_fir_coefficients_with_c.md @@ -29,16 +29,26 @@ MathJax = { Low pass ideal impulse response -Impulse response of the filter +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 @@ -70,6 +80,12 @@ How to use calculated coefficients Here is most common windows for window methods that can give you better results then naive rectangular windows filter. There is better ways how to calculate filters, but that for laters. +|Name|Main lobe|Stop band attenuation|Window function| +|---|---|---|---| +| Rectangluar | 13dB | 21dB | 1 | +| Hanning | 31dB | 44dB | $0.5+0.5cos(\frac{2\pi n}{N})$ | +| Hamming | 41dB | 53dB | $0.54 + 0.46 cos\frac{2\pi n}{N}$ | +| Blackman | 57dB | 74dB | $0.42+0.5cos(\frac{2\pi n}{N-1}) + 0.08 cos(\frac{4\pi n }{N-1})$ | ### Rectangular ```c @@ -232,6 +248,7 @@ run program [main.lv/writeup/dsp_lp_filter.md](/writeup/dsp_lp_filter.md) [http://git.main.lv/cgit.cgi/code-snippets.git/tree/fir1](http://git.main.lv/cgit.cgi/code-snippets.git/tree/fir1) +https://en.wikipedia.org/wiki/Sinc_function https://ccrma.stanford.edu/~jos/st/FFT_Simple_Sinusoid.html https://ccrma.stanford.edu/~jos/st/Example_Applications_DFT.html https://ccrma.stanford.edu/~jos/st/Use_Blackman_Window.html -- cgit v1.2.3