A module for PDL providing window functions for signal processing.
Distributions of this module can be downloaded most easily from CPAN.
(Commits tagged with version numbers,
may also be downloaded from github.)

This module provides symmetric and periodic (DFT-symmetric) window functions for use in filtering and spectral analysis. It provides a high-level access subroutine "window". This functional interface is sufficient for getting the window samples. For analysis and plotting, etc. an object oriented interface is provided. The functional subroutines must be either explicitly exported, or fully qualified. In this document, the word function refers only to the mathematical window functions, while the word subroutine is used to describe code.

Window functions are also known as apodization functions or tapering functions. In this module, each of these functions maps a sequence of $N integers to values called a samples. (To confuse matters, the word sample also has other meanings when describing window functions.) The functions are often named for authors of journal articles. Be aware that across the literature and software, some functions referred to by several different names, and some names refer to several different functions. As a result, the choice of window names is somewhat arbitrary.

The most common and easiest usage of this module is indirect, via some higher-level filtering interface, such as PDL::DSP::Fir::Simple. The next easiest usage is to return a pdl of real-space samples with the subroutine "window". Finally, for analyzing window functions, object methods, such as "new", "plot", "plot_freq" are provided.

In the following, first the functional interface (non-object oriented) is described in "FUNCTIONAL INTERFACE". Next, the object methods are described in "METHODS". Next the low-level subroutines returning samples for each named window are described in "WINDOW FUNCTIONS". Finally, some support routines that may be of interest are described in "AUXILIARY SUBROUTINES".

(string) name of window function. Default: hamming. This selects one of the window functions listed below. Note that the suffix '_per', for periodic, may be ommitted. It is specified with the option periodic => 1

ref to array of parameter or parameters for the window-function subroutine. Only some window-function subroutines take parameters. If the subroutine takes a single parameter, it may be given either as a number, or a list of one number. For example 3 or [3].

Return a reference to the pdl of the frequency response (modulus of the DFT) for the Window instance $win.

Options are passed to the method "modfreqs". The data are created with "modfreqs" if they don't exist. The data are also created even if they already exist if options are supplied. Otherwise the cached data are returned.

Return a name suitable for printing associated with the window $win. This is something like the name used in the documentation for the particular window function. This is static data and does not depend on the instance.

Plot the frequency response (magnitude of the DFT of the window samples). The response is plotted in dB, and the frequency (by default) as a fraction of the Nyquist frequency. Currently, only PDL::Graphics::Gnuplot is supported. The default display type is used.

This sets the units of frequency of the co-ordinate axis. COORD must be one of nyquist, for fraction of the nyquist frequency (range -1,1), sample, for fraction of the sampling frequncy (range -.5,.5), or bin for frequency bin number (range 0,$N-1). The default value is nyquist.

These window-function subroutines return a pdl of $N samples. For most windows, there are a symmetric and a periodic version. The symmetric versions are functions of $N points, uniformly spaced, and taking values from x_lo through x_hi. Here, a periodic function of $N points is equivalent to its symmetric counterpart of $N+1 points, with the final point omitted. The name of a periodic window-function subroutine is the same as that for the corresponding symmetric function, except it has the suffix _per. The descriptions below describe the symmetric version of each window.

The term 'Blackman-Harris family' is meant to include the Hamming family and the Blackman family. These are functions of sums of cosines.

Unless otherwise noted, the arguments in the cosines of all symmetric window functions are multiples of $N numbers uniformly spaced from 0 through 2 pi.

The Chebyshev window. The frequency response of this window has $at dB of attenuation in the stop-band. Another name for this window is the Dolph-Chebyshev window. No periodic version of this window is defined. This routine gives the same result as the routine chebwin in Octave 3.6.2.

The Digital Prolate Spheroidal Sequence (DPSS) window. The parameter $beta is the half-width of the mainlobe, measured in frequency bins. This window maximizes the power in the mainlobe for given $N and $beta. Another name for this window is the sleppian window.

The Kaiser window. (Ref 1). The parameter $beta is the approximate half-width of the mainlobe, measured in frequency bins. Another name for this window is the Kaiser-Bessel window. This window is defined by

Convert Blackman-Harris coefficients. The BH windows are usually defined via coefficients for cosines of integer multiples of an argument. The same windows may be written instead as terms of powers of cosines of the same argument. These may be computed faster as they replace evaluation of cosines with multiplications. This subroutine is used internally to implement the Blackman-Harris family of windows more efficiently.