# Low Pass Filter: Sinc Filter ###### tags: `Tutorial` * Generalization * highpass * Bandpass --- ## Section 1 - Ideal Low-Pass Filter The **frequency response** of the ideal “brick-wall" low-pass filter: * full transmission in the pass band * complete attenuation in the stop band * the transition between the two is infinite small. <br> In mathematical terms, it can be described by the **rectangular function**: ![](https://i.imgur.com/Yacx70T.png) where B is an arbitrary cutoff frequency (fc). <br> To get the impulse reponse (temporal domain), we can apply inverse Fourier transform: ![](https://i.imgur.com/fLPbkM7.png) where sinc is the normalized **sinc function**. ![](https://i.imgur.com/drU4ymV.png) [推導](https://ccrma.stanford.edu/~jos/sasp/Ideal_Lowpass_Filter.html) ![](https://i.imgur.com/3d0l3ZQ.png) We call such filter **sinc filter**. ## Section 2 - Truncation and Windowing ### 2.1 Truncation To apply the sinc filter, we can convolve singal with the impulse response. However, the sinc function continues to **both negative and positive infinity** without dropping to zero amplitude, which is computationally unfeasible. So, we need to **truncate** the filter to finite length. ![](https://i.imgur.com/07jmPqL.png) Note that the modified version is an **approximation** of the ideal one: * Ripple in pass band * Poor attenuation in the stopband * Gibbs effect * an approximation error around jump discontinuity * [approximate square wave with sinusoids ](https://zh.wikipedia.org/wiki/%E5%90%89%E5%B8%83%E6%96%AF%E7%8E%B0%E8%B1%A1#/media/File:SquareWave.gif) ### 2.1 Windowing The solution to aforementioned issues is **windowing**. The idea is to reduce the abruptness of the truncated ends and thereby improve the frequency response. ![](https://i.imgur.com/MLh9Ihx.png) Popular window: * **Blackman window** (recommended) * Hamming window * Hanning window * ... * Rectangular window, is equal to **no window** Note the fc is **normalized** ([normalized frequency](https://en.wikipedia.org/wiki/Normalized_frequency_(signal_processing)): fc/fs). Notice that the maximum displayed frequency is 0.5 (nyquist frequency). ## Section 3 - Design a Truncated Windowed Sinc LPF Generally, we need to consider 3 fators: * window type * the cutoff frequency * the length of the filter kernel and find a trade-off between **computation overhead** and the **filter sharpness**. Online tool: https://fiiir.com/ ### 3.1 Window Type Comparison of Blackman and Hamming windows: * the Hamming window has about a 20% faster transition bandwidth (or roll-off) than the Blackman. * the Blackman has a better stopband attenuation. To be exact, the stopband attenuation for the Blackman is -74dB (-0.02%), while the Hamming is only -53dB (-0.2%). <img src="https://i.imgur.com/cMMj4Bt.png" alt="drawing" width="400"/> ### 3.2 Bandwidth and Filter Length The relation between the **filter length 𝑁** and **transition bandwidth 𝑏** is ![](https://i.imgur.com/kkCJM1o.png) <br> ![](https://i.imgur.com/CtaYG9R.png) ## JUCE Documents [dsp::FilterDesign](https://docs.juce.com/master/structdsp_1_1FilterDesign.html) [dsp::Oversampling](https://docs.juce.com/master/classdsp_1_1Oversampling.html) ## Reference https://tomroelandts.com/articles/how-to-create-a-simple-low-pass-filter https://profiles.uonbi.ac.ke/wokelo/files/16-windowed_sinc_filters-ver3nov2013.pdf