pad_reflect

ketos.audio.utils.misc.pad_reflect(x, pad_left=0, pad_right=0, invert=False)[source]

Pad array with its own (inverted) reflection along the first axis (0).

Args:
x: numpy.array

The data to be padded.

pad_left: int

Amount of padding on the left

pad_right: int

Amount of padding on the right

invert: bool

Whether to invert the reflection. Default is False.

Returns:
x_padded: numpy.array

Padded array

Example:
>>> from ketos.audio.utils.misc import pad_reflect
>>> arr = np.arange(9) #create a simple array
>>> print(arr)
[0 1 2 3 4 5 6 7 8]
>>> arr = pad_reflect(arr, pad_right=3) #pad on the right
>>> print(arr)
[0 1 2 3 4 5 6 7 8 7 6 5]