Windowing Functions =================== .. author jgaeddert Joseph D. Gaeddert .. date January 1, 1975 .. location Boston, MA .. header /doc/windowing/banner.png .. keywords window, windowing, Hamming, Hann, Blackman, harris, Kaiser, Bessel This section describes the various windowing functions in the ``math`` module. These windowing functions are useful for spectral approximation as they are compact in both the time and frequency domains. See :ref:`hamming` for more details. Interfaces ---------- .. _hamming: ``hamming()``, Hamming window ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The function :api:`hamming` computes the :math:`n^{th}` of :math:`N` indices of the Hamming window: .. math:: w(n) = 0.53836 - 0.46164 \cos\left( 2 \pi n / (N-1) \right) :label: eqn-math-window-hamming .. qplot:: window math/windowing.c :args: -w hamming :width: 80% :name: fig-hamming-window :caption: Hamming window response .. _hann: ``hann()``, Hann window ~~~~~~~~~~~~~~~~~~~~~~~~~~~ The function :api:`hann` computes the :math:`n^{th}` of :math:`N` indices of the Hann window: .. math:: :label: eqn-math-window-hann w(n) = 0.5 - 0.5 \cos\left( 2 \pi n / (N-1) \right) .. qplot:: window math/windowing.c :args: -w hann :width: 80% :name: fig-hann-window :caption: Hann window response .. _blackmanharris: ``blackmanharris()``, Blackman-harris window ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The function :api:`blackmanharris` computes the :math:`n^{th}` of :math:`N` indices of the Blackman-harris window: .. math:: :label: eqn-math-window-blackmanharris w(n) = \sum_{k=0}^{3} { a_k \cos\left( 2 \pi k n / (N-1)\right) } where :math:`a_0 = 0.35875`, :math:`a_1 = -0.48829`, :math:`a_2 = 0.14128`, and :math:`a_3 = -0.01168`. .. qplot:: window math/windowing.c :args: -w blackmanharris :width: 80% :name: fig-blackmanharris-window :caption: Blackman-harris window response .. _blackmanharris7: ``blackmanharris7()``, 7th-order Blackman-harris Window ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The function :api:`blackmanharris7` computes the :math:`n^{th}` of :math:`N` indices of the 7:math:`^{th}`-order Blackman-harris window: .. math:: :label: eqn-math-window-blackmanharris7 w(n) = \sum_{k=0}^{3} { a_k \cos\left( 2 \pi k n / (N-1)\right) } where :math:`a_0 = 0.27105`, :math:`a_1 = 0.43329`, :math:`a_2 = 0.21812`, :math:`a_3 = 0.06592`, :math:`a_4 = 0.01081`, :math:`a_5 = 0.00077`, and :math:`a_6 = 0.00001`. Notice that the side-lobes have been suppressed below 100 dB at the expense of a wider main lobe. .. qplot:: window math/windowing.c :args: -w blackmanharris7 :width: 80% :name: fig-blackmanharris7-window :caption: Blackman-harris (7) window response .. _flattop: ``flattop()``, Flat-top Window ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The function :api:`flattop` computes the :math:`n^{th}` of :math:`N` indices of the Flat-top window: .. math:: :label: eqn-math-window-flattop w(n;N) = 1 - 1.93 \cos\left( \frac{n}{N}\right) + 1.29 \cos\left(2\frac{n}{N}\right) - 0.388\cos\left(3\frac{n}{N}\right) + 0.028\cos\left(4\frac{n}{N}\right) Notice that the response looks similar to a low-pass non-recursive [filter design][/doc/firdes/], allows the window to have negative values, and has a peak much greater than one. .. qplot:: window math/windowing.c :args: -w flattop :width: 80% :name: fig-flattop-window :caption: Flat top window response .. _triangular: ``triangular()``, Triangular window ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The function :api:`triangular` computes the :math:`n^{th}` of :math:`N` indices of the triangular window: .. math:: :label: eqn-math-window-triangular w(n;N) = 1 - \left| \frac{n - \frac{N-1}{2} }{\frac{L}{2}}\right| .. qplot:: window math/windowing.c :args: -w triangular :width: 80% :name: fig-triangular-window :caption: Triangular window response .. _kaiser: ``kaiser()``, Kaiser-Bessel window ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The function :api:`kaiser` computes the :math:`n^{th}` of :math:`N` indices of the Kaiser-:math:`\beta` window with a shape parameter :math:`\beta`: .. math:: w(n,\beta) = \frac{ I_0\left(\pi\beta\sqrt{1-\left(\frac{n}{N/2}\right)^2}\right) }{ I_0\left(\pi\beta\right) } :label: eqn-math-window-kaiser where :math:`I_\nu(z)` is the modified Bessel function of the first kind of order :math:`\nu`, and :math:`\beta` is a parameter controlling the width of the window and its stop-band attenuation. In `liquid`, :math:`I_0(z)` is computed using `liquid_besseli0f()` (see [section-math-transcendentals]). A fractional sample offset :math:`\Delta t` can be introduced by substituting :math:`\frac{n}{N/2}` with :math:`\frac{n+\Delta t}{N/2}` in [eqn-math-window-kaiser]. .. qplot:: window math/windowing.c :args: -w kaiser -b 10 :width: 80% :name: fig-kaiser-window :caption: Kaiser window response, :math:`\beta = 10` .. _kbd: ``liquid_kbd_window()``, Kaiser-Bessel derived window ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The function :api:`liquid_kbd_window` computes the :math:`n`-point Kaiser-Bessel derived window with a shape parameter :math:`\beta` storing the result in the :math:`n`-point array `w`. The length of the window *must* be even. .. qplot:: window math/windowing.c :args: -w kbd -b 10 :width: 80% :name: fig-kbd-window :caption: Kaiser-Besssel derived window response, :math:`beta = 10` .. _rcostaper: ``liquid_rcostaper_windowf()``, Raised-Cosine Tapering Window ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The function :api:`liquid_rcostaper_windowf` computes the :math:`n^{th}` of :math:`N` indices of the raised-cosine tapering window with `t` samples on the front and tail used for tapering. .. qplot:: window math/windowing.c :args: -w rcostaper :width: 80% :name: fig-rcostaper-window :caption: Raised-Cosine taper window response