window#

class diffsptk.Window(in_length, out_length=None, *, window='blackman', norm='power')[source]#

See this page for details.

Parameters:
in_lengthint >= 1

The window length, \(L_1\).

out_lengthint >= L1 or None

The output length, \(L_2\). If \(L_2 > L_1\), output is zero-padded. If None, \(L_2 = L_1\).

window[‘blackman’, ‘hamming’, ‘hanning’, ‘bartlett’, ‘trapezoidal’, ‘rectangular’, ‘nuttall’]

The window type.

norm[‘none’, ‘power’, ‘magnitude’]

The normalization type of the window.

forward(x)[source]#

Apply a window function to the given waveform.

Parameters:
xTensor [shape=(…, L1)]

The input framed waveform.

Returns:
outTensor [shape=(…, L2)]

The windowed waveform.

Examples

>>> x = torch.ones(5)
>>> window = diffsptk.Window(5, out_length=7, window="hamming", norm="none")
>>> y = window(x)
>>> y
tensor([0.0800, 0.5400, 1.0000, 0.5400, 0.0800, 0.0000, 0.0000])
diffsptk.functional.window(x, out_length=None, *, window='blackman', norm='power')[source]#

Apply a window function to the given waveform.

Parameters:
xTensor [shape=(…, L1)]

The input framed waveform.

out_lengthint >= L1 or None

The output length, \(L_2\). If \(L_2 > L_1\), output is zero-padded. If None, \(L_2 = L_1\).

window[‘blackman’, ‘hamming’, ‘hanning’, ‘bartlett’, ‘trapezoidal’, ‘rectangular’, ‘nuttall’]

The window type.

norm[‘none’, ‘power’, ‘magnitude’]

The normalization type of the window.

Returns:
outTensor [shape=(…, L2)]

The windowed waveform.

See also

frame unframe spec