window#

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

See this page for details.

Parameters:
in_lengthint >= 1

Input length or window length, \(L_1\).

out_lengthint >= L1 or None

Output length, \(L_2\). If \(L_2 > L_1\), output is zero-padded.

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

Window type.

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

Normalization type of window.

forward(x)[source]#

Apply a window function to given waveform.

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

Framed waveform.

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

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 window function.

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

Framed waveform.

out_lengthint >= L1 or None

Output length, \(L_2\).

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

Window type.

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

Normalization type of window.

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

Windowed waveform.

See also

frame unframe spec