window()

audmath.window(samples, shape='tukey', half=None)[source]

Return a window.

The window will start from and/or end at 0. If at least 3 samples are requested and the number of samples is odd, the windows maximum value will always be 1.

The shape of the window is selected via shape The following figure shows all available shapes. For the Kaiser window we use β=14\beta = 14 and set its first sample to 0.

../_images/audmath-window-1.png
Parameters
  • samples (int) – length of window

  • shape (str) – shape of window

  • half (Optional[str]) – if None return whole window, if 'left' or 'right' return left or right half-window. Other than the whole window the half-windows will always contain 1 as maximum value as long as samples > 1

Return type

ndarray

Returns

window

Raises

Examples

>>> window(7)
array([0.  , 0.25, 0.75, 1.  , 0.75, 0.25, 0.  ])
>>> window(6)
array([0.  , 0.25, 0.75, 0.75, 0.25, 0.  ])
>>> window(5, shape="linear", half="left")
array([0.  , 0.25, 0.5 , 0.75, 1.  ])