alaw#

class diffsptk.ALawCompression(abs_max=1, a=87.6)[source]#

See this page for details.

Parameters:
abs_maxfloat > 0

The absolute maximum value of the input waveform.

afloat >= 1

The compression factor, \(A\).

forward(x)[source]#

Compress the input waveform using the A-law algorithm.

Parameters:
xTensor [shape=(…,)]

The input waveform.

Returns:
outTensor [shape=(…,)]

The compressed waveform.

Examples

>>> x = diffsptk.ramp(4)
>>> alaw = diffsptk.ALawCompression(4)
>>> y = alaw(x)
>>> y
tensor([0.0000, 2.9868, 3.4934, 3.7897, 4.0000])
diffsptk.functional.alaw(x, abs_max=1, a=87.6)[source]#

Compress the input waveform using the A-law algorithm.

Parameters:
xTensor [shape=(…,)]

The input waveform.

abs_maxfloat > 0

The absolute maximum value of the input waveform.

afloat >= 1

The compression factor, \(A\).

Returns:
outTensor [shape=(…,)]

The compressed waveform.

See also

ialaw ulaw