components.fft.window

pyctools.components.fft.window.Window

General 2-D window.

pyctools.components.fft.window.Hann

Hann window.

pyctools.components.fft.window.Hamming

Hamming window.

pyctools.components.fft.window.Blackman

Blackman window.

pyctools.components.fft.window.Kaiser

Kaiser-Bessel window.

pyctools.components.fft.window.InverseWindow

Generate "inverse" window function with inter-tile cross-fade.

pyctools.components.fft.window.HannCore

pyctools.components.fft.window.HammingCore

pyctools.components.fft.window.BlackmanCore

pyctools.components.fft.window.KaiserCore

FFT window functions.

Window functions are used with Fourier transforms to give some control over the trade-off between frequency resolution and “leakage”. See Wikipedia for a good introduction to the subject.

This module contains components to generate several popular window functions, and one to generate a corresponding “inverse window”. This can be used to reconstruct a signal from its Fourier transform. Note that overlapping tiles are almost essential to avoid visible tile edge effects when doing this. The inverse windows compensate for the attenuation of the original window and “cross fade” from one tile to the next, overlapping, tile. There is a choice of crossfade function.

For each window function component there is a “core” function. This generates a single Frame containing the window data. This is useful if you don’t need to change the window while your network of components is running. For example:

window = Modulate()
window.cell(HammingCore(xtile=32, ytile=32))

creates a windowing component that uses a 32x32 Hamming window. Its cell input does not need to be connected to anything.

Hann

Hann window.

HannCore

Hamming

Hamming window.

HammingCore

Blackman

Blackman window.

BlackmanCore

Kaiser

Kaiser-Bessel window.

KaiserCore

InverseWindow

Generate "inverse" window function with inter-tile cross-fade.

class Window(config={}, **kwds)[source]

Bases: Component

General 2-D window.

The function parameter selects one of several widely used 1-D window functions. The sym parameter makes the window symmetrical or not. Note that a symmetrical window with an even size does not have a central value of unity.

alpha is the control parameter for the Kaiser window. See numpy.kaiser for more detail. Note that NumPy and SciPy use a control parameter called beta, which is alpha * pi.

The combine2D parameter selects how the horizontal and vertical windows are combined to make a 2-D window. (If either dimension has size one it has no effect.) The option names refer to the shape of the contours if you plotted the window. square means the two windows are simply multiplied together. round means the window value depends on the normalised distance from the centre of the window, with points further than 0.5 set to zero. round2 is an alternative that is normalised to the diagonal, so no points are further than 0.5.

Config

xtile

int

Horizontal tile size.

ytile

int

Vertical tile size.

sym

bool

When True (default), generates a symmetric window.

combine2D

str

How to combine 1-D windows to make 2-D window. Can be square, round or round2.

function

str

Choose the window function. Possible values: 'Hann', 'Hamming', 'Blackman', 'Kaiser'

alpha

float

Window control parameter.

class Hann(config={}, **kwds)[source]

Bases: WindowBase

Hann window.

Config

xtile

int

Horizontal tile size.

ytile

int

Vertical tile size.

sym

bool

When True (default), generates a symmetric window.

class Hamming(config={}, **kwds)[source]

Bases: WindowBase

Hamming window.

Config

xtile

int

Horizontal tile size.

ytile

int

Vertical tile size.

sym

bool

When True (default), generates a symmetric window.

class Blackman(config={}, **kwds)[source]

Bases: WindowBase

Blackman window.

Config

xtile

int

Horizontal tile size.

ytile

int

Vertical tile size.

sym

bool

When True (default), generates a symmetric window.

alpha

float

Window control parameter.

class Kaiser(config={}, **kwds)[source]

Bases: WindowBase

Kaiser-Bessel window.

See numpy.kaiser for more detail. Note that NumPy and SciPy use a control parameter called beta. This is alpha * pi.

Config

xtile

int

Horizontal tile size.

ytile

int

Vertical tile size.

sym

bool

When True (default), generates a symmetric window.

alpha

float

Window control parameter.

class InverseWindow(config={}, **kwds)[source]

Bases: Component

Generate “inverse” window function with inter-tile cross-fade.

The fade config value determines the transition from one tile to the next, within their area of overlap. 'switch' abruptly cuts from one tile to the next, 'linear' does a cross-fade and 'minsnr' does a weighted cross-fade to minimise signal to noise ratio.

Config

xtile

int

Horizontal tile size.

ytile

int

Vertical tile size.

xoff

int

Horizontal tile offset. Typically set to xtile / 2.

yoff

int

Vertical tile offset. Typically set to ytile / 2.

fade

str

Can be 'switch', 'linear' or 'minsnr'.

outputs = ['window', 'inv_window']

Comments or questions? Please email jim@jim-easterbrook.me.uk.