ulaw#

class diffsptk.MuLawCompression(abs_max=1, mu=255)[source]#

See this page for details.

Parameters:
abs_maxfloat > 0 [scalar]

Absolute maximum value of input.

muint >= 1 [scalar]

Compression factor, \(\mu\).

forward(x)[source]#

Compress waveform by \(\mu\)-law algorithm.

Parameters:
xTensor [shape=(…,)]

Waveform.

Returns:
yTensor [shape=(…,)]

Compressed waveform.

Examples

>>> x = diffsptk.ramp(4)
>>> ulaw = diffsptk.MuLawCompression(4)
>>> y = ulaw(x)
>>> y
tensor([0.0000, 3.0084, 3.5028, 3.7934, 4.0000])

See also

iulaw