GNU Radio C++ API Reference: gr::fft::window Class Reference

| GNU Radio C++ API Reference 3.10.12.0 The Free & Open Software Radio Ecosystem |

Loading...
Searching...
No Matches
gr::fft::window Class Reference

`#include <gnuradio/fft/window.h>`

## Public Types
enum | win_type { WIN_NONE = -1 , WIN_HAMMING = 0 , WIN_HANN = 1 , WIN_HANNING = 1 , WIN_BLACKMAN = 2 , WIN_RECTANGULAR = 3 , WIN_KAISER = 4 , WIN_BLACKMAN_hARRIS = 5 , WIN_BLACKMAN_HARRIS , WIN_BARTLETT = 6 , WIN_FLATTOP = 7 , WIN_NUTTALL = 8 , WIN_BLACKMAN_NUTTALL = 8 , WIN_NUTTALL_CFD , WIN_WELCH = 10 , WIN_PARZEN = 11 , WIN_EXPONENTIAL , WIN_RIEMANN = 13 , WIN_GAUSSIAN , WIN_TUKEY = 15 }

## Static Public Member Functions
static double | max_attenuation (win_type type, double param=INVALID_WIN_PARAM)
| Given a window::win_type, this tells you the maximum attenuation (really the maximum approximation error) you can expect.
static std::vector< float > | coswindow (int ntaps, float c0, float c1, float c2)
| Helper function to build cosine-based windows. 3-coefficient version.
static std::vector< float > | coswindow (int ntaps, float c0, float c1, float c2, float c3)
| Helper function to build cosine-based windows. 4-coefficient version.
static std::vector< float > | coswindow (int ntaps, float c0, float c1, float c2, float c3, float c4)
| Helper function to build cosine-based windows. 5-coefficient version.
static std::vector< float > | rectangular (int ntaps)
| Build a rectangular window.
static std::vector< float > | hamming (int ntaps)
| Build a Hamming window.
static std::vector< float > | hann (int ntaps)
| Build a Hann window (sometimes known as Hanning).
static std::vector< float > | hanning (int ntaps)
| Alias to build a Hann window.
static std::vector< float > | blackman (int ntaps)
| Build an exact Blackman window.
static std::vector< float > | blackman2 (int ntaps)
| Build Blackman window, variation 1.
static std::vector< float > | blackman3 (int ntaps)
| Build Blackman window, variation 2.
static std::vector< float > | blackman4 (int ntaps)
| Build Blackman window, variation 3.
static std::vector< float > | blackman_harris (int ntaps, int atten=92)
| Build a Blackman-harris window with a given attenuation.
static std::vector< float > | blackmanharris (int ntaps, int atten=92)
static std::vector< float > | nuttall (int ntaps)
| Build a minimum 4-term Nuttall (or Blackman-Nuttall) window, referred to by Heinzel G. et al. as a Nuttall4c window.
static std::vector< float > | blackman_nuttall (int ntaps)
| Alias to the Nuttall window.
static std::vector< float > | nuttall_cfd (int ntaps)
| Build a Nuttall 4-term continuous first derivative window, referred to by Heinzel G. et al. as a Nuttall4b window.
static std::vector< float > | flattop (int ntaps)
| Build a flat top window per the SRS specification.
static std::vector< float > | kaiser (int ntaps, double beta)
| Build a Kaiser window with a given beta.
static std::vector< float > | bartlett (int ntaps)
| Build a Barlett (triangular) window.
static std::vector< float > | welch (int ntaps)
static std::vector< float > | parzen (int ntaps)
| Build a Parzen (or de la Valle-Poussin) window.
static std::vector< float > | exponential (int ntaps, double d)
| Build an exponential window with a given decay.
static std::vector< float > | riemann (int ntaps)
| Build a Riemann window.
static std::vector< float > | tukey (int ntaps, float alpha)
| Build a Tukey window.
static std::vector< float > | gaussian (int ntaps, float sigma)
| Build a Gaussian window using the equation.
static std::vector< float > | build (win_type type, int ntaps, double param=INVALID_WIN_PARAM, const bool normalize=false)
| Build a window using gr::fft::win_type to index the type of window desired.

## Static Public Attributes
static constexpr double | INVALID_WIN_PARAM = -1

## Member Enumeration Documentation

## ◆ win_type

enum gr::fft::window::win_type

Enumerator
WIN_NONE | don't use a window
WIN_HAMMING | Hamming window; max attenuation 53 dB.
WIN_HANN | Hann window; max attenuation 44 dB.
WIN_HANNING | alias to WIN_HANN
WIN_BLACKMAN | Blackman window; max attenuation 74 dB.
WIN_RECTANGULAR | Basic rectangular window; max attenuation 21 dB.
WIN_KAISER | Kaiser window; max attenuation see window::max_attenuation.
WIN_BLACKMAN_hARRIS | Blackman-harris window; max attenuation 92 dB.
WIN_BLACKMAN_HARRIS | alias to WIN_BLACKMAN_hARRIS for capitalization consistency
WIN_BARTLETT | Barlett (triangular) window; max attenuation 26 dB.
WIN_FLATTOP | flat top window; useful in FFTs; max attenuation 93 dB
WIN_NUTTALL | Nuttall window; max attenuation 114 dB.
WIN_BLACKMAN_NUTTALL | Nuttall window; max attenuation 114 dB.
WIN_NUTTALL_CFD | Nuttall continuous-first-derivative window; max attenuation 112 dB.
WIN_WELCH | Welch window; max attenuation 31 dB.
WIN_PARZEN | Parzen window; max attenuation 56 dB.
WIN_EXPONENTIAL | Exponential window; max attenuation see window::max_attenuation.
WIN_RIEMANN | Riemann window; max attenuation 39 dB.
WIN_GAUSSIAN | Gaussian window; max attenuation see window::max_attenuation.
WIN_TUKEY | Tukey window; max attenuation see window::max_attenuation.

## Member Function Documentation

## ◆ bartlett()

std::vector< float > gr::fft::window::bartlett | ( | int | ntaps | ) |
| static

Build a Barlett (triangular) window.

See:

      A. V. Oppenheim and R. W. Schafer, "Discrete-Time
      Signal Processing," Upper Saddle River, N.J.: Prentice
      Hall, 2010, pp. 535-538.

Parameters

  ntaps | Number of coefficients in the window.

## ◆ blackman()

std::vector< float > gr::fft::window::blackman | ( | int | ntaps | ) |
| static

Build an exact Blackman window.

See:

      A. V. Oppenheim and R. W. Schafer, "Discrete-Time
      Signal Processing," Upper Saddle River, N.J.: Prentice
      Hall, 2010, pp. 535-538.

Parameters

  ntaps | Number of coefficients in the window.

## ◆ blackman2()

std::vector< float > gr::fft::window::blackman2 | ( | int | ntaps | ) |
| static

Build Blackman window, variation 1.

## ◆ blackman3()

std::vector< float > gr::fft::window::blackman3 | ( | int | ntaps | ) |
| static

Build Blackman window, variation 2.

## ◆ blackman4()

std::vector< float > gr::fft::window::blackman4 | ( | int | ntaps | ) |
| static

Build Blackman window, variation 3.

## ◆ blackman_harris()

std::vector< float > gr::fft::window::blackman_harris | ( | int | ntaps,
|  | int | atten = 92 )
| static

Build a Blackman-harris window with a given attenuation.

        f. j. harris, "On the use of windows for harmonic analysis
        with the discrete Fourier transforms," Proc. IEEE, Vol. 66,
        ppg. 51-83, Jan. 1978.

Parameters

  ntaps | Number of coefficients in the window.
  atten | Attenuation factor. Must be [61, 67, 74, 92]. See the above paper for details.

## ◆ blackman_nuttall()

std::vector< float > gr::fft::window::blackman_nuttall | ( | int | ntaps | ) |
| static

Alias to the Nuttall window.

Parameters

  ntaps | Number of coefficients in the window.

## ◆ blackmanharris()

std::vector< float > gr::fft::window::blackmanharris | ( | int | ntaps,
|  | int | atten = 92 )
| static

Alias to gr::fft::window::blackman_harris.

## ◆ build()

std::vector< float > gr::fft::window::build | ( | win_type | type,
|  | int | ntaps,
|  | double | param = INVALID_WIN_PARAM,
|  | const bool | normalize = false )
| static

Build a window using gr::fft::win_type to index the type of window desired.

Parameters

  type | a gr::fft::win_type index for the type of window.
  ntaps | Number of coefficients in the window.
  param | Parameter value used for Kaiser (beta), Exponential (d), Gaussian (sigma) and Tukey (alpha) window creation.
  normalize | If true, return a window with unit power

References INVALID_WIN_PARAM.

## ◆ coswindow() [1/3]

std::vector< float > gr::fft::window::coswindow | ( | int | ntaps,
|  | float | c0,
|  | float | c1,
|  | float | c2 )
| static

Helper function to build cosine-based windows. 3-coefficient version.

## ◆ coswindow() [2/3]

std::vector< float > gr::fft::window::coswindow | ( | int | ntaps,
|  | float | c0,
|  | float | c1,
|  | float | c2,
|  | float | c3 )
| static

Helper function to build cosine-based windows. 4-coefficient version.

## ◆ coswindow() [3/3]

std::vector< float > gr::fft::window::coswindow | ( | int | ntaps,
|  | float | c0,
|  | float | c1,
|  | float | c2,
|  | float | c3,
|  | float | c4 )
| static

Helper function to build cosine-based windows. 5-coefficient version.

## ◆ exponential()

std::vector< float > gr::fft::window::exponential | ( | int | ntaps,
|  | double | d )
| static

Build an exponential window with a given decay.

See: http://en.wikipedia.org/wiki/Window_function#Exponential_or_Poisson_window

Parameters

  ntaps | Number of coefficients in the window.
  d | Decay of `d` dB over half the window length.

## ◆ flattop()

std::vector< float > gr::fft::window::flattop | ( | int | ntaps | ) |
| static

Build a flat top window per the SRS specification.

See:

        Stanford Research Systems, "Model SR785 Dynamic Signal
        Analyzer: Operating Manual and Programming Reference,"
        2017, pp 2-13

Note: there are many flat top windows, and this implementation is different from SciPY and Matlab which use the coefficients from D’Antona et al. "Digital Signal Processing for Measurement Systems" with the following cosine coefficients:

        [0.21557895, 0.41663158, 0.277263158, 0.083578947, 0.006947368]

Parameters

  ntaps | Number of coefficients in the window.

## ◆ gaussian()

std::vector< float > gr::fft::window::gaussian | ( | int | ntaps,
|  | float | sigma )
| static

Build a Gaussian window using the equation.

    exp(-(1/2) * (n/sigma)^2)

Parameters

  ntaps | Number of coefficients in the window.
  sigma | Standard deviation of gaussian distribution.

## ◆ hamming()

std::vector< float > gr::fft::window::hamming | ( | int | ntaps | ) |
| static

Build a Hamming window.

See:

      A. V. Oppenheim and R. W. Schafer, "Discrete-Time
      Signal Processing," Upper Saddle River, N.J.: Prentice
      Hall, 2010, pp. 535-538.

Parameters

  ntaps | Number of coefficients in the window.

## ◆ hann()

std::vector< float > gr::fft::window::hann | ( | int | ntaps | ) |
| static

Build a Hann window (sometimes known as Hanning).

See:

      A. V. Oppenheim and R. W. Schafer, "Discrete-Time
      Signal Processing," Upper Saddle River, N.J.: Prentice
      Hall, 2010, pp. 535-538.

Parameters

  ntaps | Number of coefficients in the window.

## ◆ hanning()

std::vector< float > gr::fft::window::hanning | ( | int | ntaps | ) |
| static

Alias to build a Hann window.

Parameters

  ntaps | Number of coefficients in the window.

## ◆ kaiser()

std::vector< float > gr::fft::window::kaiser | ( | int | ntaps,
|  | double | beta )
| static

Build a Kaiser window with a given beta.

See:

        A. V. Oppenheim and R. W. Schafer, "Discrete-Time
        Signal Processing," Upper Saddle River, N.J.: Prentice
        Hall, 2010, pp. 541-545.

Parameters

  ntaps | Number of coefficients in the window.
  beta | Shaping parameter of the window. See the discussion in Oppenheim and Schafer.

## ◆ max_attenuation()

double gr::fft::window::max_attenuation | ( | win_type | type,
|  | double | param = INVALID_WIN_PARAM )
| static

Given a window::win_type, this tells you the maximum attenuation (really the maximum approximation error) you can expect.

For most windows, this is a set value. For the Kaiser, Exponential, Gaussian, and Tukey windows, the attenuation is based on the value of a provided parameter.

For the Kaiser window the actual relationship is a piece-wise exponential relationship to calculate beta from the desired attenuation and can be found on page 542 of Oppenheim and Schafer (Discrete-Time Signal Processing, 3rd edition). To simplify this function to solve for A given beta, we use a linear form that is exact for attenuation >= 50 dB. For an attenuation of 50 dB, beta = 4.55; for an attenuation of 70 dB, beta = 6.76.

Exponential attenuation is complicated to measure due to the irregular error ripple structure, but it ranges between 23 and 26 dB depending on the decay factor; 26 dB is a good bound.

The Gaussian window should not be used for window based filter construction; instead there is a dedicated gaussian filter construction function. There is no meaningful way to measure approximation error 'delta' as shown in Fig 7.23 of Oppenheim and Schafer (Discrete-Time Signal Processing, 3rd edition).

Tukey windows provide attenuation that varies non-linearily between Rectangular (21 dB) and Hann (44 dB) windows.

Parameters

  type | The window::win_type enumeration of the window type.
  param | Parameter value used for Kaiser (beta), Exponential (d), Gaussian (sigma) and Tukey (alpha) window creation.

References INVALID_WIN_PARAM.

## ◆ nuttall()

std::vector< float > gr::fft::window::nuttall | ( | int | ntaps | ) |
| static

Build a minimum 4-term Nuttall (or Blackman-Nuttall) window, referred to by Heinzel G. et al. as a Nuttall4c window.

See: A.H. Nuttall: 'Some windows with very good sidelobe behaviour', IEEE Trans. on Acoustics, Speech and Signal Processing, Vol ASSP-29, figure 15

See: 'Spectrum and spectral density estimation by the Discrete Fourier transform (DFT), including a comprehensive list of window functions and some new flat-top windows', February 15, 2002 https://holometer.fnal.gov/GH_FFT.pdf

Also: http://en.wikipedia.org/wiki/Window_function#Blackman.E2.80.93Nuttall_window

Parameters

  ntaps | Number of coefficients in the window.

## ◆ nuttall_cfd()

std::vector< float > gr::fft::window::nuttall_cfd | ( | int | ntaps | ) |
| static

Build a Nuttall 4-term continuous first derivative window, referred to by Heinzel G. et al. as a Nuttall4b window.

See: A.H. Nuttall: 'Some windows with very good sidelobe behaviour', IEEE Trans. on Acoustics, Speech and Signal Processing, Vol ASSP-29, figure 12

See: 'Spectrum and spectral density estimation by the Discrete Fourier transform (DFT), including a comprehensive list of window functions and some new flat-top windows', February 15, 2002 https://holometer.fnal.gov/GH_FFT.pdf

Also: http://en.wikipedia.org/wiki/Window_function#Nuttall_window.2C_continuous_first_derivative

Parameters

  ntaps | Number of coefficients in the window.

## ◆ parzen()

std::vector< float > gr::fft::window::parzen | ( | int | ntaps | ) |
| static

Build a Parzen (or de la Valle-Poussin) window.

See:

      A. D. Poularikas, "Handbook of Formulas and Tables for
      Signal Processing," Springer, Oct 28, 1998

Parameters

  ntaps | Number of coefficients in the window.

## ◆ rectangular()

std::vector< float > gr::fft::window::rectangular | ( | int | ntaps | ) |
| static

Build a rectangular window.

Taps are flat across the window.

Parameters

  ntaps | Number of coefficients in the window.

## ◆ riemann()

std::vector< float > gr::fft::window::riemann | ( | int | ntaps | ) |
| static

Build a Riemann window.

See:

      A. D. Poularikas, "Handbook of Formulas and Tables for
      Signal Processing," Springer, Oct 28, 1998

Parameters

  ntaps | Number of coefficients in the window.

## ◆ tukey()

std::vector< float > gr::fft::window::tukey | ( | int | ntaps,
|  | float | alpha )
| static

Build a Tukey window.

    Bloomfield, P. Fourier Analysis of Time Series: An Introduction. New York:
    Wiley-Interscience, 2000, pp 69 (eqn 6.9)

Parameters

  ntaps | Number of coefficients in the window.
  alpha | Shaping parameter for the Tukey window, an alpha of zero is equivalent to a rectangular window, an alpha of 1 is equivalent to Hann.

## ◆ welch()

std::vector< float > gr::fft::window::welch | ( | int | ntaps | ) |
| static

## Member Data Documentation

## ◆ INVALID_WIN_PARAM

double gr::fft::window::INVALID_WIN_PARAM = -1
| staticconstexpr

Referenced by build(), and max_attenuation().

The documentation for this class was generated from the following file:

- window.h